linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* memory limitation test kit (tm) :-)
@ 1998-02-26 12:58 Rik van Riel
  1998-02-26 15:32 ` Rik van Riel
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Rik van Riel @ 1998-02-26 12:58 UTC (permalink / raw)
  To: linux-mm; +Cc: Stephen C. Tweedie, werner

Hi there,

I've made a 'very preliminary' test patch to test
whether memory limitation / quotation might work.
It's untested, untunable and plain wrong, but nevertheless
I'd like you all to take a look at it and point out things
that I've forgotten in the limitation code...

-----------------------------------------------------
--- linux2188orig/mm/page_alloc.c	Thu Feb 26 13:51:16 1998
+++ linux-2.1.88/mm/page_alloc.c	Thu Feb 26 13:09:17 1998
@@ -26,6 +26,7 @@
 #include <asm/bitops.h>
 #include <asm/pgtable.h>
 #include <asm/spinlock.h>
+#include <asm/smp_lock.h> /* for (un)lock_kernel() */
 
 int nr_swap_pages = 0;
 int nr_free_pages = 0;
@@ -328,7 +329,20 @@
 void swap_in(struct task_struct * tsk, struct vm_area_struct * vma,
 	pte_t * page_table, unsigned long entry, int write_access)
 {
-	unsigned long page = __get_free_page(GFP_KERNEL);
+	int i = 0;
+	unsigned long page = 0;
+	static int swap_out_process(struct task_struct *, int);
+
+	if (vma->vm_mm->rss > num_physpages / 2 && nr_free_pages < 
+			free_pages_high) {
+		lock_kernel();
+		for (i = vma->vm_mm->rss; i > 0; i--)
+			if (swap_out_process(tsk, __GFP_IO|__GFP_WAIT))
+				break;
+		unlock_kernel();
+	}
+
+	page = __get_free_page(GFP_KERNEL);
 
 	if (pte_val(*page_table) != entry) {
 		free_page(page);
------------------------------------------------------------

Rik.
+-----------------------------+------------------------------+
| For Linux mm-patches, go to | "I'm busy managing memory.." |
| my homepage (via LinuxHQ).  | H.H.vanRiel@fys.ruu.nl       |
| ...submissions welcome...   | http://www.fys.ruu.nl/~riel/ |
+-----------------------------+------------------------------+

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

* Re: memory limitation test kit (tm) :-)
  1998-02-26 12:58 memory limitation test kit (tm) :-) Rik van Riel
@ 1998-02-26 15:32 ` Rik van Riel
  1998-02-26 19:10 ` Dr. Werner Fink
  1998-02-26 22:53 ` Stephen C. Tweedie
  2 siblings, 0 replies; 6+ messages in thread
From: Rik van Riel @ 1998-02-26 15:32 UTC (permalink / raw)
  To: Stephen C. Tweedie; +Cc: linux-mm, werner, Rogier Wolff

On Thu, 26 Feb 1998, Rik van Riel wrote:

> I've made a 'very preliminary' test patch to test
> whether memory limitation / quotation might work.
> It's untested, untunable and plain wrong, but nevertheless
> I'd like you all to take a look at it and point out things
> that I've forgotten in the limitation code...

Hate to follow up on my own posts, but as Rogier illustrated
nicely it just won't work...
Hell, I even tested it, naturally with the same result as
Rogier's post illustrated :-))

An all-new stripped down version of my mmap-age patch is
on my way to Linus, Stephen and linux-mm however.

Rik.
+-----------------------------+------------------------------+
| For Linux mm-patches, go to | "I'm busy managing memory.." |
| my homepage (via LinuxHQ).  | H.H.vanRiel@fys.ruu.nl       |
| ...submissions welcome...   | http://www.fys.ruu.nl/~riel/ |
+-----------------------------+------------------------------+

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

* Re: memory limitation test kit (tm) :-)
  1998-02-26 12:58 memory limitation test kit (tm) :-) Rik van Riel
  1998-02-26 15:32 ` Rik van Riel
@ 1998-02-26 19:10 ` Dr. Werner Fink
  1998-02-26 19:29   ` Rik van Riel
  1998-02-26 22:53 ` Stephen C. Tweedie
  2 siblings, 1 reply; 6+ messages in thread
From: Dr. Werner Fink @ 1998-02-26 19:10 UTC (permalink / raw)
  To: H.H.vanRiel; +Cc: linux-mm, sct


> Hi there,
> 
> I've made a 'very preliminary' test patch to test
> whether memory limitation / quotation might work.
> It's untested, untunable and plain wrong, but nevertheless
> I'd like you all to take a look at it and point out things
> that I've forgotten in the limitation code...

Hmmm ... this will lead to increasing swap I/O. This because the
tsk which currently swaps in a needed page maybe lose an other
needed page ... even it not lose it the age of such a page is
decreased ... just like a handicap.

          Werner


> 
> -----------------------------------------------------
> --- linux2188orig/mm/page_alloc.c	Thu Feb 26 13:51:16 1998
> +++ linux-2.1.88/mm/page_alloc.c	Thu Feb 26 13:09:17 1998
> @@ -26,6 +26,7 @@
>  #include <asm/bitops.h>
>  #include <asm/pgtable.h>
>  #include <asm/spinlock.h>
> +#include <asm/smp_lock.h> /* for (un)lock_kernel() */
>  
>  int nr_swap_pages = 0;
>  int nr_free_pages = 0;
> @@ -328,7 +329,20 @@
>  void swap_in(struct task_struct * tsk, struct vm_area_struct * vma,
>  	pte_t * page_table, unsigned long entry, int write_access)
>  {
> -	unsigned long page = __get_free_page(GFP_KERNEL);
> +	int i = 0;
> +	unsigned long page = 0;
> +	static int swap_out_process(struct task_struct *, int);
> +
> +	if (vma->vm_mm->rss > num_physpages / 2 && nr_free_pages < 
> +			free_pages_high) {
> +		lock_kernel();
> +		for (i = vma->vm_mm->rss; i > 0; i--)
> +			if (swap_out_process(tsk, __GFP_IO|__GFP_WAIT))
> +				break;
> +		unlock_kernel();
> +	}
> +
> +	page = __get_free_page(GFP_KERNEL);
>  
>  	if (pte_val(*page_table) != entry) {
>  		free_page(page);
> ------------------------------------------------------------
> 
> Rik.
> +-----------------------------+------------------------------+
> | For Linux mm-patches, go to | "I'm busy managing memory.." |
> | my homepage (via LinuxHQ).  | H.H.vanRiel@fys.ruu.nl       |
> | ...submissions welcome...   | http://www.fys.ruu.nl/~riel/ |
> +-----------------------------+------------------------------+
> 
> 

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

* Re: memory limitation test kit (tm) :-)
  1998-02-26 19:10 ` Dr. Werner Fink
@ 1998-02-26 19:29   ` Rik van Riel
  0 siblings, 0 replies; 6+ messages in thread
From: Rik van Riel @ 1998-02-26 19:29 UTC (permalink / raw)
  To: Dr. Werner Fink; +Cc: linux-mm

On Thu, 26 Feb 1998, Dr. Werner Fink wrote:

> Hmmm ... this will lead to increasing swap I/O. This because the
> tsk which currently swaps in a needed page maybe lose an other
> needed page ... even it not lose it the age of such a page is
> decreased ... just like a handicap.

I tested it and lost :-) Better next time...
This patch only shows that we need to go another way,
as I pointed out in my post to linux-mm somewhat earlier
today.

Now we need to focus on design first, before we start
coding around :-)

Rik.
+-----------------------------+------------------------------+
| For Linux mm-patches, go to | "I'm busy managing memory.." |
| my homepage (via LinuxHQ).  | H.H.vanRiel@fys.ruu.nl       |
| ...submissions welcome...   | http://www.fys.ruu.nl/~riel/ |
+-----------------------------+------------------------------+

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

* Re: memory limitation test kit (tm) :-)
  1998-02-26 12:58 memory limitation test kit (tm) :-) Rik van Riel
  1998-02-26 15:32 ` Rik van Riel
  1998-02-26 19:10 ` Dr. Werner Fink
@ 1998-02-26 22:53 ` Stephen C. Tweedie
  1998-02-26 23:29   ` Rik van Riel
  2 siblings, 1 reply; 6+ messages in thread
From: Stephen C. Tweedie @ 1998-02-26 22:53 UTC (permalink / raw)
  To: Rik van Riel; +Cc: linux-mm, Stephen C. Tweedie, werner

Hi,

On Thu, 26 Feb 1998 13:58:05 +0100 (MET), Rik van Riel
<H.H.vanRiel@fys.ruu.nl> said:

> Hi there,
> I've made a 'very preliminary' test patch to test
> whether memory limitation / quotation might work.
> It's untested, untunable and plain wrong, but nevertheless
> I'd like you all to take a look at it and point out things
> that I've forgotten in the limitation code...

Running a single task which has a perfectly reasonable resident set
larger than num_physpages/2 will thrash unnecessarily.

What I'm aiming for with the RSS limits is to swap stuff out of the
process's ptes if it exceeds its RSS limit (btw, struct rusage already
defines a perfectly good RSS limit we can use here --- ru_maxrss), but
to keep the pages in memory in the swap cache until the memory is needed
for something else.  That way, a process exceeding RSS will run more
slowly due to soft page faults, but won't necessarily incur any extra
disk IO unless either there is genuine contention for memory or the
process is actively writing to a lot of its working set (doing the
swapout on unmodified pages is cheap, since we just keep the old copy on
disk anyway).

The new swap cache code was designed to support this stuff, and I'm
currently working on the code necessary to manage fast reclamation (even
from within interrupts) of swap pages which are disconnected from all
page tables but are still in cache.

Cheers,
 Stephen.

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

* Re: memory limitation test kit (tm) :-)
  1998-02-26 22:53 ` Stephen C. Tweedie
@ 1998-02-26 23:29   ` Rik van Riel
  0 siblings, 0 replies; 6+ messages in thread
From: Rik van Riel @ 1998-02-26 23:29 UTC (permalink / raw)
  To: Stephen C. Tweedie; +Cc: linux-mm, werner

On Thu, 26 Feb 1998, Stephen C. Tweedie wrote:

> > I've made a 'very preliminary' test patch to test
> > whether memory limitation / quotation might work.
> 
> Running a single task which has a perfectly reasonable resident set
> larger than num_physpages/2 will thrash unnecessarily.

I know... The patch was just meant as a "look it works ...
euhm, nope" type of eye-opener. Once the swap cache and
inactive list infrastructure is in place, we should replace
RSS limit with active limit, ie. the maximum number of active
pages a process is allowed to have. Then we can do effective
and harmless RSS limitation.

Rik.
+-----------------------------+------------------------------+
| For Linux mm-patches, go to | "I'm busy managing memory.." |
| my homepage (via LinuxHQ).  | H.H.vanRiel@fys.ruu.nl       |
| ...submissions welcome...   | http://www.fys.ruu.nl/~riel/ |
+-----------------------------+------------------------------+

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

end of thread, other threads:[~1998-02-27  0:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-26 12:58 memory limitation test kit (tm) :-) Rik van Riel
1998-02-26 15:32 ` Rik van Riel
1998-02-26 19:10 ` Dr. Werner Fink
1998-02-26 19:29   ` Rik van Riel
1998-02-26 22:53 ` Stephen C. Tweedie
1998-02-26 23:29   ` 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