linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Rik van Riel <H.H.vanRiel@fys.ruu.nl>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: linux-mm <linux-mm@kvack.org>
Subject: [PATCH] kswapd fix
Date: Mon, 23 Mar 1998 22:31:44 +0100 (MET)	[thread overview]
Message-ID: <Pine.LNX.3.91.980323222552.570B-100000@mirkwood.dummy.home> (raw)

Hi Linus,

I've written the following fix for kswapd, it:
- makes sure kswapd doesn't use all of the CPU, even if swapout_interval
  is 0 (this fix is broken, but works for the moment)
- triggers kswapd when free_memory_available() fails
  (it gives a swapout frenzy, but since BUFFER_MEM has a minimum
  quota interactive use suffers far less)
- makes sure kswapd tries at least SWAP_CLUSTER_MAX times before
  quitting (even when free_memory_available() succeeds), this is
  done to avoid loads of context switches when kswapd is triggered
  for another reason

It patches cleanly against 2.1.90.
(my university's internet dialup line is _very_ flaky right
now, so I can't ftp a pre-91 if it exists :-( ).

Rik.
+-------------------------------------------+--------------------------+
| Linux: - LinuxHQ MM-patches page          | Scouting       webmaster |
|        - kswapd ask-him & complain-to guy | Vries    cubscout leader |
|     http://www.fys.ruu.nl/~riel/          | <H.H.vanRiel@fys.ruu.nl> |
+-------------------------------------------+--------------------------+

--- vmscan.c.orig	Thu Mar 19 01:45:42 1998
+++ vmscan.c	Mon Mar 23 22:12:21 1998
@@ -545,6 +545,7 @@
 	add_wait_queue(&kswapd_wait, &wait);
 	while (1) {
 		int tries;
+		int tried = 0;
 
 		current->state = TASK_INTERRUPTIBLE;
 		kswapd_awake = 0;
@@ -563,12 +564,12 @@
 		if (tries < freepages.min) {
 			tries = freepages.min;
 		}
-		if (nr_free_pages < freepages.high + freepages.low)
+		if (nr_free_pages < freepages.low)
 			tries <<= 1;
 		while (tries--) {
 			int gfp_mask;
 
-			if (free_memory_available())
+			if (free_memory_available() && ++tried > SWAP_CLUSTER_MAX)
 				break;
 			gfp_mask = __GFP_IO;
 			try_to_free_page(gfp_mask);
@@ -597,8 +598,8 @@
 
 	if (pages < freepages.low)
 		memory_low = want_wakeup = 1;
-	else if ((pages < freepages.high || BUFFER_MEM > (num_physpages * buffer_mem.max_percent / 100))
-			&& jiffies >= next_swap_jiffies)
+	else if ((pages < freepages.high || BUFFER_MEM > (num_physpages * buffer_mem.max_percent / 100) || !free_memory_available())
+			&& jiffies >= next_swap_jiffies + 5)
 		want_wakeup = 1;
 
 	if (want_wakeup) { 

             reply	other threads:[~1998-03-24  2:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-03-23 21:31 Rik van Riel [this message]
1998-03-24  7:34 ` Linus Torvalds

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.3.91.980323222552.570B-100000@mirkwood.dummy.home \
    --to=h.h.vanriel@fys.ruu.nl \
    --cc=linux-mm@kvack.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox