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: current/mm/memory.c =================================================================== --- current.orig/mm/memory.c 2007-02-05 12:32:34.000000000 -0800 +++ current/mm/memory.c 2007-02-05 12:31:57.000000000 -0800 @@ -906,7 +906,15 @@ static void add_anon_page(struct vm_area 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); + inc_zone_page_state(page, NR_MLOCK); + } else + lru_cache_add_active(page); page_add_new_anon_rmap(page, vma, address); }