path: root/ipc
diff options
authorLee Schermerhorn <>2008-10-18 20:26:43 -0700
committerLinus Torvalds <>2008-10-20 08:50:26 -0700
commit89e004ea55abe201b29e2d6e35124101f1288ef7 (patch)
tree272a8f453106fd33d66fd7153f44696648dbe8b6 /ipc
parentba9ddf49391645e6bb93219131a40446538a5e76 (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. [ revert shm change] Signed-off-by: Lee Schermerhorn <> Signed-off-by: Rik van Riel <> Signed-off-by: Kosaki Motohiro <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'ipc')
1 files changed, 4 insertions, 0 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index e77ec698cf4..0add3fa5f54 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -737,6 +737,10 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf)
case SHM_LOCK:
+ struct file *uninitialized_var(shm_file);
+ lru_add_drain_all(); /* drain pagevecs to lru lists */
shp = shm_lock_check(ns, shmid);
if (IS_ERR(shp)) {
err = PTR_ERR(shp);