Re: [PATCH 10/23] userfaultfd: add new syscall to provide memory externalization

2015-06-23 Thread Andrea Arcangeli
Hi Dave, On Tue, Jun 23, 2015 at 12:00:19PM -0700, Dave Hansen wrote: > Down in userfaultfd_wake_function(), it looks like you intended for a > len=0 to mean "wake all". But the validate_range() that we do from > userspace has a !len check in it, which keeps us from passing a len=0 in > from

Re: [PATCH 10/23] userfaultfd: add new syscall to provide memory externalization

2015-06-23 Thread Dave Hansen
On 05/14/2015 10:31 AM, Andrea Arcangeli wrote: > +static int userfaultfd_wake_function(wait_queue_t *wq, unsigned mode, > + int wake_flags, void *key) > +{ > + struct userfaultfd_wake_range *range = key; > + int ret; > + struct userfaultfd_wait_queue

Re: [PATCH 10/23] userfaultfd: add new syscall to provide memory externalization

2015-06-23 Thread Dave Hansen
On 05/14/2015 10:31 AM, Andrea Arcangeli wrote: +static int userfaultfd_wake_function(wait_queue_t *wq, unsigned mode, + int wake_flags, void *key) +{ + struct userfaultfd_wake_range *range = key; + int ret; + struct userfaultfd_wait_queue *uwq;

Re: [PATCH 10/23] userfaultfd: add new syscall to provide memory externalization

2015-06-23 Thread Andrea Arcangeli
Hi Dave, On Tue, Jun 23, 2015 at 12:00:19PM -0700, Dave Hansen wrote: Down in userfaultfd_wake_function(), it looks like you intended for a len=0 to mean wake all. But the validate_range() that we do from userspace has a !len check in it, which keeps us from passing a len=0 in from

Re: [PATCH 10/23] userfaultfd: add new syscall to provide memory externalization

2015-05-15 Thread Linus Torvalds
On Fri, May 15, 2015 at 9:04 AM, Andrea Arcangeli wrote: > > To fix it I added this along a comment: Ok, this looks good as a explanation/fix for the races (and also as an example of my worry about waitqueue_active() use in general). However, it now makes me suspect that the optimistic "let's

Re: [PATCH 10/23] userfaultfd: add new syscall to provide memory externalization

2015-05-15 Thread Andrea Arcangeli
On Thu, May 14, 2015 at 10:49:06AM -0700, Linus Torvalds wrote: > On Thu, May 14, 2015 at 10:31 AM, Andrea Arcangeli > wrote: > > +static __always_inline void wake_userfault(struct userfaultfd_ctx *ctx, > > + struct userfaultfd_wake_range > > *range) > >

Re: [PATCH 10/23] userfaultfd: add new syscall to provide memory externalization

2015-05-15 Thread Andrea Arcangeli
On Thu, May 14, 2015 at 10:49:06AM -0700, Linus Torvalds wrote: On Thu, May 14, 2015 at 10:31 AM, Andrea Arcangeli aarca...@redhat.com wrote: +static __always_inline void wake_userfault(struct userfaultfd_ctx *ctx, + struct userfaultfd_wake_range

Re: [PATCH 10/23] userfaultfd: add new syscall to provide memory externalization

2015-05-15 Thread Linus Torvalds
On Fri, May 15, 2015 at 9:04 AM, Andrea Arcangeli aarca...@redhat.com wrote: To fix it I added this along a comment: Ok, this looks good as a explanation/fix for the races (and also as an example of my worry about waitqueue_active() use in general). However, it now makes me suspect that the

Re: [PATCH 10/23] userfaultfd: add new syscall to provide memory externalization

2015-05-14 Thread Linus Torvalds
On Thu, May 14, 2015 at 10:31 AM, Andrea Arcangeli wrote: > +static __always_inline void wake_userfault(struct userfaultfd_ctx *ctx, > + struct userfaultfd_wake_range > *range) > +{ > + if (waitqueue_active(>fault_wqh)) > +

[PATCH 10/23] userfaultfd: add new syscall to provide memory externalization

2015-05-14 Thread Andrea Arcangeli
Once an userfaultfd has been created and certain region of the process virtual address space have been registered into it, the thread responsible for doing the memory externalization can manage the page faults in userland by talking to the kernel using the userfaultfd protocol. poll() can be used

Re: [PATCH 10/23] userfaultfd: add new syscall to provide memory externalization

2015-05-14 Thread Linus Torvalds
On Thu, May 14, 2015 at 10:31 AM, Andrea Arcangeli aarca...@redhat.com wrote: +static __always_inline void wake_userfault(struct userfaultfd_ctx *ctx, + struct userfaultfd_wake_range *range) +{ + if (waitqueue_active(ctx-fault_wqh)) +

[PATCH 10/23] userfaultfd: add new syscall to provide memory externalization

2015-05-14 Thread Andrea Arcangeli
Once an userfaultfd has been created and certain region of the process virtual address space have been registered into it, the thread responsible for doing the memory externalization can manage the page faults in userland by talking to the kernel using the userfaultfd protocol. poll() can be used