linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Galbraith <mikeg@wen-online.de>
To: "Stephen C. Tweedie" <sct@redhat.com>
Cc: Rik van Riel <riel@conectiva.com.br>,
	Ingo Oeser <ingo.oeser@informatik.tu-chemnitz.de>,
	<linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>
Subject: [RFC][PATCH] Re: Linux 2.4.4-ac10
Date: Sat, 19 May 2001 19:13:01 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.33.0105191743000.393-100000@mikeg.weiden.de> (raw)
In-Reply-To: <20010518235852.R8080@redhat.com>

Hi,

On Fri, 18 May 2001, Stephen C. Tweedie wrote:

> That's the main problem with static parameters.  The problem you are
> trying to solve is fundamentally dynamic in most cases (which is also
> why magic numbers tend to suck in the VM.)

Magic numbers might be sucking some performance right now ;-)

Three back to back make -j 30 runs for three different kernels.
Swap cache numbers are taken immediately after last completion.

Reference runs  (bad numbers.  cache collapse hurts.. a lot)
real    12m8.157s  11m41.192s  11m36.069s  2.4.4.virgin
user    7m57.710s   7m57.820s   7m57.150s
sys     0m37.200s   0m37.070s   0m37.020s
Swap cache: add 785029, delete 781670, find 243396/1051626

                    oddball.. infrequent, but happens
                    vvvv
real    10m30.470s  9m36.478s   9m50.512s  2.4.5-pre3.virgin
user    7m54.300s   7m53.430s   7m55.200s
sys     0m36.010s   0m36.850s   0m35.230s
Swap cache: add 1018892, delete 1007053, find 821456/1447811

real    9m9.679s    9m18.291s   8m55.981s  3.4.5-pre3.tweak
user    7m55.590s   7m57.060s   7m55.850s
sys     0m34.890s   0m34.370s   0m34.330s
Swap cache: add 656966, delete 646676, find 325186/865183

--- linux-2.4.5-pre3/mm/vmscan.c.org	Thu May 17 16:44:23 2001
+++ linux-2.4.5-pre3/mm/vmscan.c	Sat May 19 11:52:40 2001
@@ -824,39 +824,17 @@
 #define DEF_PRIORITY (6)
 static int refill_inactive(unsigned int gfp_mask, int user)
 {
-	int count, start_count, maxtry;
-
-	if (user) {
-		count = (1 << page_cluster);
-		maxtry = 6;
-	} else {
-		count = inactive_shortage();
-		maxtry = 1 << DEF_PRIORITY;
-	}
-
-	start_count = count;
-	do {
-		if (current->need_resched) {
-			__set_current_state(TASK_RUNNING);
-			schedule();
-			if (!inactive_shortage())
-				return 1;
-		}
-
-		count -= refill_inactive_scan(DEF_PRIORITY, count);
-		if (count <= 0)
-			goto done;
-
-		/* If refill_inactive_scan failed, try to page stuff out.. */
-		swap_out(DEF_PRIORITY, gfp_mask);
-
-		if (--maxtry <= 0)
-				return 0;
-
-	} while (inactive_shortage());
-
-done:
-	return (count < start_count);
+	int shortage = inactive_shortage();
+	int large = freepages.high/2;
+	int scale;
+
+	scale = shortage/large;
+	scale += free_shortage()/large;
+	if (scale > DEF_PRIORITY-1)
+		scale = DEF_PRIORITY-1;
+	if (refill_inactive_scan(DEF_PRIORITY-scale, shortage) < shortage)
+		return swap_out(DEF_PRIORITY, gfp_mask);
+	return 1;
 }

 static int do_try_to_free_pages(unsigned int gfp_mask, int user)
@@ -976,7 +954,8 @@
 		 * We go to sleep for one second, but if it's needed
 		 * we'll be woken up earlier...
 		 */
-		if (!free_shortage() || !inactive_shortage()) {
+		if (current->need_resched || !free_shortage() ||
+				!inactive_shortage()) {
 			interruptible_sleep_on_timeout(&kswapd_wait, HZ);
 		/*
 		 * If we couldn't free enough memory, we see if it was
@@ -1054,7 +1033,7 @@
 				if (!zone->size)
 					continue;

-				while (zone->free_pages < zone->pages_low) {
+				while (zone->free_pages < zone->inactive_clean_pages) {
 					struct page * page;
 					page = reclaim_page(zone);
 					if (!page)


Now, lets go back to the patch I posted which reduced context switches
under load by ~40% (of ~685000) for a moment.  Kswapd is asleep while
awaiting IO completion.  The guys who are pestering the sleeping kswapd
are going to be doing page_launder to fix the shortage they're yammering
at kswapd about.  We're nibbling away at the free shortage..  and the
inactive_dirty list.  So now, we have an inactive shortage as well as
a large free shortage when we enter refill_inactive.  (shortages became
large because kswapd is sleeping on the job)

6 * (1 << page_cluster) is larger than MAX_LAUNDER, but I don't see any
reason to sneak up on the shortage instead of correcting it all at once.
It takes too long to find out it's going to fail.  Why not just get it
over with before every scrubber in the system is sleeping on IO.. except
the ones doing swap pagebuffer allocations.  They can swapout, but they
can't help push swap, so it'll all sit there until somebody wakes up no?

If I'm interpreting the results right, taking it all on at once is saving
a lot of what looks to me to be unnecessary swap.  I can't see those
swap numbers as being anything other than unnecessary given that I see
no evidence of cache collapse as in 2.4.4 and earlier kernels, and the
job is getting done faster without them.

	-Mike

(yes, the last hunk looks out of place wrt my text.  however, it improves
throughput nicely, so I left it in.  swap reduction and time savings are
present without it.. just not quite as pretty;)


  parent reply	other threads:[~2001-05-19 17:17 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-17 16:45 Linux 2.4.4-ac10 Alan Cox
2001-05-17 17:00 ` Christoph Hellwig
2001-05-17 17:36   ` Alan Cox
2001-05-17 17:16 ` Chris Evans
2001-05-17 17:37   ` Rik van Riel
2001-05-17 17:47   ` Mike Galbraith
2001-05-17 21:03     ` Rik van Riel
2001-05-18  3:55       ` Sasi Peter
2001-05-18  4:03         ` Rik van Riel
2001-05-18  6:06       ` Mike Galbraith
2001-05-18 17:08         ` Rik van Riel
2001-05-18 17:45           ` Mike Galbraith
2001-05-18 18:19             ` Ingo Oeser
2001-05-18 18:23               ` Rik van Riel
2001-05-18 18:58                 ` Ingo Oeser
2001-05-18 20:12                   ` Rik van Riel
2001-05-18 20:24                   ` Mike Galbraith
2001-05-18 20:09                 ` Mike Galbraith
2001-05-18 22:44                   ` Rik van Riel
2001-05-18 22:58                     ` Stephen C. Tweedie
2001-05-19  2:12                       ` Rik van Riel
2001-05-19  2:32                         ` Mike Castle
2001-05-19  6:45                         ` Mike Galbraith
2001-05-19  4:40                       ` Mike Galbraith
2001-05-19 17:13                       ` Mike Galbraith [this message]
2001-05-19 21:41                         ` [RFC][PATCH] " Rik van Riel
2001-05-20  3:29                           ` Mike Galbraith
2001-05-20  6:42                             ` Rik van Riel
2001-05-20  8:08                               ` Mike Galbraith
2001-05-20  8:49                                 ` Rik van Riel
2001-05-20  9:47                                   ` Mike Galbraith
2001-05-20 10:04                                     ` Rik van Riel
2001-05-21 13:36                                       ` Stephen C. Tweedie
2001-05-20 21:54                                   ` Pavel Machek
2001-05-21 20:32                                     ` David Weinehall
2001-05-23 15:34                                       ` Rik van Riel
2001-05-25  8:39                                         ` Pavel Machek
2001-05-23 17:24                                       ` Jonathan Morton
2001-05-23 17:51                                       ` Scott Anderson
2001-05-25  8:10                                         ` David Weinehall
2001-05-25 18:39                                         ` Pavel Machek
2001-06-04 19:22                                     ` RPM Installation - Compilation errors jalaja devi
2001-05-24  8:48                                   ` [RFC][PATCH] Re: Linux 2.4.4-ac10 Mike Galbraith
2001-05-24  9:10                                     ` Rik van Riel
2001-05-24 10:32                                       ` Mike Galbraith
2001-05-24 11:03                                         ` Rik van Riel
2001-05-24 14:23                                           ` Mike Galbraith
2001-05-20 15:32                             ` Ingo Oeser
2001-05-20 17:38                               ` Mike Galbraith
2001-05-20 13:44                         ` Zlatko Calusic
2001-05-20 17:58                           ` Mike Galbraith
2001-05-20 19:32                             ` Marcelo Tosatti
2001-05-20 21:37                             ` Rik van Riel
2001-05-21  3:44                               ` Mike Galbraith
2001-05-20 21:03                         ` Marcelo Tosatti
2001-05-21  3:54                           ` Mike Galbraith
2001-05-17 17:26 ` Geert Uytterhoeven
2001-05-17 18:33 ` Udo A. Steinberg
2001-05-17 18:40   ` Matti Aarnio
2001-05-17 18:51     ` Matti Aarnio
2001-05-17 19:21   ` Alan Cox
2001-05-17 18:46 ` Ingo Oeser
2001-05-17 19:00   ` J . A . Magallon
2001-05-17 19:05     ` Jeff Garzik
2001-05-17 19:26     ` Alan Cox
2001-05-17 20:52 ` Linux 2.4.4-ac10: Oops FAVRE Gregoire
2001-05-17 21:41   ` Alan Cox
2001-05-18 11:28     ` FAVRE Gregoire
2001-05-20  0:52 [RFC][PATCH] Re: Linux 2.4.4-ac10 Dieter Nützel
     [not found] <200105200225107.SM01044@paloma16.e0k.nbg-hannover.de>
2001-05-20  3:40 ` Mike Galbraith

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.33.0105191743000.393-100000@mikeg.weiden.de \
    --to=mikeg@wen-online.de \
    --cc=ingo.oeser@informatik.tu-chemnitz.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=riel@conectiva.com.br \
    --cc=sct@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).