]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - include/linux/rmap.h
mm/rmap: Convert the struct anon_vma::mutex to an rwsem
[karo-tx-linux.git] / include / linux / rmap.h
index bfe1f4780644434cd8901abae42939d661e70a8e..f3f41d242e25a0e5bed4dc7c8a02c2316d5d1c4e 100644 (file)
@@ -7,7 +7,7 @@
 #include <linux/list.h>
 #include <linux/slab.h>
 #include <linux/mm.h>
-#include <linux/mutex.h>
+#include <linux/rwsem.h>
 #include <linux/memcontrol.h>
 
 /*
@@ -25,8 +25,8 @@
  * pointing to this anon_vma once its vma list is empty.
  */
 struct anon_vma {
-       struct anon_vma *root;  /* Root of this anon_vma tree */
-       struct mutex mutex;     /* Serialize access to vma list */
+       struct anon_vma *root;          /* Root of this anon_vma tree */
+       struct rw_semaphore rwsem;      /* W: modification, R: walking the list */
        /*
         * The refcount is taken on an anon_vma when there is no
         * guarantee that the vma of page tables will exist for
@@ -64,7 +64,7 @@ struct anon_vma_chain {
        struct vm_area_struct *vma;
        struct anon_vma *anon_vma;
        struct list_head same_vma;   /* locked by mmap_sem & page_table_lock */
-       struct rb_node rb;                      /* locked by anon_vma->mutex */
+       struct rb_node rb;                      /* locked by anon_vma->rwsem */
        unsigned long rb_subtree_last;
 #ifdef CONFIG_DEBUG_VM_RB
        unsigned long cached_vma_start, cached_vma_last;
@@ -108,24 +108,24 @@ static inline void vma_lock_anon_vma(struct vm_area_struct *vma)
 {
        struct anon_vma *anon_vma = vma->anon_vma;
        if (anon_vma)
-               mutex_lock(&anon_vma->root->mutex);
+               down_write(&anon_vma->root->rwsem);
 }
 
 static inline void vma_unlock_anon_vma(struct vm_area_struct *vma)
 {
        struct anon_vma *anon_vma = vma->anon_vma;
        if (anon_vma)
-               mutex_unlock(&anon_vma->root->mutex);
+               up_write(&anon_vma->root->rwsem);
 }
 
 static inline void anon_vma_lock(struct anon_vma *anon_vma)
 {
-       mutex_lock(&anon_vma->root->mutex);
+       down_write(&anon_vma->root->rwsem);
 }
 
 static inline void anon_vma_unlock(struct anon_vma *anon_vma)
 {
-       mutex_unlock(&anon_vma->root->mutex);
+       up_write(&anon_vma->root->rwsem);
 }
 
 /*