diff options
author | Hugh Dickins <hugh.dickins@tiscali.co.uk> | 2009-12-14 20:59:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-15 11:53:20 -0500 |
commit | e9995ef978a7d5296fe04a9a2c5ca6e66d8bb4e5 (patch) | |
tree | df4324273856e06b8277b7e4a0fa9289eb8e6385 /include/linux/ksm.h | |
parent | 407f9c8b0889ced1dbe2f9157e4e60c61329d5c9 (diff) |
ksm: rmap_walk to remove_migation_ptes
A side-effect of making ksm pages swappable is that they have to be placed
on the LRUs: which then exposes them to isolate_lru_page() and hence to
page migration.
Add rmap_walk() for remove_migration_ptes() to use: rmap_walk_anon() and
rmap_walk_file() in rmap.c, but rmap_walk_ksm() in ksm.c. Perhaps some
consolidation with existing code is possible, but don't attempt that yet
(try_to_unmap needs to handle nonlinears, but migration pte removal does
not).
rmap_walk() is sadly less general than it appears: rmap_walk_anon(), like
remove_anon_migration_ptes() which it replaces, avoids calling
page_lock_anon_vma(), because that includes a page_mapped() test which
fails when all migration ptes are in place. That was valid when NUMA page
migration was introduced (holding mmap_sem provided the missing guarantee
that anon_vma's slab had not already been destroyed), but I believe not
valid in the memory hotremove case added since.
For now do the same as before, and consider the best way to fix that
unlikely race later on. When fixed, we can probably use rmap_walk() on
hwpoisoned ksm pages too: for now, they remain among hwpoison's various
exceptions (its PageKsm test comes before the page is locked, but its
page_lock_anon_vma fails safely if an anon gets upgraded).
Signed-off-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: Izik Eidus <ieidus@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Chris Wright <chrisw@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/ksm.h')
-rw-r--r-- | include/linux/ksm.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/ksm.h b/include/linux/ksm.h index 157d83dbaef8..bed5f16ba827 100644 --- a/include/linux/ksm.h +++ b/include/linux/ksm.h | |||
@@ -88,6 +88,9 @@ static inline struct page *ksm_might_need_to_copy(struct page *page, | |||
88 | int page_referenced_ksm(struct page *page, | 88 | int page_referenced_ksm(struct page *page, |
89 | struct mem_cgroup *memcg, unsigned long *vm_flags); | 89 | struct mem_cgroup *memcg, unsigned long *vm_flags); |
90 | int try_to_unmap_ksm(struct page *page, enum ttu_flags flags); | 90 | int try_to_unmap_ksm(struct page *page, enum ttu_flags flags); |
91 | int rmap_walk_ksm(struct page *page, int (*rmap_one)(struct page *, | ||
92 | struct vm_area_struct *, unsigned long, void *), void *arg); | ||
93 | void ksm_migrate_page(struct page *newpage, struct page *oldpage); | ||
91 | 94 | ||
92 | #else /* !CONFIG_KSM */ | 95 | #else /* !CONFIG_KSM */ |
93 | 96 | ||
@@ -127,6 +130,16 @@ static inline int try_to_unmap_ksm(struct page *page, enum ttu_flags flags) | |||
127 | { | 130 | { |
128 | return 0; | 131 | return 0; |
129 | } | 132 | } |
133 | |||
134 | static inline int rmap_walk_ksm(struct page *page, int (*rmap_one)(struct page*, | ||
135 | struct vm_area_struct *, unsigned long, void *), void *arg) | ||
136 | { | ||
137 | return 0; | ||
138 | } | ||
139 | |||
140 | static inline void ksm_migrate_page(struct page *newpage, struct page *oldpage) | ||
141 | { | ||
142 | } | ||
130 | #endif /* !CONFIG_KSM */ | 143 | #endif /* !CONFIG_KSM */ |
131 | 144 | ||
132 | #endif /* __LINUX_KSM_H */ | 145 | #endif /* __LINUX_KSM_H */ |