mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
userfaultfd: non-cooperative: add event for exit() notification
Allow userfaultfd monitor track termination of the processes that have memory backed by the uffd. [[email protected]: add comment] Link: http://lkml.kernel.org/r/20170202135448.GB19804@rapoport-lnxLink: http://lkml.kernel.org/r/[email protected] Signed-off-by: Mike Rapoport <[email protected]> Acked-by: Hillf Danton <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: "Dr. David Alan Gilbert" <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Pavel Emelyanov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
897ab3e0c4
commit
ca49ca7114
4 changed files with 41 additions and 1 deletions
|
|
@ -774,6 +774,34 @@ 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;
|
||||
|
||||
/*
|
||||
* We can do the vma walk without locking because the caller
|
||||
* (exit_mm) knows it now has exclusive access
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
static int userfaultfd_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct userfaultfd_ctx *ctx = file->private_data;
|
||||
|
|
|
|||
Loading…
Reference in a new issue