diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2011-03-22 19:32:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-22 20:44:03 -0400 |
commit | 9e60109f125013b6c571f399a15a8b0fe1ffa4e6 (patch) | |
tree | 52d34958e82e5649b737e21e453516a3ecd365d3 | |
parent | 7bc32f6f90dae67730645da67bfd44304f810f93 (diff) |
mm: rename drop_anon_vma() to put_anon_vma()
The normal code pattern used in the kernel is: get/put.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Hugh Dickins <hughd@google.com>
Reviewed-by: Rik van Riel <riel@redhat.com>
Acked-by: Mel Gorman <mel@csn.ul.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/rmap.h | 4 | ||||
-rw-r--r-- | mm/ksm.c | 23 | ||||
-rw-r--r-- | mm/migrate.c | 4 | ||||
-rw-r--r-- | mm/rmap.c | 4 |
4 files changed, 11 insertions, 24 deletions
diff --git a/include/linux/rmap.h b/include/linux/rmap.h index e9fd04ca1e51..b9b23ddca63a 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h | |||
@@ -87,7 +87,7 @@ static inline void get_anon_vma(struct anon_vma *anon_vma) | |||
87 | atomic_inc(&anon_vma->external_refcount); | 87 | atomic_inc(&anon_vma->external_refcount); |
88 | } | 88 | } |
89 | 89 | ||
90 | void drop_anon_vma(struct anon_vma *); | 90 | void put_anon_vma(struct anon_vma *); |
91 | #else | 91 | #else |
92 | static inline void anonvma_external_refcount_init(struct anon_vma *anon_vma) | 92 | static inline void anonvma_external_refcount_init(struct anon_vma *anon_vma) |
93 | { | 93 | { |
@@ -102,7 +102,7 @@ static inline void get_anon_vma(struct anon_vma *anon_vma) | |||
102 | { | 102 | { |
103 | } | 103 | } |
104 | 104 | ||
105 | static inline void drop_anon_vma(struct anon_vma *anon_vma) | 105 | static inline void put_anon_vma(struct anon_vma *anon_vma) |
106 | { | 106 | { |
107 | } | 107 | } |
108 | #endif /* CONFIG_KSM */ | 108 | #endif /* CONFIG_KSM */ |
@@ -301,20 +301,6 @@ static inline int in_stable_tree(struct rmap_item *rmap_item) | |||
301 | return rmap_item->address & STABLE_FLAG; | 301 | return rmap_item->address & STABLE_FLAG; |
302 | } | 302 | } |
303 | 303 | ||
304 | static void hold_anon_vma(struct rmap_item *rmap_item, | ||
305 | struct anon_vma *anon_vma) | ||
306 | { | ||
307 | rmap_item->anon_vma = anon_vma; | ||
308 | get_anon_vma(anon_vma); | ||
309 | } | ||
310 | |||
311 | static void ksm_drop_anon_vma(struct rmap_item *rmap_item) | ||
312 | { | ||
313 | struct anon_vma *anon_vma = rmap_item->anon_vma; | ||
314 | |||
315 | drop_anon_vma(anon_vma); | ||
316 | } | ||
317 | |||
318 | /* | 304 | /* |
319 | * ksmd, and unmerge_and_remove_all_rmap_items(), must not touch an mm's | 305 | * ksmd, and unmerge_and_remove_all_rmap_items(), must not touch an mm's |
320 | * page tables after it has passed through ksm_exit() - which, if necessary, | 306 | * page tables after it has passed through ksm_exit() - which, if necessary, |
@@ -397,7 +383,7 @@ static void break_cow(struct rmap_item *rmap_item) | |||
397 | * It is not an accident that whenever we want to break COW | 383 | * It is not an accident that whenever we want to break COW |
398 | * to undo, we also need to drop a reference to the anon_vma. | 384 | * to undo, we also need to drop a reference to the anon_vma. |
399 | */ | 385 | */ |
400 | ksm_drop_anon_vma(rmap_item); | 386 | put_anon_vma(rmap_item->anon_vma); |
401 | 387 | ||
402 | down_read(&mm->mmap_sem); | 388 | down_read(&mm->mmap_sem); |
403 | if (ksm_test_exit(mm)) | 389 | if (ksm_test_exit(mm)) |
@@ -466,7 +452,7 @@ static void remove_node_from_stable_tree(struct stable_node *stable_node) | |||
466 | ksm_pages_sharing--; | 452 | ksm_pages_sharing--; |
467 | else | 453 | else |
468 | ksm_pages_shared--; | 454 | ksm_pages_shared--; |
469 | ksm_drop_anon_vma(rmap_item); | 455 | put_anon_vma(rmap_item->anon_vma); |
470 | rmap_item->address &= PAGE_MASK; | 456 | rmap_item->address &= PAGE_MASK; |
471 | cond_resched(); | 457 | cond_resched(); |
472 | } | 458 | } |
@@ -554,7 +540,7 @@ static void remove_rmap_item_from_tree(struct rmap_item *rmap_item) | |||
554 | else | 540 | else |
555 | ksm_pages_shared--; | 541 | ksm_pages_shared--; |
556 | 542 | ||
557 | ksm_drop_anon_vma(rmap_item); | 543 | put_anon_vma(rmap_item->anon_vma); |
558 | rmap_item->address &= PAGE_MASK; | 544 | rmap_item->address &= PAGE_MASK; |
559 | 545 | ||
560 | } else if (rmap_item->address & UNSTABLE_FLAG) { | 546 | } else if (rmap_item->address & UNSTABLE_FLAG) { |
@@ -949,7 +935,8 @@ static int try_to_merge_with_ksm_page(struct rmap_item *rmap_item, | |||
949 | goto out; | 935 | goto out; |
950 | 936 | ||
951 | /* Must get reference to anon_vma while still holding mmap_sem */ | 937 | /* Must get reference to anon_vma while still holding mmap_sem */ |
952 | hold_anon_vma(rmap_item, vma->anon_vma); | 938 | rmap_item->anon_vma = vma->anon_vma; |
939 | get_anon_vma(vma->anon_vma); | ||
953 | out: | 940 | out: |
954 | up_read(&mm->mmap_sem); | 941 | up_read(&mm->mmap_sem); |
955 | return err; | 942 | return err; |
diff --git a/mm/migrate.c b/mm/migrate.c index 8aacce3af8cd..7d2983f3783e 100644 --- a/mm/migrate.c +++ b/mm/migrate.c | |||
@@ -764,7 +764,7 @@ skip_unmap: | |||
764 | 764 | ||
765 | /* Drop an anon_vma reference if we took one */ | 765 | /* Drop an anon_vma reference if we took one */ |
766 | if (anon_vma) | 766 | if (anon_vma) |
767 | drop_anon_vma(anon_vma); | 767 | put_anon_vma(anon_vma); |
768 | 768 | ||
769 | uncharge: | 769 | uncharge: |
770 | if (!charge) | 770 | if (!charge) |
@@ -856,7 +856,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page, | |||
856 | remove_migration_ptes(hpage, hpage); | 856 | remove_migration_ptes(hpage, hpage); |
857 | 857 | ||
858 | if (anon_vma) | 858 | if (anon_vma) |
859 | drop_anon_vma(anon_vma); | 859 | put_anon_vma(anon_vma); |
860 | out: | 860 | out: |
861 | unlock_page(hpage); | 861 | unlock_page(hpage); |
862 | 862 | ||
@@ -278,7 +278,7 @@ static void anon_vma_unlink(struct anon_vma_chain *anon_vma_chain) | |||
278 | if (empty) { | 278 | if (empty) { |
279 | /* We no longer need the root anon_vma */ | 279 | /* We no longer need the root anon_vma */ |
280 | if (anon_vma->root != anon_vma) | 280 | if (anon_vma->root != anon_vma) |
281 | drop_anon_vma(anon_vma->root); | 281 | put_anon_vma(anon_vma->root); |
282 | anon_vma_free(anon_vma); | 282 | anon_vma_free(anon_vma); |
283 | } | 283 | } |
284 | } | 284 | } |
@@ -1493,7 +1493,7 @@ int try_to_munlock(struct page *page) | |||
1493 | * we know we are the last user, nobody else can get a reference and we | 1493 | * we know we are the last user, nobody else can get a reference and we |
1494 | * can do the freeing without the lock. | 1494 | * can do the freeing without the lock. |
1495 | */ | 1495 | */ |
1496 | void drop_anon_vma(struct anon_vma *anon_vma) | 1496 | void put_anon_vma(struct anon_vma *anon_vma) |
1497 | { | 1497 | { |
1498 | BUG_ON(atomic_read(&anon_vma->external_refcount) <= 0); | 1498 | BUG_ON(atomic_read(&anon_vma->external_refcount) <= 0); |
1499 | if (atomic_dec_and_lock(&anon_vma->external_refcount, &anon_vma->root->lock)) { | 1499 | if (atomic_dec_and_lock(&anon_vma->external_refcount, &anon_vma->root->lock)) { |