linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Reap dead swap cache earlier v2
@ 2001-06-06 20:07 Marcelo Tosatti
  2001-06-07 14:47 ` John Stoffel
  2001-06-07 19:07 ` Jonathan Morton
  0 siblings, 2 replies; 6+ messages in thread
From: Marcelo Tosatti @ 2001-06-06 20:07 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: lkml, linux-mm


Hi, 

As suggested by Linus, I've cleaned the reapswap code to be contained
inside an inline function. (yes, the if statement is really ugly) 

Tested and against 2.4.6pre1. 



--- linux.orig/mm/vmscan.c	Wed Jun  6 18:16:45 2001
+++ linux/mm/vmscan.c	Wed Jun  6 18:28:26 2001
@@ -407,6 +407,27 @@
 	memory_pressure++;
 	return page;
 }
+/*
+ * Check for dead swap cache pages and clean them, forcing 
+ * those pages to be freed earlier.
+ */
+static inline int clean_dead_swap_page (struct page* page)
+{
+	int ret = 0;
+	if (!TryLockPage (page)) { 
+		if (PageSwapCache(page) && PageDirty(page) &&
+				(page_count(page) - !!page->buffers) == 1 &&
+				swap_count(page) == 1) { 
+			ClearPageDirty(page);
+			ClearPageReferenced(page);
+			page->age = 0;
+			ret = 1;
+		}
+		UnlockPage(page);
+	}
+	return ret;
+}
+
 
 /**
  * page_launder - clean dirty inactive pages, move to inactive_clean list
@@ -456,6 +477,12 @@
 			continue;
 		}
 
+		/*
+		 * Check for dead swap cache pages 
+		 * before doing any other checks.
+		 */
+		clean_dead_swap_page(page);
+			
 		/* Page is or was in use?  Move it to the active list. */
 		if (PageReferenced(page) || page->age > 0 ||
 				page->zone->free_pages > page->zone->pages_high ||
@@ -666,6 +693,15 @@
 			printk("VM: refill_inactive, wrong page on list.\n");
 			list_del(page_lru);
 			nr_active_pages--;
+			continue;
+		}
+		
+		/*
+		 * Special case for dead swap cache pages.
+		 */
+		if (clean_dead_swap_page(page)) {
+			deactivate_page_nolock(page);
+			nr_deactivated++;
 			continue;
 		}
 


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

* Re: [PATCH] Reap dead swap cache earlier v2
  2001-06-06 20:07 [PATCH] Reap dead swap cache earlier v2 Marcelo Tosatti
@ 2001-06-07 14:47 ` John Stoffel
  2001-06-07 15:44   ` Hugh Dickins
  2001-06-07 19:07 ` Jonathan Morton
  1 sibling, 1 reply; 6+ messages in thread
From: John Stoffel @ 2001-06-07 14:47 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Linus Torvalds, lkml, linux-mm


Marcelo> As suggested by Linus, I've cleaned the reapswap code to be
Marcelo> contained inside an inline function. (yes, the if statement
Marcelo> is really ugly)

Shouldn't the "swap_count(page) == 1" check be earlier in the if
statement, so we can fall through more quickly if there is no work to
be done?  A small optimization, but putting the common cases first
will help.

Marcelo> +static inline int clean_dead_swap_page (struct page* page)
Marcelo> +{
Marcelo> +	int ret = 0;
Marcelo> +	if (!TryLockPage (page)) { 
Marcelo> +		if (PageSwapCache(page) && PageDirty(page) &&
Marcelo> +				(page_count(page) - !!page->buffers) == 1 &&
Marcelo> +				swap_count(page) == 1) { 
Marcelo> +			ClearPageDirty(page);
Marcelo> +			ClearPageReferenced(page);
Marcelo> +			page->age = 0;
Marcelo> +			ret = 1;
Marcelo> +		}


Thanks,
John
   John Stoffel - Senior Unix Systems Administrator - Lucent Technologies
	 stoffel@lucent.com - http://www.lucent.com - 978-952-7548

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

* Re: [PATCH] Reap dead swap cache earlier v2
  2001-06-07 14:47 ` John Stoffel
@ 2001-06-07 15:44   ` Hugh Dickins
  0 siblings, 0 replies; 6+ messages in thread
From: Hugh Dickins @ 2001-06-07 15:44 UTC (permalink / raw)
  To: John Stoffel; +Cc: Marcelo Tosatti, Linus Torvalds, lkml, linux-mm

On Thu, 7 Jun 2001, John Stoffel wrote:
> Shouldn't the "swap_count(page) == 1" check be earlier in the if
> statement, so we can fall through more quickly if there is no work to
> be done?  A small optimization, but putting the common cases first
> will help.

I don't think so: the out-of-line swap_count() function is considerably
more complicated than the macros and inline functions tested before it.

Hugh


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

* Re: [PATCH] Reap dead swap cache earlier v2
  2001-06-07 19:07 ` Jonathan Morton
@ 2001-06-07 17:38   ` Marcelo Tosatti
  2001-06-07 19:31   ` Jonathan Morton
  1 sibling, 0 replies; 6+ messages in thread
From: Marcelo Tosatti @ 2001-06-07 17:38 UTC (permalink / raw)
  To: Jonathan Morton; +Cc: lkml, linux-mm



On Thu, 7 Jun 2001, Jonathan Morton wrote:

> >As suggested by Linus, I've cleaned the reapswap code to be contained
> >inside an inline function. (yes, the if statement is really ugly)
> 
> I can't seem to find the patch which adds this behaviour to the background
> scanning.  

I've just sent Linus a patch to free swap cache pages at the time we free
the last pte. (requested by himself)

With it applied we should get the old behaviour back again. 

I can put it on my webpage if you wish. 


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

* Re: [PATCH] Reap dead swap cache earlier v2
  2001-06-06 20:07 [PATCH] Reap dead swap cache earlier v2 Marcelo Tosatti
  2001-06-07 14:47 ` John Stoffel
@ 2001-06-07 19:07 ` Jonathan Morton
  2001-06-07 17:38   ` Marcelo Tosatti
  2001-06-07 19:31   ` Jonathan Morton
  1 sibling, 2 replies; 6+ messages in thread
From: Jonathan Morton @ 2001-06-07 19:07 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: lkml, linux-mm

>As suggested by Linus, I've cleaned the reapswap code to be contained
>inside an inline function. (yes, the if statement is really ugly)

I can't seem to find the patch which adds this behaviour to the background
scanning.  Can someone point me to it?

--------------------------------------------------------------
from:     Jonathan "Chromatix" Morton
mail:     chromi@cyberspace.org  (not for attachments)

The key to knowledge is not to rely on people to teach you it.

GCS$/E/S dpu(!) s:- a20 C+++ UL++ P L+++ E W+ N- o? K? w--- O-- M++$ V? PS
PE- Y+ PGP++ t- 5- X- R !tv b++ DI+++ D G e+ h+ r++ y+(*)



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

* Re: [PATCH] Reap dead swap cache earlier v2
  2001-06-07 19:07 ` Jonathan Morton
  2001-06-07 17:38   ` Marcelo Tosatti
@ 2001-06-07 19:31   ` Jonathan Morton
  1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Morton @ 2001-06-07 19:31 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: lkml, linux-mm

>> >As suggested by Linus, I've cleaned the reapswap code to be contained
>> >inside an inline function. (yes, the if statement is really ugly)
>>
>> I can't seem to find the patch which adds this behaviour to the background
>> scanning.
>
>I've just sent Linus a patch to free swap cache pages at the time we free
>the last pte. (requested by himself)
>
>With it applied we should get the old behaviour back again.
>
>I can put it on my webpage if you wish.

Just copy it to me so I can replace the dead-swap hacks you introduced earlier.

--------------------------------------------------------------
from:     Jonathan "Chromatix" Morton
mail:     chromi@cyberspace.org  (not for attachments)

The key to knowledge is not to rely on people to teach you it.

GCS$/E/S dpu(!) s:- a20 C+++ UL++ P L+++ E W+ N- o? K? w--- O-- M++$ V? PS
PE- Y+ PGP++ t- 5- X- R !tv b++ DI+++ D G e+ h+ r++ y+(*)



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

end of thread, other threads:[~2001-06-07 19:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-06 20:07 [PATCH] Reap dead swap cache earlier v2 Marcelo Tosatti
2001-06-07 14:47 ` John Stoffel
2001-06-07 15:44   ` Hugh Dickins
2001-06-07 19:07 ` Jonathan Morton
2001-06-07 17:38   ` Marcelo Tosatti
2001-06-07 19:31   ` Jonathan Morton

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