ksm: make rmap walks more scalable
authorHugh Dickins <hughd@google.com>
Thu, 20 Dec 2012 01:44:29 +0000 (17:44 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 20 Dec 2012 15:06:56 +0000 (07:06 -0800)
The rmap walks in ksm.c are like those in rmap.c: they can safely be
done with anon_vma_lock_read().

Signed-off-by: Hugh Dickins <hughd@google.com>
Acked-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/ksm.c

index 82dfb4b5432100799c58750823b374a30b6dbf8e..51573858938d1435a5b74c2c36dbd833b5c27837 100644 (file)
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -1624,7 +1624,7 @@ again:
                struct anon_vma_chain *vmac;
                struct vm_area_struct *vma;
 
-               anon_vma_lock_write(anon_vma);
+               anon_vma_lock_read(anon_vma);
                anon_vma_interval_tree_foreach(vmac, &anon_vma->rb_root,
                                               0, ULONG_MAX) {
                        vma = vmac->vma;
@@ -1648,7 +1648,7 @@ again:
                        if (!search_new_forks || !mapcount)
                                break;
                }
-               anon_vma_unlock(anon_vma);
+               anon_vma_unlock_read(anon_vma);
                if (!mapcount)
                        goto out;
        }
@@ -1678,7 +1678,7 @@ again:
                struct anon_vma_chain *vmac;
                struct vm_area_struct *vma;
 
-               anon_vma_lock_write(anon_vma);
+               anon_vma_lock_read(anon_vma);
                anon_vma_interval_tree_foreach(vmac, &anon_vma->rb_root,
                                               0, ULONG_MAX) {
                        vma = vmac->vma;
@@ -1697,11 +1697,11 @@ again:
                        ret = try_to_unmap_one(page, vma,
                                        rmap_item->address, flags);
                        if (ret != SWAP_AGAIN || !page_mapped(page)) {
-                               anon_vma_unlock(anon_vma);
+                               anon_vma_unlock_read(anon_vma);
                                goto out;
                        }
                }
-               anon_vma_unlock(anon_vma);
+               anon_vma_unlock_read(anon_vma);
        }
        if (!search_new_forks++)
                goto again;
@@ -1731,7 +1731,7 @@ again:
                struct anon_vma_chain *vmac;
                struct vm_area_struct *vma;
 
-               anon_vma_lock_write(anon_vma);
+               anon_vma_lock_read(anon_vma);
                anon_vma_interval_tree_foreach(vmac, &anon_vma->rb_root,
                                               0, ULONG_MAX) {
                        vma = vmac->vma;
@@ -1749,11 +1749,11 @@ again:
 
                        ret = rmap_one(page, vma, rmap_item->address, arg);
                        if (ret != SWAP_AGAIN) {
-                               anon_vma_unlock(anon_vma);
+                               anon_vma_unlock_read(anon_vma);
                                goto out;
                        }
                }
-               anon_vma_unlock(anon_vma);
+               anon_vma_unlock_read(anon_vma);
        }
        if (!search_new_forks++)
                goto again;