From: Roger Larsson <roger.larsson@norran.net> (by way of Roger Larsson <roger.larsson@norran.net>)
To: <linux-kernel@vger.kernel.org>
Cc: alan@redhat.com, torvalds@transmeta.com
Subject: [PATCH NG] alloc_pages_limit & pages_min
Date: Thu, 23 Aug 2001 20:12:49 +0200 [thread overview]
Message-ID: <200108231817.f7NIHCj11077@mailc.telia.com> (raw)
Hi,
[Same patch as earlier sent to linux-mm, now tested]
Patch is agains 2.4.8-pre3, but should apply cleanly.
The only performance difference I have noticed is for copying
a huge file, then it performs a lot better (but I do not have a
baseline run for an unpatched -pre3, but I have benchmarked
both earlier and later revisions)
* The original code in __alloc_pages_limit has a little bug in
the case when:
- kreclaimd were not allowed to run for a LONG time...
Lots of kernel activity, RT tasks, or code running
around for a long time allocating memory.
- there were lots of inactive clean pages
- pages were allocated without direct_reclaim (higher order)
(networking might be one candidate)
it could result in using up ALL free pages!
This patch tries to prevent this situation in several ways:
1) Do not allow to alloc a free page when they are critically low.
[last line of patch, the really critical part of this patch]
2) If direct reclaims are allowed do some additional work.
reclaim & free until pages_min,
alloc one page,
reclaim and free until pages_low
/RogerL
--
Roger Larsson
Skellefteå
Sweden
*******************************************
Patch prepared by: roger.larsson@norran.net with comments from Riel
--- linux/mm/page_alloc.c.orig Wed Aug 22 13:36:57 2001
+++ linux/mm/page_alloc.c Thu Aug 23 01:15:17 2001
@@ -253,11 +253,35 @@
if (z->free_pages + z->inactive_clean_pages >= water_mark) {
struct page *page = NULL;
- /* If possible, reclaim a page directly. */
- if (direct_reclaim)
+
+ /*
+ * Reclaim a page from the inactive_clean list.
+ * If needed, refill the free list up to the
+ * low water mark.
+ */
+ if (direct_reclaim) {
page = reclaim_page(z);
- /* If that fails, fall back to rmqueue. */
- if (!page)
+
+ while (page && z->free_pages < z->pages_min) {
+ __free_page(page);
+ page = reclaim_page(z);
+ }
+
+ if (page) {
+ while (z->free_pages < z->pages_low) {
+ struct page *extra = reclaim_page(z);
+ if (!extra)
+ break;
+ __free_page(extra);
+ }
+ }
+
+ /* let kreclaimd handle up to pages_high */
+ }
+ /* If that fails, fall back to rmqueue, but never let
+ * free_pages go below pages_min...
+ */
+ if (!page && z->free_pages >= z->pages_min)
page = rmqueue(z, order);
if (page)
return page;
next reply other threads:[~2001-08-23 18:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-23 18:12 Roger Larsson [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-08-22 23:46 [PATCH NG] alloc_pages_limit & pages_min Roger Larsson
2001-08-23 0:40 ` Rik van Riel
2001-08-23 18:36 ` Roger Larsson
2001-08-23 18:44 ` Rik van Riel
2001-08-23 18:52 ` Roger Larsson
2001-08-23 19:03 ` Rik van Riel
2001-08-23 18:45 ` Roger Larsson
2001-08-23 18:55 ` Rik van Riel
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=200108231817.f7NIHCj11077@mailc.telia.com \
--to=roger.larsson@norran.net \
--cc=alan@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.