Merge tag 'mm-nonmm-stable-2023-04-27-16-01' of git://git.kernel.org/pub/scm/linux...
[linux-block.git] / include / linux / mm_types.h
index a57e6ae78e6569ef67058faa9e353175628de44c..3fc9e680f1749329ea81d2929ebb027b2d3e33d8 100644 (file)
@@ -471,6 +471,16 @@ struct anon_vma_name {
        char name[];
 };
 
+struct vma_lock {
+       struct rw_semaphore lock;
+};
+
+struct vma_numab_state {
+       unsigned long next_scan;
+       unsigned long next_pid_reset;
+       unsigned long access_pids[2];
+};
+
 /*
  * This struct describes a virtual memory area. There is one of these
  * per VM-area/task. A VM area is any part of the process virtual memory
@@ -480,17 +490,19 @@ struct anon_vma_name {
 struct vm_area_struct {
        /* The first cache line has the info for VMA tree walking. */
 
-       unsigned long vm_start;         /* Our start address within vm_mm. */
-       unsigned long vm_end;           /* The first byte after our end address
-                                          within vm_mm. */
+       union {
+               struct {
+                       /* VMA covers [vm_start; vm_end) addresses within mm */
+                       unsigned long vm_start;
+                       unsigned long vm_end;
+               };
+#ifdef CONFIG_PER_VMA_LOCK
+               struct rcu_head vm_rcu; /* Used for deferred freeing. */
+#endif
+       };
 
        struct mm_struct *vm_mm;        /* The address space we belong to. */
-
-       /*
-        * Access permissions of this VMA.
-        * See vmf_insert_mixed_prot() for discussion.
-        */
-       pgprot_t vm_page_prot;
+       pgprot_t vm_page_prot;          /* Access permissions of this VMA. */
 
        /*
         * Flags, see mm.h.
@@ -501,6 +513,14 @@ struct vm_area_struct {
                vm_flags_t __private __vm_flags;
        };
 
+#ifdef CONFIG_PER_VMA_LOCK
+       int vm_lock_seq;
+       struct vma_lock *vm_lock;
+
+       /* Flag to indicate areas detached from the mm->mm_mt tree */
+       bool detached;
+#endif
+
        /*
         * For areas with an address space and backing store,
         * linkage into the address_space->i_mmap interval tree.
@@ -546,6 +566,9 @@ struct vm_area_struct {
 #endif
 #ifdef CONFIG_NUMA
        struct mempolicy *vm_policy;    /* NUMA policy for the VMA */
+#endif
+#ifdef CONFIG_NUMA_BALANCING
+       struct vma_numab_state *numab_state;    /* NUMA Balancing state */
 #endif
        struct vm_userfaultfd_ctx vm_userfaultfd_ctx;
 } __randomize_layout;
@@ -637,6 +660,9 @@ struct mm_struct {
                                          * init_mm.mmlist, and are protected
                                          * by mmlist_lock
                                          */
+#ifdef CONFIG_PER_VMA_LOCK
+               int mm_lock_seq;
+#endif
 
 
                unsigned long hiwater_rss; /* High-watermark of RSS usage */
@@ -1037,6 +1063,7 @@ typedef struct {
  *                      mapped after the fault.
  * @FAULT_FLAG_ORIG_PTE_VALID: whether the fault has vmf->orig_pte cached.
  *                        We should only access orig_pte if this flag set.
+ * @FAULT_FLAG_VMA_LOCK: The fault is handled under VMA lock.
  *
  * About @FAULT_FLAG_ALLOW_RETRY and @FAULT_FLAG_TRIED: we can specify
  * whether we would allow page faults to retry by specifying these two
@@ -1074,6 +1101,7 @@ enum fault_flag {
        FAULT_FLAG_INTERRUPTIBLE =      1 << 9,
        FAULT_FLAG_UNSHARE =            1 << 10,
        FAULT_FLAG_ORIG_PTE_VALID =     1 << 11,
+       FAULT_FLAG_VMA_LOCK =           1 << 12,
 };
 
 typedef unsigned int __bitwise zap_flags_t;