From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754053AbdBAW1Z (ORCPT ); Wed, 1 Feb 2017 17:27:25 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:42314 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753859AbdBAW1W (ORCPT ); Wed, 1 Feb 2017 17:27:22 -0500 Date: Wed, 1 Feb 2017 14:27:20 -0800 From: Andrew Morton To: Mike Rapoport Cc: Andrea Arcangeli , "Dr. David Alan Gilbert" , Hillf Danton , Mike Kravetz , Pavel Emelyanov , Linux-MM , LKML Subject: Re: [PATCH v2 3/5] userfaultfd: non-cooperative: add event for exit() notification Message-Id: <20170201142720.2d3f06ad1ba4410995e5ae0d@linux-foundation.org> In-Reply-To: <20170201063506.GA7921@rapoport-lnx> References: <1485542673-24387-1-git-send-email-rppt@linux.vnet.ibm.com> <1485542673-24387-4-git-send-email-rppt@linux.vnet.ibm.com> <20170131164132.439f9d30e3a9b3c79bcada3a@linux-foundation.org> <20170201063506.GA7921@rapoport-lnx> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 1 Feb 2017 08:35:07 +0200 Mike Rapoport 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 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.