From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Mon, 5 Feb 2007 12:53:11 -0800 (PST) From: Christoph Lameter Message-Id: <20070205205311.4500.92736.sendpatchset@schroedinger.engr.sgi.com> In-Reply-To: <20070205205235.4500.54958.sendpatchset@schroedinger.engr.sgi.com> References: <20070205205235.4500.54958.sendpatchset@schroedinger.engr.sgi.com> Subject: [RFC 7/7] Opportunistically move mlocked pages off the LRU Sender: owner-linux-mm@kvack.org Return-Path: To: linux-mm@kvack.org Cc: akpm@osdl.org, Christoph Hellwig , Peter Zijlstra , "Martin J. Bligh" , Arjan van de Ven , Nick Piggin , Matt Mackall , Christoph Lameter , Nigel Cunningham , Rik van Riel , KAMEZAWA Hiroyuki List-ID: Opportunistically move mlocked pages off the LRU Add a new function try_to_mlock() that attempts to move a page off the LRU and marks it mlocked. This function can then be used in various code paths to move pages off the LRU immediately. Early discovery will make NR_MLOCK track the actual number of mlocked pages in the system more closely. Signed-off-by: Christoph Lameter Index: current/mm/memory.c =================================================================== --- current.orig/mm/memory.c 2007-02-05 12:00:30.000000000 -0800 +++ current/mm/memory.c 2007-02-05 12:01:52.000000000 -0800 @@ -919,6 +919,30 @@ static void add_anon_page(struct vm_area } /* + * Opportunistically move the page off the LRU + * if possible. If we do not succeed then the LRU + * scans will take the page off. + */ +void try_to_set_mlocked(struct page *page) +{ + struct zone *zone; + unsigned long flags; + + if (!PageLRU(page) || PageMlocked(page)) + return; + + zone = page_zone(page); + if (spin_trylock_irqsave(&zone->lru_lock, flags)) { + if (PageLRU(page) && !PageMlocked(page)) { + ClearPageLRU(page); + list_del(&page->lru); + SetPageMlocked(page); + __inc_zone_page_state(page, NR_MLOCK); + } + spin_unlock_irqrestore(&zone->lru_lock, flags); + } +} +/* * Do a quick page-table lookup for a single page. */ struct page *follow_page(struct vm_area_struct *vma, unsigned long address, @@ -978,6 +1002,8 @@ struct page *follow_page(struct vm_area_ set_page_dirty(page); mark_page_accessed(page); } + if (vma->vm_flags & VM_LOCKED) + try_to_set_mlocked(page); unlock: pte_unmap_unlock(ptep, ptl); out: @@ -2271,6 +2297,8 @@ retry: else { inc_mm_counter(mm, file_rss); page_add_file_rmap(new_page); + if (vma->vm_flags & VM_LOCKED) + try_to_set_mlocked(new_page); if (write_access) { dirty_page = new_page; get_page(dirty_page); -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org