diff options
author | Lee Schermerhorn <Lee.Schermerhorn@hp.com> | 2008-10-18 23:26:43 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-20 11:50:26 -0400 |
commit | 89e004ea55abe201b29e2d6e35124101f1288ef7 (patch) | |
tree | 272a8f453106fd33d66fd7153f44696648dbe8b6 /include/linux | |
parent | ba9ddf49391645e6bb93219131a40446538a5e76 (diff) |
SHM_LOCKED pages are unevictable
Shmem segments locked into memory via shmctl(SHM_LOCKED) should not be
kept on the normal LRU, since scanning them is a waste of time and might
throw off kswapd's balancing algorithms. Place them on the unevictable
LRU list instead.
Use the AS_UNEVICTABLE flag to mark address_space of SHM_LOCKed shared
memory regions as unevictable. Then these pages will be culled off the
normal LRU lists during vmscan.
Add new wrapper function to clear the mapping's unevictable state when/if
shared memory segment is munlocked.
Add 'scan_mapping_unevictable_page()' to mm/vmscan.c to scan all pages in
the shmem segment's mapping [struct address_space] for evictability now
that they're no longer locked. If so, move them to the appropriate zone
lru list.
Changes depend on [CONFIG_]UNEVICTABLE_LRU.
[kosaki.motohiro@jp.fujitsu.com: revert shm change]
Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
Signed-off-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Kosaki Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/mm.h | 4 | ||||
-rw-r--r-- | include/linux/pagemap.h | 12 | ||||
-rw-r--r-- | include/linux/swap.h | 4 |
3 files changed, 15 insertions, 5 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index c61ba10768ea..40236290e2ae 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -700,10 +700,10 @@ static inline int page_mapped(struct page *page) | |||
700 | extern void show_free_areas(void); | 700 | extern void show_free_areas(void); |
701 | 701 | ||
702 | #ifdef CONFIG_SHMEM | 702 | #ifdef CONFIG_SHMEM |
703 | int shmem_lock(struct file *file, int lock, struct user_struct *user); | 703 | extern int shmem_lock(struct file *file, int lock, struct user_struct *user); |
704 | #else | 704 | #else |
705 | static inline int shmem_lock(struct file *file, int lock, | 705 | static inline int shmem_lock(struct file *file, int lock, |
706 | struct user_struct *user) | 706 | struct user_struct *user) |
707 | { | 707 | { |
708 | return 0; | 708 | return 0; |
709 | } | 709 | } |
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 09164d2c5c27..4b6c4d8d26b8 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h | |||
@@ -40,14 +40,20 @@ static inline void mapping_set_unevictable(struct address_space *mapping) | |||
40 | set_bit(AS_UNEVICTABLE, &mapping->flags); | 40 | set_bit(AS_UNEVICTABLE, &mapping->flags); |
41 | } | 41 | } |
42 | 42 | ||
43 | static inline void mapping_clear_unevictable(struct address_space *mapping) | ||
44 | { | ||
45 | clear_bit(AS_UNEVICTABLE, &mapping->flags); | ||
46 | } | ||
47 | |||
43 | static inline int mapping_unevictable(struct address_space *mapping) | 48 | static inline int mapping_unevictable(struct address_space *mapping) |
44 | { | 49 | { |
45 | if (mapping && (mapping->flags & AS_UNEVICTABLE)) | 50 | if (likely(mapping)) |
46 | return 1; | 51 | return test_bit(AS_UNEVICTABLE, &mapping->flags); |
47 | return 0; | 52 | return !!mapping; |
48 | } | 53 | } |
49 | #else | 54 | #else |
50 | static inline void mapping_set_unevictable(struct address_space *mapping) { } | 55 | static inline void mapping_set_unevictable(struct address_space *mapping) { } |
56 | static inline void mapping_clear_unevictable(struct address_space *mapping) { } | ||
51 | static inline int mapping_unevictable(struct address_space *mapping) | 57 | static inline int mapping_unevictable(struct address_space *mapping) |
52 | { | 58 | { |
53 | return 0; | 59 | return 0; |
diff --git a/include/linux/swap.h b/include/linux/swap.h index a2113044d20a..7edb4cbc29f9 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h | |||
@@ -232,12 +232,16 @@ static inline int zone_reclaim(struct zone *z, gfp_t mask, unsigned int order) | |||
232 | 232 | ||
233 | #ifdef CONFIG_UNEVICTABLE_LRU | 233 | #ifdef CONFIG_UNEVICTABLE_LRU |
234 | extern int page_evictable(struct page *page, struct vm_area_struct *vma); | 234 | extern int page_evictable(struct page *page, struct vm_area_struct *vma); |
235 | extern void scan_mapping_unevictable_pages(struct address_space *); | ||
235 | #else | 236 | #else |
236 | static inline int page_evictable(struct page *page, | 237 | static inline int page_evictable(struct page *page, |
237 | struct vm_area_struct *vma) | 238 | struct vm_area_struct *vma) |
238 | { | 239 | { |
239 | return 1; | 240 | return 1; |
240 | } | 241 | } |
242 | static inline void scan_mapping_unevictable_pages(struct address_space *mapping) | ||
243 | { | ||
244 | } | ||
241 | #endif | 245 | #endif |
242 | 246 | ||
243 | extern int kswapd_run(int nid); | 247 | extern int kswapd_run(int nid); |