lkml.org 
[lkml]   [2017]   [Feb]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 3/5] userfaultfd: non-cooperative: add event for exit() notification
On Wed, 1 Feb 2017 08:35:07 +0200 Mike Rapoport <rppt@linux.vnet.ibm.com> wrote:

> On Tue, Jan 31, 2017 at 04:41:32PM -0800, Andrew Morton wrote:
> > On Fri, 27 Jan 2017 20:44:31 +0200 Mike Rapoport <rppt@linux.vnet.ibm.com> wrote:
> >
> > > Allow userfaultfd monitor track termination of the processes that have
> > > memory backed by the uffd.
> > >
> > > --- a/fs/userfaultfd.c
> > > +++ b/fs/userfaultfd.c
> > > @@ -774,6 +774,30 @@ void userfaultfd_unmap_complete(struct mm_struct *mm, struct list_head *uf)
> > > }
> > > }
> > >
> > > +void userfaultfd_exit(struct mm_struct *mm)
> > > +{
> > > + struct vm_area_struct *vma = mm->mmap;
> > > +
> > > + while (vma) {
> > > + struct userfaultfd_ctx *ctx = vma->vm_userfaultfd_ctx.ctx;
> > > +
> > > + if (ctx && (ctx->features & UFFD_FEATURE_EVENT_EXIT)) {
> > > + struct userfaultfd_wait_queue ewq;
> > > +
> > > + userfaultfd_ctx_get(ctx);
> > > +
> > > + msg_init(&ewq.msg);
> > > + ewq.msg.event = UFFD_EVENT_EXIT;
> > > +
> > > + userfaultfd_event_wait_completion(ctx, &ewq);
> > > +
> > > + ctx->features &= ~UFFD_FEATURE_EVENT_EXIT;
> > > + }
> > > +
> > > + vma = vma->vm_next;
> > > + }
> > > +}
> >
> > And we can do the vma walk without locking because the caller (exit_mm)
> > knows it now has exclusive access. Worth a comment?
>
> Sure, will add. Do you prefer an incremental patch or update this one?

Either is OK. I routinely turn replacement patches into deltas so I
and others can see what changed.

\
 
 \ /
  Last update: 2017-02-01 23:27    [W:0.159 / U:0.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site