linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [RFC][PATCH] vm_swap_full
@ 2001-11-05 12:37 Ed Tomlinson
  0 siblings, 0 replies; 8+ messages in thread
From: Ed Tomlinson @ 2001-11-05 12:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mike Fedyk

Think of it this way.  nr_swap_pages is the ammount of space
available for new swap pages.  nr inactive pages is the ammount
of pages we know that just might get swapped - so we want to be
sure we keep space in swap for them.  The logic I am trying to
implement is to switch to aggressive swap (reclaim the swap space
at page in) when we are in at risk of filling swap.  IMO we
do not way to reclaim until we have too, as there are gains to
be had if we page in a page,it does not get changed and we have
memory pressure.  

The test as it stood would be fine for machines with small swap.
Some applications (SAP for instance) recommend swap as 3 x memory.
If you have 2G memory and 6G swap it does not make much sense to
start unmapping swap pages at swap in when you have only 3G in
swap.  It does make sense to do this when you have less than
600M of free swap pages.  Problem is to decide what is a reasonable
threshold.  Since the inactive list is what can get swapped out,
using its size as the metric makes sense.

Ed Tomlinson 

Mike Fedyk wrote:

> On Sun, Nov 04, 2001 at 09:58:17PM -0500, Ed Tomlinson wrote:
>> On November 4, 2001 09:08 pm, Mike Fedyk wrote:
>> > On Sun, Nov 04, 2001 at 02:36:34PM -0200, Rik van Riel wrote:
>> > > On Sun, 4 Nov 2001, Ed Tomlinson wrote:
>> > > > -/* Swap 50% full? Release swapcache more aggressively.. */
>> > > > -#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
>> > > > +/* Free swap less than inactive pages? Release swapcache more
>> > > > aggressively.. */ +#define vm_swap_full() (nr_swap_pages <
>> > > > nr_inactive_pages)
>> > > >
>> > > > Comments?
>> > >
>> > > Makes absolutely no sense for systems which have more
>> > > swap than RAM, eg. a 64MB system with 200MB of swap.
>> >
>> > How does the inactive list get bigger than physical ram?
>> >
>> > If swap is bigger than ram, there is *no* possibility of the inactive
>> > list being bigger than swap, and thus no aggressive swapping...
>> 
>> nr_swap_pages is the number of swap pages free.
> 
> Oh, I thought it was total swap pages...
> 
>>The idea is to start
>> aggressive swap only when we are at risk of running out of swap.  This
>> way we get to take full advantage of throwing away clean pages that are
>> backed up by swap when under vm pressure.
>> 
> Yes.  My point is that the inactive list can't get bigger than RAM, and
> thus if swap is bigger than ram this case wouldn't trigger...
> 
> But now that nr_swap_pages is *free* swap, you'll have to add another test
> for (swap > RAM)...
> 
> Mike
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [RFC][PATCH] vm_swap_full
  2001-11-05  3:10       ` Mike Fedyk
@ 2001-11-05  3:15         ` Rik van Riel
  0 siblings, 0 replies; 8+ messages in thread
From: Rik van Riel @ 2001-11-05  3:15 UTC (permalink / raw)
  To: Mike Fedyk; +Cc: Ed Tomlinson, linux-kernel

On Sun, 4 Nov 2001, Mike Fedyk wrote:

> But now that nr_swap_pages is *free* swap, you'll have to add another
> test for (swap > RAM)...

I talked about this thing with Ed on #kernelnewbies and
it turns out all which really needs to be added is some
proper documentation.

The thing is correct, but it confused me too at first ;)

cheers,

Rik
-- 
DMCA, SSSCA, W3C?  Who cares?  http://thefreeworld.net/

http://www.surriel.com/		http://distro.conectiva.com/


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

* Re: [RFC][PATCH] vm_swap_full
  2001-11-05  2:58     ` Ed Tomlinson
@ 2001-11-05  3:10       ` Mike Fedyk
  2001-11-05  3:15         ` Rik van Riel
  0 siblings, 1 reply; 8+ messages in thread
From: Mike Fedyk @ 2001-11-05  3:10 UTC (permalink / raw)
  To: Ed Tomlinson; +Cc: Rik van Riel, linux-kernel

On Sun, Nov 04, 2001 at 09:58:17PM -0500, Ed Tomlinson wrote:
> On November 4, 2001 09:08 pm, Mike Fedyk wrote:
> > On Sun, Nov 04, 2001 at 02:36:34PM -0200, Rik van Riel wrote:
> > > On Sun, 4 Nov 2001, Ed Tomlinson wrote:
> > > > -/* Swap 50% full? Release swapcache more aggressively.. */
> > > > -#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
> > > > +/* Free swap less than inactive pages? Release swapcache more
> > > > aggressively.. */ +#define vm_swap_full() (nr_swap_pages <
> > > > nr_inactive_pages)
> > > >
> > > > Comments?
> > >
> > > Makes absolutely no sense for systems which have more
> > > swap than RAM, eg. a 64MB system with 200MB of swap.
> >
> > How does the inactive list get bigger than physical ram?
> >
> > If swap is bigger than ram, there is *no* possibility of the inactive list
> > being bigger than swap, and thus no aggressive swapping...
> 
> nr_swap_pages is the number of swap pages free.  

Oh, I thought it was total swap pages...

>The idea is to start
> aggressive swap only when we are at risk of running out of swap.  This way
> we get to take full advantage of throwing away clean pages that are backed
> up by swap when under vm pressure. 
> 
Yes.  My point is that the inactive list can't get bigger than RAM, and thus
if swap is bigger than ram this case wouldn't trigger...

But now that nr_swap_pages is *free* swap, you'll have to add another test
for (swap > RAM)... 

Mike

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

* Re: [RFC][PATCH] vm_swap_full
  2001-11-05  2:08   ` Mike Fedyk
@ 2001-11-05  2:58     ` Ed Tomlinson
  2001-11-05  3:10       ` Mike Fedyk
  0 siblings, 1 reply; 8+ messages in thread
From: Ed Tomlinson @ 2001-11-05  2:58 UTC (permalink / raw)
  To: Mike Fedyk, Rik van Riel; +Cc: linux-kernel

On November 4, 2001 09:08 pm, Mike Fedyk wrote:
> On Sun, Nov 04, 2001 at 02:36:34PM -0200, Rik van Riel wrote:
> > On Sun, 4 Nov 2001, Ed Tomlinson wrote:
> > > -/* Swap 50% full? Release swapcache more aggressively.. */
> > > -#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
> > > +/* Free swap less than inactive pages? Release swapcache more
> > > aggressively.. */ +#define vm_swap_full() (nr_swap_pages <
> > > nr_inactive_pages)
> > >
> > > Comments?
> >
> > Makes absolutely no sense for systems which have more
> > swap than RAM, eg. a 64MB system with 200MB of swap.
>
> How does the inactive list get bigger than physical ram?
>
> If swap is bigger than ram, there is *no* possibility of the inactive list
> being bigger than swap, and thus no aggressive swapping...

nr_swap_pages is the number of swap pages free.  The idea is to start
aggressive swap only when we are at risk of running out of swap.  This way
we get to take full advantage of throwing away clean pages that are backed
up by swap when under vm pressure. 

Ed Tomlinson

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

* Re: [RFC][PATCH] vm_swap_full
  2001-11-04 16:36 ` Rik van Riel
  2001-11-04 17:04   ` Ed Tomlinson
@ 2001-11-05  2:08   ` Mike Fedyk
  2001-11-05  2:58     ` Ed Tomlinson
  1 sibling, 1 reply; 8+ messages in thread
From: Mike Fedyk @ 2001-11-05  2:08 UTC (permalink / raw)
  To: Rik van Riel; +Cc: Ed Tomlinson, linux-kernel

On Sun, Nov 04, 2001 at 02:36:34PM -0200, Rik van Riel wrote:
> On Sun, 4 Nov 2001, Ed Tomlinson wrote:
> 
> > -/* Swap 50% full? Release swapcache more aggressively.. */
> > -#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
> > +/* Free swap less than inactive pages? Release swapcache more aggressively.. */
> > +#define vm_swap_full() (nr_swap_pages < nr_inactive_pages)
> 
> > Comments?
> 
> Makes absolutely no sense for systems which have more
> swap than RAM, eg. a 64MB system with 200MB of swap.
> 

How does the inactive list get bigger than physical ram?

If swap is bigger than ram, there is *no* possibility of the inactive list
being bigger than swap, and thus no aggressive swapping...

Mike

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

* Re: [RFC][PATCH] vm_swap_full
  2001-11-04 16:36 ` Rik van Riel
@ 2001-11-04 17:04   ` Ed Tomlinson
  2001-11-05  2:08   ` Mike Fedyk
  1 sibling, 0 replies; 8+ messages in thread
From: Ed Tomlinson @ 2001-11-04 17:04 UTC (permalink / raw)
  To: linux-kernel

Rik van Riel wrote:

> On Sun, 4 Nov 2001, Ed Tomlinson wrote:
> 
>> -/* Swap 50% full? Release swapcache more aggressively.. */
>> -#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
>> +/* Free swap less than inactive pages? Release swapcache more
>> aggressively.. */ +#define vm_swap_full() (nr_swap_pages <
>> nr_inactive_pages)
> 
>> Comments?
> 
> Makes absolutely no sense for systems which have more
> swap than RAM, eg. a 64MB system with 200MB of swap.

My thinking was allong these lines.  At a given instant in time the max we
have that might get swapped out is the inactive list.  So if we start 
aggressive swapping when we have less swap than the size of the inactive 
list we should be ok.  The premise being that leaving swap mapped can be
a win for pages swapped in but not changed.

Ed Tomlinson



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

* Re: [RFC][PATCH] vm_swap_full
  2001-11-04 15:23 Ed Tomlinson
@ 2001-11-04 16:36 ` Rik van Riel
  2001-11-04 17:04   ` Ed Tomlinson
  2001-11-05  2:08   ` Mike Fedyk
  0 siblings, 2 replies; 8+ messages in thread
From: Rik van Riel @ 2001-11-04 16:36 UTC (permalink / raw)
  To: Ed Tomlinson; +Cc: linux-kernel

On Sun, 4 Nov 2001, Ed Tomlinson wrote:

> -/* Swap 50% full? Release swapcache more aggressively.. */
> -#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
> +/* Free swap less than inactive pages? Release swapcache more aggressively.. */
> +#define vm_swap_full() (nr_swap_pages < nr_inactive_pages)

> Comments?

Makes absolutely no sense for systems which have more
swap than RAM, eg. a 64MB system with 200MB of swap.

Rik
-- 
DMCA, SSSCA, W3C?  Who cares?  http://thefreeworld.net/

http://www.surriel.com/		http://distro.conectiva.com/


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

* [RFC][PATCH] vm_swap_full
@ 2001-11-04 15:23 Ed Tomlinson
  2001-11-04 16:36 ` Rik van Riel
  0 siblings, 1 reply; 8+ messages in thread
From: Ed Tomlinson @ 2001-11-04 15:23 UTC (permalink / raw)
  To: linux-kernel

Hi,

I my opinion, basing the vm_swap_full test on the size of swap is bogus.
If you have a 512M box with 128M of swap its a good idea to always release
aggressively.  If the same box has 2G of swap (has /tmp on tmpfs maybe), it
does not make sense to start the agressive release at 1G.  I suggest the 
following makes more sense.

--- linux/include/linux/swap.h.orig     Sun Nov  4 09:30:14 2001
+++ linux/include/linux/swap.h  Sun Nov  4 09:32:46 2001
@@ -80,8 +80,8 @@

 extern int nr_swap_pages;

-/* Swap 50% full? Release swapcache more aggressively.. */
-#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
+/* Free swap less than inactive pages? Release swapcache more aggressively.. */
+#define vm_swap_full() (nr_swap_pages < nr_inactive_pages)

 extern unsigned int nr_free_pages(void);
 extern unsigned int nr_free_buffer_pages(void);

This starts aggressive swaping when the ammount of space left in swap is
less than the size of the inactive pages.

Comments?
Ed Tomlinson

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

end of thread, other threads:[~2001-11-06  1:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-05 12:37 [RFC][PATCH] vm_swap_full Ed Tomlinson
  -- strict thread matches above, loose matches on Subject: below --
2001-11-04 15:23 Ed Tomlinson
2001-11-04 16:36 ` Rik van Riel
2001-11-04 17:04   ` Ed Tomlinson
2001-11-05  2:08   ` Mike Fedyk
2001-11-05  2:58     ` Ed Tomlinson
2001-11-05  3:10       ` Mike Fedyk
2001-11-05  3:15         ` Rik van Riel

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