From: Christoph Lameter <clameter@engr.sgi.com>
To: akpm@osdl.org
Cc: linux-mm@vger.kernel.org
Subject: [PATCH] zone_reclaim: partial scans instead of full scan.
Date: Wed, 25 Jan 2006 10:18:40 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.4.62.0601251016380.9732@schroedinger.engr.sgi.com> (raw)
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: Christoph Lameter <clameter@sgi.com>
Index: linux-2.6.16-rc1-mm3/mm/vmscan.c
===================================================================
--- linux-2.6.16-rc1-mm3.orig/mm/vmscan.c 2006-01-25 10:02:09.000000000 -0800
+++ linux-2.6.16-rc1-mm3/mm/vmscan.c 2006-01-25 10:05:05.000000000 -0800
@@ -1835,6 +1835,14 @@ int zone_reclaim_mode __read_mostly;
* Mininum time between zone reclaim scans
*/
#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.
*/
@@ -1865,7 +1873,7 @@ int zone_reclaim(struct zone *zone, gfp_
sc.may_swap = 0;
sc.nr_scanned = 0;
sc.nr_reclaimed = 0;
- sc.priority = 0;
+ sc.priority = ZONE_RECLAIM_PRIORITY + 1;
sc.nr_mapped = read_page_state(nr_mapped);
sc.gfp_mask = gfp_mask;
@@ -1882,7 +1890,15 @@ int zone_reclaim(struct zone *zone, gfp_
reclaim_state.reclaimed_slab = 0;
p->reclaim_state = &reclaim_state;
- shrink_zone(zone, &sc);
+ /*
+ * Free memory by calling shrink zone with increasing priorities
+ * until we have enough memory freed.
+ */
+ do {
+ sc.priority--;
+ shrink_zone(zone, &sc);
+
+ } while (sc.nr_reclaimed < nr_pages && sc.priority > 0);
p->reclaim_state = NULL;
current->flags &= ~PF_MEMALLOC;
--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
reply other threads:[~2006-01-25 18:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.62.0601251016380.9732@schroedinger.engr.sgi.com \
--to=clameter@engr.sgi.com \
--cc=akpm@osdl.org \
--cc=linux-mm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox