提交 a92f7126 编写于 作者: C Christoph Lameter 提交者: Linus Torvalds

[PATCH] zone_reclaim: partial scans instead of full scan

Instead of scanning all the pages in a zone, imitate real swap and scan
only a portion of the pages and gradually scan more if we do not free up
enough pages.  This avoids a zone suddenly loosing all unused pagecache
pages (we may after all access some of these again so they deserve another
chance) but it still frees up large chunks of memory if a zone only
contains unused pagecache pages.
Signed-off-by: NChristoph Lameter <clameter@sgi.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 aa3f18b3
...@@ -1596,6 +1596,14 @@ int zone_reclaim_mode __read_mostly; ...@@ -1596,6 +1596,14 @@ int zone_reclaim_mode __read_mostly;
* Mininum time between zone reclaim scans * Mininum time between zone reclaim scans
*/ */
#define ZONE_RECLAIM_INTERVAL 30*HZ #define ZONE_RECLAIM_INTERVAL 30*HZ
/*
* Priority for ZONE_RECLAIM. This determines the fraction of pages
* of a node considered for each zone_reclaim. 4 scans 1/16th of
* a zone.
*/
#define ZONE_RECLAIM_PRIORITY 4
/* /*
* Try to free up some pages from this zone through reclaim. * Try to free up some pages from this zone through reclaim.
*/ */
...@@ -1626,7 +1634,7 @@ int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) ...@@ -1626,7 +1634,7 @@ int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
sc.may_swap = 0; sc.may_swap = 0;
sc.nr_scanned = 0; sc.nr_scanned = 0;
sc.nr_reclaimed = 0; sc.nr_reclaimed = 0;
sc.priority = 0; sc.priority = ZONE_RECLAIM_PRIORITY + 1;
sc.nr_mapped = read_page_state(nr_mapped); sc.nr_mapped = read_page_state(nr_mapped);
sc.gfp_mask = gfp_mask; sc.gfp_mask = gfp_mask;
...@@ -1643,8 +1651,16 @@ int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) ...@@ -1643,8 +1651,16 @@ int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
reclaim_state.reclaimed_slab = 0; reclaim_state.reclaimed_slab = 0;
p->reclaim_state = &reclaim_state; p->reclaim_state = &reclaim_state;
/*
* Free memory by calling shrink zone with increasing priorities
* until we have enough memory freed.
*/
do {
sc.priority--;
shrink_zone(zone, &sc); shrink_zone(zone, &sc);
} while (sc.nr_reclaimed < nr_pages && sc.priority > 0);
p->reclaim_state = NULL; p->reclaim_state = NULL;
current->flags &= ~PF_MEMALLOC; current->flags &= ~PF_MEMALLOC;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册