userfaultfd: add vm_userfaultfd_ctx to the vm_area_struct
authorAndrea Arcangeli <[email protected]>
Fri, 4 Sep 2015 22:46:14 +0000 (15:46 -0700)
committerLinus Torvalds <[email protected]>
Fri, 4 Sep 2015 23:54:41 +0000 (16:54 -0700)
This adds the vm_userfaultfd_ctx to the vm_area_struct.

Signed-off-by: Andrea Arcangeli <[email protected]>
Acked-by: Pavel Emelyanov <[email protected]>
Cc: Sanidhya Kashyap <[email protected]>
Cc: [email protected]
Cc: "Kirill A. Shutemov" <[email protected]>
Cc: Andres Lagar-Cavilla <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Peter Feiner <[email protected]>
Cc: "Dr. David Alan Gilbert" <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: "Huangpeng (Peter)" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/mm_types.h
kernel/fork.c

index 15549578d55998e5497c5da58a50fa1531e132d8..26a30c3566f0c751b66174fe8813a005f00a817d 100644 (file)
@@ -256,6 +256,16 @@ struct vm_region {
                                                * this region */
 };
 
+#ifdef CONFIG_USERFAULTFD
+#define NULL_VM_UFFD_CTX ((struct vm_userfaultfd_ctx) { NULL, })
+struct vm_userfaultfd_ctx {
+       struct userfaultfd_ctx *ctx;
+};
+#else /* CONFIG_USERFAULTFD */
+#define NULL_VM_UFFD_CTX ((struct vm_userfaultfd_ctx) {})
+struct vm_userfaultfd_ctx {};
+#endif /* CONFIG_USERFAULTFD */
+
 /*
  * This struct defines a memory VMM memory area. There is one of these
  * per VM-area/task.  A VM area is any part of the process virtual memory
@@ -322,6 +332,7 @@ struct vm_area_struct {
 #ifdef CONFIG_NUMA
        struct mempolicy *vm_policy;    /* NUMA policy for the VMA */
 #endif
+       struct vm_userfaultfd_ctx vm_userfaultfd_ctx;
 };
 
 struct core_thread {
index 03aa2e6de7a4e90696c003792641d2c3a150cd02..ceb4eb4abb9df57d47abf60933fff346847de1b4 100644 (file)
@@ -456,6 +456,7 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
                        goto fail_nomem_anon_vma_fork;
                tmp->vm_flags &= ~VM_LOCKED;
                tmp->vm_next = tmp->vm_prev = NULL;
+               tmp->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
                file = tmp->vm_file;
                if (file) {
                        struct inode *inode = file_inode(file);