diff options
author | Mel Gorman <mel@csn.ul.ie> | 2010-05-24 17:32:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-25 11:06:58 -0400 |
commit | 7f60c214fd3a360461f3286c6908084f7f8b1950 (patch) | |
tree | dba48cf988a22a40796187c7274f7903a288f7f4 /include/linux/rmap.h | |
parent | 3f6c82728f4e31a97c3a1b32abccb512fed0b573 (diff) |
mm: migration: share the anon_vma ref counts between KSM and page migration
For clarity of review, KSM and page migration have separate refcounts on
the anon_vma. While clear, this is a waste of memory. This patch gets
KSM and page migration to share their toys in a spirit of harmony.
Signed-off-by: Mel Gorman <mel@csn.ul.ie>
Reviewed-by: Minchan Kim <minchan.kim@gmail.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reviewed-by: Christoph Lameter <cl@linux-foundation.org>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/rmap.h')
-rw-r--r-- | include/linux/rmap.h | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 567d43f29a10..77216742c178 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h | |||
@@ -26,11 +26,17 @@ | |||
26 | */ | 26 | */ |
27 | struct anon_vma { | 27 | struct anon_vma { |
28 | spinlock_t lock; /* Serialize access to vma list */ | 28 | spinlock_t lock; /* Serialize access to vma list */ |
29 | #ifdef CONFIG_KSM | 29 | #if defined(CONFIG_KSM) || defined(CONFIG_MIGRATION) |
30 | atomic_t ksm_refcount; | 30 | |
31 | #endif | 31 | /* |
32 | #ifdef CONFIG_MIGRATION | 32 | * The external_refcount is taken by either KSM or page migration |
33 | atomic_t migrate_refcount; | 33 | * to take a reference to an anon_vma when there is no |
34 | * guarantee that the vma of page tables will exist for | ||
35 | * the duration of the operation. A caller that takes | ||
36 | * the reference is responsible for clearing up the | ||
37 | * anon_vma if they are the last user on release | ||
38 | */ | ||
39 | atomic_t external_refcount; | ||
34 | #endif | 40 | #endif |
35 | /* | 41 | /* |
36 | * NOTE: the LSB of the head.next is set by | 42 | * NOTE: the LSB of the head.next is set by |
@@ -64,46 +70,26 @@ struct anon_vma_chain { | |||
64 | }; | 70 | }; |
65 | 71 | ||
66 | #ifdef CONFIG_MMU | 72 | #ifdef CONFIG_MMU |
67 | #ifdef CONFIG_KSM | 73 | #if defined(CONFIG_KSM) || defined(CONFIG_MIGRATION) |
68 | static inline void ksm_refcount_init(struct anon_vma *anon_vma) | 74 | static inline void anonvma_external_refcount_init(struct anon_vma *anon_vma) |
69 | { | 75 | { |
70 | atomic_set(&anon_vma->ksm_refcount, 0); | 76 | atomic_set(&anon_vma->external_refcount, 0); |
71 | } | 77 | } |
72 | 78 | ||
73 | static inline int ksm_refcount(struct anon_vma *anon_vma) | 79 | static inline int anonvma_external_refcount(struct anon_vma *anon_vma) |
74 | { | 80 | { |
75 | return atomic_read(&anon_vma->ksm_refcount); | 81 | return atomic_read(&anon_vma->external_refcount); |
76 | } | 82 | } |
77 | #else | 83 | #else |
78 | static inline void ksm_refcount_init(struct anon_vma *anon_vma) | 84 | static inline void anonvma_external_refcount_init(struct anon_vma *anon_vma) |
79 | { | 85 | { |
80 | } | 86 | } |
81 | 87 | ||
82 | static inline int ksm_refcount(struct anon_vma *anon_vma) | 88 | static inline int anonvma_external_refcount(struct anon_vma *anon_vma) |
83 | { | 89 | { |
84 | return 0; | 90 | return 0; |
85 | } | 91 | } |
86 | #endif /* CONFIG_KSM */ | 92 | #endif /* CONFIG_KSM */ |
87 | #ifdef CONFIG_MIGRATION | ||
88 | static inline void migrate_refcount_init(struct anon_vma *anon_vma) | ||
89 | { | ||
90 | atomic_set(&anon_vma->migrate_refcount, 0); | ||
91 | } | ||
92 | |||
93 | static inline int migrate_refcount(struct anon_vma *anon_vma) | ||
94 | { | ||
95 | return atomic_read(&anon_vma->migrate_refcount); | ||
96 | } | ||
97 | #else | ||
98 | static inline void migrate_refcount_init(struct anon_vma *anon_vma) | ||
99 | { | ||
100 | } | ||
101 | |||
102 | static inline int migrate_refcount(struct anon_vma *anon_vma) | ||
103 | { | ||
104 | return 0; | ||
105 | } | ||
106 | #endif /* CONFIG_MIGRATE */ | ||
107 | 93 | ||
108 | static inline struct anon_vma *page_anon_vma(struct page *page) | 94 | static inline struct anon_vma *page_anon_vma(struct page *page) |
109 | { | 95 | { |