aboutsummaryrefslogtreecommitdiffstats
path: root/mm/vmscan.c
diff options
context:
space:
mode:
authorNick Piggin <npiggin@suse.de>2008-10-18 23:26:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-20 11:50:25 -0400
commit62695a84eb8f2e718bf4dfb21700afaa7a08e0ea (patch)
tree0af7bac599748a7e462bff16d70c702c9e33a2fb /mm/vmscan.c
parent71088785c6bc68fddb450063d57b1bd1c78e0ea1 (diff)
vmscan: move isolate_lru_page() to vmscan.c
On large memory systems, the VM can spend way too much time scanning through pages that it cannot (or should not) evict from memory. Not only does it use up CPU time, but it also provokes lock contention and can leave large systems under memory presure in a catatonic state. This patch series improves VM scalability by: 1) putting filesystem backed, swap backed and unevictable pages onto their own LRUs, so the system only scans the pages that it can/should evict from memory 2) switching to two handed clock replacement for the anonymous LRUs, so the number of pages that need to be scanned when the system starts swapping is bound to a reasonable number 3) keeping unevictable pages off the LRU completely, so the VM does not waste CPU time scanning them. ramfs, ramdisk, SHM_LOCKED shared memory segments and mlock()ed VMA pages are keept on the unevictable list. This patch: isolate_lru_page logically belongs to be in vmscan.c than migrate.c. It is tough, because we don't need that function without memory migration so there is a valid argument to have it in migrate.c. However a subsequent patch needs to make use of it in the core mm, so we can happily move it to vmscan.c. Also, make the function a little more generic by not requiring that it adds an isolated page to a given list. Callers can do that. Note that we now have '__isolate_lru_page()', that does something quite different, visible outside of vmscan.c for use with memory controller. Methinks we need to rationalize these names/purposes. --lts [akpm@linux-foundation.org: fix mm/memory_hotplug.c build] Signed-off-by: Nick Piggin <npiggin@suse.de> Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: Lee Schermerhorn <Lee.Schermerhorn@hp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/vmscan.c')
-rw-r--r--mm/vmscan.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 1ff1a58e7c10..1fd4912a596c 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -844,6 +844,51 @@ static unsigned long clear_active_flags(struct list_head *page_list)
844 return nr_active; 844 return nr_active;
845} 845}
846 846
847/**
848 * isolate_lru_page - tries to isolate a page from its LRU list
849 * @page: page to isolate from its LRU list
850 *
851 * Isolates a @page from an LRU list, clears PageLRU and adjusts the
852 * vmstat statistic corresponding to whatever LRU list the page was on.
853 *
854 * Returns 0 if the page was removed from an LRU list.
855 * Returns -EBUSY if the page was not on an LRU list.
856 *
857 * The returned page will have PageLRU() cleared. If it was found on
858 * the active list, it will have PageActive set. That flag may need
859 * to be cleared by the caller before letting the page go.
860 *
861 * The vmstat statistic corresponding to the list on which the page was
862 * found will be decremented.
863 *
864 * Restrictions:
865 * (1) Must be called with an elevated refcount on the page. This is a
866 * fundamentnal difference from isolate_lru_pages (which is called
867 * without a stable reference).
868 * (2) the lru_lock must not be held.
869 * (3) interrupts must be enabled.
870 */
871int isolate_lru_page(struct page *page)
872{
873 int ret = -EBUSY;
874
875 if (PageLRU(page)) {
876 struct zone *zone = page_zone(page);
877
878 spin_lock_irq(&zone->lru_lock);
879 if (PageLRU(page) && get_page_unless_zero(page)) {
880 ret = 0;
881 ClearPageLRU(page);
882 if (PageActive(page))
883 del_page_from_active_list(zone, page);
884 else
885 del_page_from_inactive_list(zone, page);
886 }
887 spin_unlock_irq(&zone->lru_lock);
888 }
889 return ret;
890}
891
847/* 892/*
848 * shrink_inactive_list() is a helper for shrink_zone(). It returns the number 893 * shrink_inactive_list() is a helper for shrink_zone(). It returns the number
849 * of reclaimed pages 894 * of reclaimed pages