3/5 VM changes: dont-rotate-active-list.patch
Subsystems (5)
PATCH 1/1 3/5 VM changes: dont-rotate-active-list.patch
Currently, if zone is short on free pages, refill_inactive_zone() starts moving pages from active_list to inactive_list, rotating active_list as it goes. That is, pages from the tail of active_list are transferred to its head, thus destroying lru ordering, exactly when we need it most --- when system is low on free memory and page replacement has to be performed.
This patch modifies refill_inactive_zone() so that it scans active_list without rotating it. To achieve this, special dummy page zone->scan_page is maintained for each zone. This page marks a place in the active_list reached during scanning.
As an additional bonus, if memory pressure is not so big as to start swapping mapped pages (reclaim_mapped == 0 in refill_inactive_zone()), then not referenced mapped pages can be left behind zone->scan_page instead of moving them to the head of active_list. When reclaim_mapped mode is activated, zone->scan_page is reset back to the tail of active_list so that these pages can be re-scanned.
include/linux/mmzone.h renamed from include/linux/mmzone.h~dont-rotate-active-list +6 -0
@@ -146,6 +146,12 @@ struct zone {/* zone_start_pfn == zone_start_paddr >> PAGE_SHIFT */ unsigned long zone_start_pfn; +/* +* dummy page used as place holder during scanning of +* active_list in refill_inactive_zone() +*/ +struct page *scan_page; +/* * rarely used fields: */
mm/page_alloc.c renamed from mm/page_alloc.c~dont-rotate-active-list +20 -0
@@ -1201,6 +1201,9 @@ void __init memmap_init_zone(struct page memmap_init_zone((start), (size), (nid), (zone), (start_pfn))#endif +/* dummy pages used to scan active lists */ +static struct page scan_pages[MAX_NR_NODES ][MAX_NR_ZONES ]; +/* * Set up the zone data structures: * - mark all pages reserved
@@ -1223,6 +1226,7 @@ static void __init free_area_init_core(sstruct zone *zone = pgdat->node_zones + j;unsigned long size, realsize;unsigned long batch; +struct page *scan_page; zone_table[nid *MAX_NR_ZONES + j] = zone; realsize = size = zones_size[j];
@@ -1275,6 +1279,22 @@ static void __init free_area_init_core(satomic_set (&zone->refill_counter,0 ); zone->nr_active =0 ; zone->nr_inactive =0 ; + +/* initialize dummy page used for scanning */ + scan_page = &scan_pages[nid][j]; + zone->scan_page = scan_page; +memset (scan_page,0 ,sizeof *scan_page); + scan_page->flags = + (1 << PG_locked) | + (1 << PG_error) | + (1 << PG_lru) | + (1 << PG_active) | + (1 << PG_reserved); +set_page_zone (scan_page, j); +page_cache_get (scan_page); +INIT_LIST_HEAD (&scan_page->list); +list_add (&scan_page->lru, &zone->active_list); +if (!size)continue ;
mm/vmscan.c renamed from mm/vmscan.c~dont-rotate-active-list +93 -52
227 lines not on this page · raw message
_
Quoted 3 lines · Nikita Danilov
This patch modifies
refill_inactive_zone()so that it scansactive_list
without rotating it.
I'm unconvinced. The scanning of the active list allows us to keep the referenced state uptodate and balanced across all pages.
Quoted 8 lines · Andrew Morton
Quoted 3 lines · Nikita Danilov
This patch modifies
refill_inactive_zone()so that it scansactive_list
without rotating it.I'm unconvinced. The scanning of the active list allows us to keep the referenced state uptodate and balanced across all pages.
With this patch active list is still scanned. The only difference is that in !reclaim_mapped mode, mapped but unreferenced pages are left behind scanning point instead of being thrown to the head of active list (which supposed to be LRU, after all).
Nikita.