linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kswapd fix
@ 1998-03-23 21:31 Rik van Riel
  1998-03-24  7:34 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: Rik van Riel @ 1998-03-23 21:31 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-mm

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) { 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-03-24  7:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-03-23 21:31 [PATCH] kswapd fix Rik van Riel
1998-03-24  7:34 ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox