From: Nigel Cunningham <nigel@suspend2.net>
To: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] Vmscan.c: Account for memory already freed in seeking to free more.
Date: Tue, 12 Dec 2006 21:54:41 +1100 [thread overview]
Message-ID: <1165920881.7318.2.camel@nigel.suspend2.net> (raw)
The current versions of shrink_all_zones and shrink_all_memory don't
take account of memory already freed when making multiple calls to seek
to free memory. As a result, we can end up freeing far more memory than
was asked for. This can in turn result in more (unnecessary) paging
if/when the data is later needed.
These modifications seek to alleviate this situation by modifying
swap_cluster_max by the number of pages freed by shrink_inactive_list in
shrink_all_zones before proceeding to the next zone, and in
shrink_all_memory before shrinking slab and going to the next priority.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
diff -ruNp 930-vmscan.patch-old/mm/vmscan.c 930-vmscan.patch-new/mm/vmscan.c
@@ -1469,9 +1469,12 @@ static unsigned long shrink_all_zones(un
zone->nr_scan_inactive += (zone->nr_inactive >> prio) + 1;
if (zone->nr_scan_inactive >= nr_pages || pass > 3) {
+ int freed;
zone->nr_scan_inactive = 0;
nr_to_scan = min(nr_pages, zone->nr_inactive);
- ret += shrink_inactive_list(nr_to_scan, zone, sc);
+ freed = shrink_inactive_list(nr_to_scan, zone, sc);
+ ret += freed;
+ sc->swap_cluster_max -= freed;
if (ret >= nr_pages)
return ret;
}
@@ -1550,9 +1553,14 @@ unsigned long shrink_all_memory(unsigned
for (prio = DEF_PRIORITY; prio >= 0; prio--) {
unsigned long nr_to_scan = nr_pages - ret;
+ int freed;
sc.nr_scanned = 0;
- ret += shrink_all_zones(nr_to_scan, prio, pass, &sc);
+ sc.swap_cluster_max = nr_pages - ret;
+ freed = shrink_all_zones(nr_to_scan, prio, pass, &sc);
+ ret += freed;
+ lru_pages =- freed;
+ nr_to_scan = nr_pages - ret;
if (ret >= nr_pages)
goto out;
reply other threads:[~2006-12-12 10:54 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=1165920881.7318.2.camel@nigel.suspend2.net \
--to=nigel@suspend2.net \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®