Mark new anonymous pages mlocked if they are in a mlocked VMA. Avoid putting pages onto the LRU that are allocated in a VMA with VM_LOCKED set. NR_MLOCK will be more accurate. Signed-off-by: Christoph Lameter Index: linux-2.6.20/mm/memory.c =================================================================== --- linux-2.6.20.orig/mm/memory.c 2007-02-14 12:52:01.000000000 -0800 +++ linux-2.6.20/mm/memory.c 2007-02-14 12:52:36.000000000 -0800 @@ -906,7 +906,16 @@ unsigned long address) { inc_mm_counter(vma->vm_mm, anon_rss); - lru_cache_add_active(page); + if (vma->vm_flags & VM_LOCKED) { + /* + * Page is new and therefore not on the LRU + * so we can directly mark it as mlocked + */ + SetPageMlocked(page); + ClearPageActive(page); + inc_zone_page_state(page, NR_MLOCK); + } else + lru_cache_add_active(page); page_add_new_anon_rmap(page, vma, address); }