linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Warn if we run out of swap space
@ 2009-05-22 18:58 Christoph Lameter
  2009-05-22 20:47 ` Pavel Machek
                   ` (3 more replies)
  0 siblings, 4 replies; 34+ messages in thread
From: Christoph Lameter @ 2009-05-22 18:58 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, Pavel Machek, Dave Hansen


Subject: Warn if we run out of swap space

Running out of swap space means that the evicton of anonymous pages may no longer
be possible which can lead to OOM conditions.

Print a warning when swap space first becomes exhausted.

Signed-off-by: Christoph Lameter <cl@linux-foundation.org>

---
 mm/swapfile.c |    5 +++++
 1 file changed, 5 insertions(+)

Index: linux-2.6/mm/swapfile.c
===================================================================
--- linux-2.6.orig/mm/swapfile.c	2009-05-22 12:25:19.000000000 -0500
+++ linux-2.6/mm/swapfile.c	2009-05-22 13:56:10.000000000 -0500
@@ -380,6 +380,7 @@ swp_entry_t get_swap_page(void)
 	pgoff_t offset;
 	int type, next;
 	int wrapped = 0;
+	static int printed = 0;

 	spin_lock(&swap_lock);
 	if (nr_swap_pages <= 0)
@@ -410,6 +411,10 @@ swp_entry_t get_swap_page(void)
 	}

 	nr_swap_pages++;
+	if (!printed) {
+		printed = 1;
+		printk(KERN_WARNING "All of swap is in use. Some pages cannot be swapped out.");
+	}
 noswap:
 	spin_unlock(&swap_lock);
 	return (swp_entry_t) {0};

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-22 18:58 [PATCH] Warn if we run out of swap space Christoph Lameter
@ 2009-05-22 20:47 ` Pavel Machek
  2009-05-23  4:38 ` Andrew Morton
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 34+ messages in thread
From: Pavel Machek @ 2009-05-22 20:47 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: akpm, linux-mm, Dave Hansen

On Fri 2009-05-22 14:58:19, Christoph Lameter wrote:
> 
> Subject: Warn if we run out of swap space
> 
> Running out of swap space means that the evicton of anonymous pages may no longer
> be possible which can lead to OOM conditions.
> 
> Print a warning when swap space first becomes exhausted.
> 
> Signed-off-by: Christoph Lameter <cl@linux-foundation.org>

Acked-by: Pavel Machek <pavel@ucw.cz>

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-22 18:58 [PATCH] Warn if we run out of swap space Christoph Lameter
  2009-05-22 20:47 ` Pavel Machek
@ 2009-05-23  4:38 ` Andrew Morton
  2009-05-25  0:53   ` KAMEZAWA Hiroyuki
  2009-05-24 13:44 ` KOSAKI Motohiro
  2009-06-01 16:19 ` Avi Kivity
  3 siblings, 1 reply; 34+ messages in thread
From: Andrew Morton @ 2009-05-23  4:38 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: linux-mm, Pavel Machek, Dave Hansen

On Fri, 22 May 2009 14:58:19 -0400 (EDT) Christoph Lameter <cl@linux-foundation.org> wrote:

> 
> Subject: Warn if we run out of swap space
> 
> Running out of swap space means that the evicton of anonymous pages may no longer
> be possible which can lead to OOM conditions.
> 
> Print a warning when swap space first becomes exhausted.
> 
> Signed-off-by: Christoph Lameter <cl@linux-foundation.org>
> 
> ---
>  mm/swapfile.c |    5 +++++
>  1 file changed, 5 insertions(+)
> 
> Index: linux-2.6/mm/swapfile.c
> ===================================================================
> --- linux-2.6.orig/mm/swapfile.c	2009-05-22 12:25:19.000000000 -0500
> +++ linux-2.6/mm/swapfile.c	2009-05-22 13:56:10.000000000 -0500
> @@ -380,6 +380,7 @@ swp_entry_t get_swap_page(void)
>  	pgoff_t offset;
>  	int type, next;
>  	int wrapped = 0;
> +	static int printed = 0;
> 
>  	spin_lock(&swap_lock);
>  	if (nr_swap_pages <= 0)
> @@ -410,6 +411,10 @@ swp_entry_t get_swap_page(void)
>  	}
> 
>  	nr_swap_pages++;
> +	if (!printed) {
> +		printed = 1;
> +		printk(KERN_WARNING "All of swap is in use. Some pages cannot be swapped out.");
> +	}
>  noswap:
>  	spin_unlock(&swap_lock);
>  	return (swp_entry_t) {0};

I think the warning is useful.  (Although the missing \n makes me wonder
how well tested this is).

However the once-per-boot thing weakens it quite a lot.  Suppose someone
runs out of swap, sees the message, adds more swap then later runs out
again?

Perhaps we could clear the `printed' flag each time the amount of online
swap is altered?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-22 18:58 [PATCH] Warn if we run out of swap space Christoph Lameter
  2009-05-22 20:47 ` Pavel Machek
  2009-05-23  4:38 ` Andrew Morton
@ 2009-05-24 13:44 ` KOSAKI Motohiro
  2009-05-25  2:42   ` Randy Dunlap
  2009-06-01 16:19 ` Avi Kivity
  3 siblings, 1 reply; 34+ messages in thread
From: KOSAKI Motohiro @ 2009-05-24 13:44 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: kosaki.motohiro, akpm, linux-mm, Pavel Machek, Dave Hansen

Hi

I have two question.


> Subject: Warn if we run out of swap space
> 
> Running out of swap space means that the evicton of anonymous pages may no longer
> be possible which can lead to OOM conditions.
> 
> Print a warning when swap space first becomes exhausted.
> 
> Signed-off-by: Christoph Lameter <cl@linux-foundation.org>
> 
> ---
>  mm/swapfile.c |    5 +++++
>  1 file changed, 5 insertions(+)
> 
> Index: linux-2.6/mm/swapfile.c
> ===================================================================
> --- linux-2.6.orig/mm/swapfile.c	2009-05-22 12:25:19.000000000 -0500
> +++ linux-2.6/mm/swapfile.c	2009-05-22 13:56:10.000000000 -0500
> @@ -380,6 +380,7 @@ swp_entry_t get_swap_page(void)
>  	pgoff_t offset;
>  	int type, next;
>  	int wrapped = 0;
> +	static int printed = 0;
> 
>  	spin_lock(&swap_lock);
>  	if (nr_swap_pages <= 0)
> @@ -410,6 +411,10 @@ swp_entry_t get_swap_page(void)
>  	}
> 
>  	nr_swap_pages++;
> +	if (!printed) {
> +		printed = 1;
> +		printk(KERN_WARNING "All of swap is in use. Some pages cannot be swapped out.");
> +	}

Why don't you use WARN_ONCE()?

lumpy reclaim on no swap system makes this warnings, right?
if so, I think it's a bit annoy.



>  noswap:
>  	spin_unlock(&swap_lock);
>  	return (swp_entry_t) {0};



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-23  4:38 ` Andrew Morton
@ 2009-05-25  0:53   ` KAMEZAWA Hiroyuki
  0 siblings, 0 replies; 34+ messages in thread
From: KAMEZAWA Hiroyuki @ 2009-05-25  0:53 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Christoph Lameter, linux-mm, Pavel Machek, Dave Hansen

On Fri, 22 May 2009 21:38:47 -0700
Andrew Morton <akpm@linux-foundation.org> wrote:

> On Fri, 22 May 2009 14:58:19 -0400 (EDT) Christoph Lameter <cl@linux-foundation.org> wrote:
> 
> > 
> > Subject: Warn if we run out of swap space
> > 
> > Running out of swap space means that the evicton of anonymous pages may no longer
> > be possible which can lead to OOM conditions.
> > 
> > Print a warning when swap space first becomes exhausted.
> > 
> > Signed-off-by: Christoph Lameter <cl@linux-foundation.org>
> > 
> > ---
> >  mm/swapfile.c |    5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > Index: linux-2.6/mm/swapfile.c
> > ===================================================================
> > --- linux-2.6.orig/mm/swapfile.c	2009-05-22 12:25:19.000000000 -0500
> > +++ linux-2.6/mm/swapfile.c	2009-05-22 13:56:10.000000000 -0500
> > @@ -380,6 +380,7 @@ swp_entry_t get_swap_page(void)
> >  	pgoff_t offset;
> >  	int type, next;
> >  	int wrapped = 0;
> > +	static int printed = 0;
> > 
> >  	spin_lock(&swap_lock);
> >  	if (nr_swap_pages <= 0)
> > @@ -410,6 +411,10 @@ swp_entry_t get_swap_page(void)
> >  	}
> > 
> >  	nr_swap_pages++;
> > +	if (!printed) {
> > +		printed = 1;
> > +		printk(KERN_WARNING "All of swap is in use. Some pages cannot be swapped out.");
> > +	}
> >  noswap:
> >  	spin_unlock(&swap_lock);
> >  	return (swp_entry_t) {0};
> 
> I think the warning is useful.  (Although the missing \n makes me wonder
> how well tested this is).
> 
> However the once-per-boot thing weakens it quite a lot.  Suppose someone
> runs out of swap, sees the message, adds more swap then later runs out
> again?
> 
> Perhaps we could clear the `printed' flag each time the amount of online
> swap is altered?
> 
How about clearing it in the condition vm_swap_full() returns false ?
Anyway, I welcome this patch :)

Thanks,
-Kame

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-24 13:44 ` KOSAKI Motohiro
@ 2009-05-25  2:42   ` Randy Dunlap
  2009-05-26  0:40     ` KOSAKI Motohiro
  2009-05-26  3:29     ` Paul Mundt
  0 siblings, 2 replies; 34+ messages in thread
From: Randy Dunlap @ 2009-05-25  2:42 UTC (permalink / raw)
  To: KOSAKI Motohiro
  Cc: Christoph Lameter, akpm, linux-mm, Pavel Machek, Dave Hansen

KOSAKI Motohiro wrote:
> Hi
> 
> I have two question.
> 
> 
>> Subject: Warn if we run out of swap space
>>
>> Running out of swap space means that the evicton of anonymous pages may no longer
>> be possible which can lead to OOM conditions.
>>
>> Print a warning when swap space first becomes exhausted.
>>
>> Signed-off-by: Christoph Lameter <cl@linux-foundation.org>
>>
>> ---
>>  mm/swapfile.c |    5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> Index: linux-2.6/mm/swapfile.c
>> ===================================================================
>> --- linux-2.6.orig/mm/swapfile.c	2009-05-22 12:25:19.000000000 -0500
>> +++ linux-2.6/mm/swapfile.c	2009-05-22 13:56:10.000000000 -0500
>> @@ -380,6 +380,7 @@ swp_entry_t get_swap_page(void)
>>  	pgoff_t offset;
>>  	int type, next;
>>  	int wrapped = 0;
>> +	static int printed = 0;
>>
>>  	spin_lock(&swap_lock);
>>  	if (nr_swap_pages <= 0)
>> @@ -410,6 +411,10 @@ swp_entry_t get_swap_page(void)
>>  	}
>>
>>  	nr_swap_pages++;
>> +	if (!printed) {
>> +		printed = 1;
>> +		printk(KERN_WARNING "All of swap is in use. Some pages cannot be swapped out.");
>> +	}
> 
> Why don't you use WARN_ONCE()?

Someone earlier in this patch thread (maybe Pavel?) commented that
WARN_ONCE() would cause a stack dump and that would be too harsh,
especially for users.  I.e., just the message is needed here, not a
stack dump.

> lumpy reclaim on no swap system makes this warnings, right?
> if so, I think it's a bit annoy.
> 
> 
> 
>>  noswap:
>>  	spin_unlock(&swap_lock);
>>  	return (swp_entry_t) {0};


-- 
~Randy
LPC 2009, Sept. 23-25, Portland, Oregon
http://linuxplumbersconf.org/2009/

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-25  2:42   ` Randy Dunlap
@ 2009-05-26  0:40     ` KOSAKI Motohiro
  2009-05-26  1:05       ` Randy Dunlap
  2009-05-26  3:29     ` Paul Mundt
  1 sibling, 1 reply; 34+ messages in thread
From: KOSAKI Motohiro @ 2009-05-26  0:40 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: kosaki.motohiro, Christoph Lameter, akpm, linux-mm, Pavel Machek,
	Dave Hansen

> >> @@ -410,6 +411,10 @@ swp_entry_t get_swap_page(void)
> >>  	}
> >>
> >>  	nr_swap_pages++;
> >> +	if (!printed) {
> >> +		printed = 1;
> >> +		printk(KERN_WARNING "All of swap is in use. Some pages cannot be swapped out.");
> >> +	}
> > 
> > Why don't you use WARN_ONCE()?
> 
> Someone earlier in this patch thread (maybe Pavel?) commented that
> WARN_ONCE() would cause a stack dump and that would be too harsh,
> especially for users.  I.e., just the message is needed here, not a
> stack dump.

Ah, makes sense.
I agree with you.

So, adding patch description is better?

> 
> > lumpy reclaim on no swap system makes this warnings, right?
> > if so, I think it's a bit annoy.
> > 
> >>  noswap:
> >>  	spin_unlock(&swap_lock);
> >>  	return (swp_entry_t) {0};



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-26  0:40     ` KOSAKI Motohiro
@ 2009-05-26  1:05       ` Randy Dunlap
  2009-05-26  1:08         ` KOSAKI Motohiro
  0 siblings, 1 reply; 34+ messages in thread
From: Randy Dunlap @ 2009-05-26  1:05 UTC (permalink / raw)
  To: KOSAKI Motohiro
  Cc: Christoph Lameter, akpm, linux-mm, Pavel Machek, Dave Hansen

KOSAKI Motohiro wrote:
>>>> @@ -410,6 +411,10 @@ swp_entry_t get_swap_page(void)
>>>>  	}
>>>>
>>>>  	nr_swap_pages++;
>>>> +	if (!printed) {
>>>> +		printed = 1;
>>>> +		printk(KERN_WARNING "All of swap is in use. Some pages cannot be swapped out.");
>>>> +	}
>>> Why don't you use WARN_ONCE()?
>> Someone earlier in this patch thread (maybe Pavel?) commented that
>> WARN_ONCE() would cause a stack dump and that would be too harsh,
>> especially for users.  I.e., just the message is needed here, not a
>> stack dump.
> 
> Ah, makes sense.
> I agree with you.
> 
> So, adding patch description is better?

Do you mean put that info in the patch description?
That would be OK.

>>> lumpy reclaim on no swap system makes this warnings, right?
>>> if so, I think it's a bit annoy.
>>>
>>>>  noswap:
>>>>  	spin_unlock(&swap_lock);
>>>>  	return (swp_entry_t) {0};


-- 
~Randy
LPC 2009, Sept. 23-25, Portland, Oregon
http://linuxplumbersconf.org/2009/

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-26  1:05       ` Randy Dunlap
@ 2009-05-26  1:08         ` KOSAKI Motohiro
  0 siblings, 0 replies; 34+ messages in thread
From: KOSAKI Motohiro @ 2009-05-26  1:08 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: kosaki.motohiro, Christoph Lameter, akpm, linux-mm, Pavel Machek,
	Dave Hansen

> KOSAKI Motohiro wrote:
> >>>> @@ -410,6 +411,10 @@ swp_entry_t get_swap_page(void)
> >>>>  	}
> >>>>
> >>>>  	nr_swap_pages++;
> >>>> +	if (!printed) {
> >>>> +		printed = 1;
> >>>> +		printk(KERN_WARNING "All of swap is in use. Some pages cannot be swapped out.");
> >>>> +	}
> >>> Why don't you use WARN_ONCE()?
> >> Someone earlier in this patch thread (maybe Pavel?) commented that
> >> WARN_ONCE() would cause a stack dump and that would be too harsh,
> >> especially for users.  I.e., just the message is needed here, not a
> >> stack dump.
> > 
> > Ah, makes sense.
> > I agree with you.
> > 
> > So, adding patch description is better?
> 
> Do you mean put that info in the patch description?

Sure. sorry my poor english.


> That would be OK.

I oftern review the patch by compare the patch description and the code.
so, explicit intention explanation is very useful.

thanks.



> 
> >>> lumpy reclaim on no swap system makes this warnings, right?
> >>> if so, I think it's a bit annoy.
> >>>
> >>>>  noswap:
> >>>>  	spin_unlock(&swap_lock);
> >>>>  	return (swp_entry_t) {0};
> 
> 
> -- 
> ~Randy
> LPC 2009, Sept. 23-25, Portland, Oregon
> http://linuxplumbersconf.org/2009/



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-25  2:42   ` Randy Dunlap
  2009-05-26  0:40     ` KOSAKI Motohiro
@ 2009-05-26  3:29     ` Paul Mundt
  2009-05-26 14:23       ` Christoph Lameter
  1 sibling, 1 reply; 34+ messages in thread
From: Paul Mundt @ 2009-05-26  3:29 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: KOSAKI Motohiro, Christoph Lameter, akpm, linux-mm, Pavel Machek,
	Dave Hansen

On Sun, May 24, 2009 at 07:42:02PM -0700, Randy Dunlap wrote:
> KOSAKI Motohiro wrote:
> >> +	if (!printed) {
> >> +		printed = 1;
> >> +		printk(KERN_WARNING "All of swap is in use. Some pages cannot be swapped out.");
> >> +	}
> > 
> > Why don't you use WARN_ONCE()?
> 
> Someone earlier in this patch thread (maybe Pavel?) commented that
> WARN_ONCE() would cause a stack dump and that would be too harsh,
> especially for users.  I.e., just the message is needed here, not a
> stack dump.
> 
Note that this is precisely what we have printk_once() for these days,
which will do what this patch is doing already. Of course if the variable
will be reset, then it is best left as is.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-26  3:29     ` Paul Mundt
@ 2009-05-26 14:23       ` Christoph Lameter
  2009-05-26 20:15         ` Andrew Morton
  2009-05-27  0:42         ` KAMEZAWA Hiroyuki
  0 siblings, 2 replies; 34+ messages in thread
From: Christoph Lameter @ 2009-05-26 14:23 UTC (permalink / raw)
  To: Paul Mundt
  Cc: Randy Dunlap, KOSAKI Motohiro, akpm, linux-mm, Pavel Machek, Dave Hansen


Subject: Warn if we run out of swap space

Running out of swap space means that the evicton of anonymous pages may no longer
be possible which can lead to OOM conditions.

Print a warning when swap space first becomes exhausted.
We do not use WARN_ON because that would perform a meaningless stack dump.

Signed-off-by: Christoph Lameter <cl@linux-foundation.org>

---
 include/linux/swap.h |    1 +
 mm/swapfile.c        |    7 +++++++
 mm/vmscan.c          |    9 +++++++++
 3 files changed, 17 insertions(+)

Index: linux-2.6/mm/swapfile.c
===================================================================
--- linux-2.6.orig/mm/swapfile.c	2009-05-22 14:03:37.000000000 -0500
+++ linux-2.6/mm/swapfile.c	2009-05-26 09:11:52.000000000 -0500
@@ -374,6 +374,8 @@ no_page:
 	return 0;
 }

+int out_of_swap_message_printed = 0;
+
 swp_entry_t get_swap_page(void)
 {
 	struct swap_info_struct *si;
@@ -410,6 +412,11 @@ swp_entry_t get_swap_page(void)
 	}

 	nr_swap_pages++;
+	if (!out_of_swap_message_printed) {
+		out_of_swap_message_printed = 1;
+		printk(KERN_WARNING "All of swap is in use. Some pages "
+			"cannot be swapped out.\n");
+	}
 noswap:
 	spin_unlock(&swap_lock);
 	return (swp_entry_t) {0};
Index: linux-2.6/mm/vmscan.c
===================================================================
--- linux-2.6.orig/mm/vmscan.c	2009-05-26 09:06:03.000000000 -0500
+++ linux-2.6/mm/vmscan.c	2009-05-26 09:20:30.000000000 -0500
@@ -1945,6 +1945,15 @@ out:
 		goto loop_again;
 	}

+	/*
+	 * If we had an out of swap condition but things have improved then
+	 * reset the flag so that we print the message again when we run
+	 * out of swap again.
+	 */
+#ifdef CONFIG_SWAP
+	if (out_of_swap_message_printed && !vm_swap_full())
+		out_of_swap_message_printed = 0;
+#endif
 	return sc.nr_reclaimed;
 }

Index: linux-2.6/include/linux/swap.h
===================================================================
--- linux-2.6.orig/include/linux/swap.h	2009-05-26 09:11:00.000000000 -0500
+++ linux-2.6/include/linux/swap.h	2009-05-26 09:11:38.000000000 -0500
@@ -163,6 +163,7 @@ struct swap_list_t {

 /* Swap 50% full? Release swapcache more aggressively.. */
 #define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
+extern int out_of_swap_message_printed;

 /* linux/mm/page_alloc.c */
 extern unsigned long totalram_pages;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-26 14:23       ` Christoph Lameter
@ 2009-05-26 20:15         ` Andrew Morton
  2009-05-26 20:45           ` Randy Dunlap
  2009-05-26 20:54           ` Christoph Lameter
  2009-05-27  0:42         ` KAMEZAWA Hiroyuki
  1 sibling, 2 replies; 34+ messages in thread
From: Andrew Morton @ 2009-05-26 20:15 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: lethal, randy.dunlap, kosaki.motohiro, linux-mm, pavel, dave

On Tue, 26 May 2009 10:23:36 -0400 (EDT)
Christoph Lameter <cl@linux.com> wrote:

> @@ -410,6 +412,11 @@ swp_entry_t get_swap_page(void)
>  	}
> 
>  	nr_swap_pages++;
> +	if (!out_of_swap_message_printed) {
> +		out_of_swap_message_printed = 1;
> +		printk(KERN_WARNING "All of swap is in use. Some pages "
> +			"cannot be swapped out.\n");
> +	}
>  noswap:
>  	spin_unlock(&swap_lock);
>  	return (swp_entry_t) {0};
> Index: linux-2.6/mm/vmscan.c
> ===================================================================
> --- linux-2.6.orig/mm/vmscan.c	2009-05-26 09:06:03.000000000 -0500
> +++ linux-2.6/mm/vmscan.c	2009-05-26 09:20:30.000000000 -0500
> @@ -1945,6 +1945,15 @@ out:
>  		goto loop_again;
>  	}
> 
> +	/*
> +	 * If we had an out of swap condition but things have improved then
> +	 * reset the flag so that we print the message again when we run
> +	 * out of swap again.
> +	 */
> +#ifdef CONFIG_SWAP
> +	if (out_of_swap_message_printed && !vm_swap_full())
> +		out_of_swap_message_printed = 0;
> +#endif
>  	return sc.nr_reclaimed;
>  }

I still worry that there may be usage patterns which will result in
this message coming out many times.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-26 20:15         ` Andrew Morton
@ 2009-05-26 20:45           ` Randy Dunlap
  2009-05-26 20:55             ` Andrew Morton
  2009-05-26 20:54           ` Christoph Lameter
  1 sibling, 1 reply; 34+ messages in thread
From: Randy Dunlap @ 2009-05-26 20:45 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Christoph Lameter, lethal, kosaki.motohiro, linux-mm, pavel, dave

Andrew Morton wrote:
> On Tue, 26 May 2009 10:23:36 -0400 (EDT)
> Christoph Lameter <cl@linux.com> wrote:
> 
>> @@ -410,6 +412,11 @@ swp_entry_t get_swap_page(void)
>>  	}
>>
>>  	nr_swap_pages++;
>> +	if (!out_of_swap_message_printed) {
>> +		out_of_swap_message_printed = 1;
>> +		printk(KERN_WARNING "All of swap is in use. Some pages "
>> +			"cannot be swapped out.\n");
>> +	}
>>  noswap:
>>  	spin_unlock(&swap_lock);
>>  	return (swp_entry_t) {0};
>> Index: linux-2.6/mm/vmscan.c
>> ===================================================================
>> --- linux-2.6.orig/mm/vmscan.c	2009-05-26 09:06:03.000000000 -0500
>> +++ linux-2.6/mm/vmscan.c	2009-05-26 09:20:30.000000000 -0500
>> @@ -1945,6 +1945,15 @@ out:
>>  		goto loop_again;
>>  	}
>>
>> +	/*
>> +	 * If we had an out of swap condition but things have improved then
>> +	 * reset the flag so that we print the message again when we run
>> +	 * out of swap again.
>> +	 */
>> +#ifdef CONFIG_SWAP
>> +	if (out_of_swap_message_printed && !vm_swap_full())
>> +		out_of_swap_message_printed = 0;
>> +#endif
>>  	return sc.nr_reclaimed;
>>  }
> 
> I still worry that there may be usage patterns which will result in
> this message coming out many times.

and using printk_ratelimit() or printk_timed_ratelimit() would be OK or not?

-- 
~Randy
LPC 2009, Sept. 23-25, Portland, Oregon
http://linuxplumbersconf.org/2009/

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-26 20:15         ` Andrew Morton
  2009-05-26 20:45           ` Randy Dunlap
@ 2009-05-26 20:54           ` Christoph Lameter
  2009-05-26 21:01             ` Andrew Morton
  1 sibling, 1 reply; 34+ messages in thread
From: Christoph Lameter @ 2009-05-26 20:54 UTC (permalink / raw)
  To: Andrew Morton
  Cc: lethal, randy.dunlap, kosaki.motohiro, linux-mm, pavel, dave

On Tue, 26 May 2009, Andrew Morton wrote:

> I still worry that there may be usage patterns which will result in
> this message coming out many times.

Note that vm_swa_full is defined the following way

#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)

This means that vm_swap_full is true when more than 50% of swap are in
use. The printed flag will therefore only be cleared if swap use falls to
less than half.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-26 20:45           ` Randy Dunlap
@ 2009-05-26 20:55             ` Andrew Morton
  2009-05-27  0:25               ` KAMEZAWA Hiroyuki
  0 siblings, 1 reply; 34+ messages in thread
From: Andrew Morton @ 2009-05-26 20:55 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: cl, lethal, kosaki.motohiro, linux-mm, pavel, dave

On Tue, 26 May 2009 13:45:13 -0700
Randy Dunlap <randy.dunlap@oracle.com> wrote:

> Andrew Morton wrote:
> > On Tue, 26 May 2009 10:23:36 -0400 (EDT)
> > Christoph Lameter <cl@linux.com> wrote:
> > 
> >> @@ -410,6 +412,11 @@ swp_entry_t get_swap_page(void)
> >>  	}
> >>
> >>  	nr_swap_pages++;
> >> +	if (!out_of_swap_message_printed) {
> >> +		out_of_swap_message_printed = 1;
> >> +		printk(KERN_WARNING "All of swap is in use. Some pages "
> >> +			"cannot be swapped out.\n");
> >> +	}
> >>  noswap:
> >>  	spin_unlock(&swap_lock);
> >>  	return (swp_entry_t) {0};
> >> Index: linux-2.6/mm/vmscan.c
> >> ===================================================================
> >> --- linux-2.6.orig/mm/vmscan.c	2009-05-26 09:06:03.000000000 -0500
> >> +++ linux-2.6/mm/vmscan.c	2009-05-26 09:20:30.000000000 -0500
> >> @@ -1945,6 +1945,15 @@ out:
> >>  		goto loop_again;
> >>  	}
> >>
> >> +	/*
> >> +	 * If we had an out of swap condition but things have improved then
> >> +	 * reset the flag so that we print the message again when we run
> >> +	 * out of swap again.
> >> +	 */
> >> +#ifdef CONFIG_SWAP
> >> +	if (out_of_swap_message_printed && !vm_swap_full())
> >> +		out_of_swap_message_printed = 0;
> >> +#endif
> >>  	return sc.nr_reclaimed;
> >>  }
> > 
> > I still worry that there may be usage patterns which will result in
> > this message coming out many times.
> 
> and using printk_ratelimit() or printk_timed_ratelimit() would be OK or not?

Well...  it would help.  We'd then get the same thing in the logs
thousands of times rather than hundreds of thousands of times.


But what's wrong with printing the thing just once, and not printing it
again until after someone ran swapon or swapoff?  I think that matches up
with the operator's actions pretty closely?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-26 20:54           ` Christoph Lameter
@ 2009-05-26 21:01             ` Andrew Morton
  2009-05-26 21:05               ` Christoph Lameter
  0 siblings, 1 reply; 34+ messages in thread
From: Andrew Morton @ 2009-05-26 21:01 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: lethal, randy.dunlap, kosaki.motohiro, linux-mm, pavel, dave

On Tue, 26 May 2009 16:54:58 -0400 (EDT)
Christoph Lameter <cl@linux.com> wrote:

> On Tue, 26 May 2009, Andrew Morton wrote:
> 
> > I still worry that there may be usage patterns which will result in
> > this message coming out many times.
> 
> Note that vm_swa_full is defined the following way
> 
> #define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
> 
> This means that vm_swap_full is true when more than 50% of swap are in
> use. The printed flag will therefore only be cleared if swap use falls to
> less than half.

(which was highly relevant changelog material)

OK.  But it that optimal?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-26 21:01             ` Andrew Morton
@ 2009-05-26 21:05               ` Christoph Lameter
  0 siblings, 0 replies; 34+ messages in thread
From: Christoph Lameter @ 2009-05-26 21:05 UTC (permalink / raw)
  To: Andrew Morton
  Cc: lethal, randy.dunlap, kosaki.motohiro, linux-mm, pavel, dave

On Tue, 26 May 2009, Andrew Morton wrote:

> On Tue, 26 May 2009 16:54:58 -0400 (EDT)
> Christoph Lameter <cl@linux.com> wrote:
>
> > On Tue, 26 May 2009, Andrew Morton wrote:
> >
> > > I still worry that there may be usage patterns which will result in
> > > this message coming out many times.
> >
> > Note that vm_swa_full is defined the following way
> >
> > #define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
> >
> > This means that vm_swap_full is true when more than 50% of swap are in
> > use. The printed flag will therefore only be cleared if swap use falls to
> > less than half.
>
> (which was highly relevant changelog material)

I thought everyone knew since they were pointing to it. There is a comment
where vm_swap_full() is defined.

> OK.  But it that optimal?

Not sure but it certainly makes the messages rather infrequent. I would
personally be satisifed with a single message if it occurs for the first
time. Someone tinkering around with swap space is rare at least on
machines that are supposed to do real work and I really do not want
printk storms during development.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-26 20:55             ` Andrew Morton
@ 2009-05-27  0:25               ` KAMEZAWA Hiroyuki
  0 siblings, 0 replies; 34+ messages in thread
From: KAMEZAWA Hiroyuki @ 2009-05-27  0:25 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Randy Dunlap, cl, lethal, kosaki.motohiro, linux-mm, pavel, dave

On Tue, 26 May 2009 13:55:27 -0700
Andrew Morton <akpm@linux-foundation.org> wrote:

> On Tue, 26 May 2009 13:45:13 -0700
> Randy Dunlap <randy.dunlap@oracle.com> wrote:
> 
> > Andrew Morton wrote:
> > > On Tue, 26 May 2009 10:23:36 -0400 (EDT)
> > > Christoph Lameter <cl@linux.com> wrote:
> > > 
> > >> @@ -410,6 +412,11 @@ swp_entry_t get_swap_page(void)
> > >>  	}
> > >>
> > >>  	nr_swap_pages++;
> > >> +	if (!out_of_swap_message_printed) {
> > >> +		out_of_swap_message_printed = 1;
> > >> +		printk(KERN_WARNING "All of swap is in use. Some pages "
> > >> +			"cannot be swapped out.\n");
> > >> +	}
> > >>  noswap:
> > >>  	spin_unlock(&swap_lock);
> > >>  	return (swp_entry_t) {0};
> > >> Index: linux-2.6/mm/vmscan.c
> > >> ===================================================================
> > >> --- linux-2.6.orig/mm/vmscan.c	2009-05-26 09:06:03.000000000 -0500
> > >> +++ linux-2.6/mm/vmscan.c	2009-05-26 09:20:30.000000000 -0500
> > >> @@ -1945,6 +1945,15 @@ out:
> > >>  		goto loop_again;
> > >>  	}
> > >>
> > >> +	/*
> > >> +	 * If we had an out of swap condition but things have improved then
> > >> +	 * reset the flag so that we print the message again when we run
> > >> +	 * out of swap again.
> > >> +	 */
> > >> +#ifdef CONFIG_SWAP
> > >> +	if (out_of_swap_message_printed && !vm_swap_full())
> > >> +		out_of_swap_message_printed = 0;
> > >> +#endif
> > >>  	return sc.nr_reclaimed;
> > >>  }
> > > 
> > > I still worry that there may be usage patterns which will result in
> > > this message coming out many times.
> > 
> > and using printk_ratelimit() or printk_timed_ratelimit() would be OK or not?
> 
> Well...  it would help.  We'd then get the same thing in the logs
> thousands of times rather than hundreds of thousands of times.
> 
> 
> But what's wrong with printing the thing just once, and not printing it
> again until after someone ran swapon or swapoff?  I think that matches up
> with the operator's actions pretty closely?
> 
IMHO, when the system is used every day without reboot and shared by users,
following behavior can be shown.

Monday   : UserA uses.
Tuesday  : UserA uses
Wednesday: UserA uses and near to swap full.
Thursday : UserB uses
Friday   : UserB uses and near to swap full.

If the appliation can be changed while the system is alive, multiple message is
not very bad. And...I don't think swapon/swapoff is usual operation for users.

Anyway, I think vm_swap_full() does all necessary work as Christoph explained in
other thread.

Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

Thanks,
-Kame






--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-26 14:23       ` Christoph Lameter
  2009-05-26 20:15         ` Andrew Morton
@ 2009-05-27  0:42         ` KAMEZAWA Hiroyuki
  2009-05-27 13:54           ` Christoph Lameter
  1 sibling, 1 reply; 34+ messages in thread
From: KAMEZAWA Hiroyuki @ 2009-05-27  0:42 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: Paul Mundt, Randy Dunlap, KOSAKI Motohiro, akpm, linux-mm,
	Pavel Machek, Dave Hansen

On Tue, 26 May 2009 10:23:36 -0400 (EDT)
Christoph Lameter <cl@linux.com> wrote:

> 
> Subject: Warn if we run out of swap space
> 
> Running out of swap space means that the evicton of anonymous pages may no longer
> be possible which can lead to OOM conditions.
> 
> Print a warning when swap space first becomes exhausted.
> We do not use WARN_ON because that would perform a meaningless stack dump.
> 
> Signed-off-by: Christoph Lameter <cl@linux-foundation.org>
> 
> ---
>  include/linux/swap.h |    1 +
>  mm/swapfile.c        |    7 +++++++
>  mm/vmscan.c          |    9 +++++++++
>  3 files changed, 17 insertions(+)
> 
> Index: linux-2.6/mm/swapfile.c
> ===================================================================
> --- linux-2.6.orig/mm/swapfile.c	2009-05-22 14:03:37.000000000 -0500
> +++ linux-2.6/mm/swapfile.c	2009-05-26 09:11:52.000000000 -0500
> @@ -374,6 +374,8 @@ no_page:
>  	return 0;
>  }
> 
> +int out_of_swap_message_printed = 0;
> +
>  swp_entry_t get_swap_page(void)
>  {
>  	struct swap_info_struct *si;
> @@ -410,6 +412,11 @@ swp_entry_t get_swap_page(void)
>  	}
> 
>  	nr_swap_pages++;
> +	if (!out_of_swap_message_printed) {
> +		out_of_swap_message_printed = 1;
> +		printk(KERN_WARNING "All of swap is in use. Some pages "
> +			"cannot be swapped out.\n");
> +	}
>  noswap:
>  	spin_unlock(&swap_lock);
BTW, hmm

Isn't this should be
==
noswap:
	if (total_swap_pages && !out_of_swap_message_printed) {
		....
	}
==

?
-Kame




--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-27  0:42         ` KAMEZAWA Hiroyuki
@ 2009-05-27 13:54           ` Christoph Lameter
  2009-06-04  6:02             ` KOSAKI Motohiro
  0 siblings, 1 reply; 34+ messages in thread
From: Christoph Lameter @ 2009-05-27 13:54 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki
  Cc: Christoph Lameter, Paul Mundt, Randy Dunlap, KOSAKI Motohiro,
	akpm, linux-mm, Pavel Machek, Dave Hansen

On Wed, 27 May 2009, KAMEZAWA Hiroyuki wrote:

> >  3 files changed, 17 insertions(+)
> >
> > Index: linux-2.6/mm/swapfile.c
> > ===================================================================
> > --- linux-2.6.orig/mm/swapfile.c	2009-05-22 14:03:37.000000000 -0500
> > +++ linux-2.6/mm/swapfile.c	2009-05-26 09:11:52.000000000 -0500
> > @@ -374,6 +374,8 @@ no_page:
> >  	return 0;
> >  }
> >
> > +int out_of_swap_message_printed = 0;
> > +
> >  swp_entry_t get_swap_page(void)
> >  {
> >  	struct swap_info_struct *si;
> > @@ -410,6 +412,11 @@ swp_entry_t get_swap_page(void)
> >  	}
> >
> >  	nr_swap_pages++;
> > +	if (!out_of_swap_message_printed) {
> > +		out_of_swap_message_printed = 1;
> > +		printk(KERN_WARNING "All of swap is in use. Some pages "
> > +			"cannot be swapped out.\n");
> > +	}
> >  noswap:
> >  	spin_unlock(&swap_lock);
> BTW, hmm
>
> Isn't this should be
> ==
> noswap:
> 	if (total_swap_pages && !out_of_swap_message_printed) {
> 		....
> 	}

Look at the beginning of get_swap_page():

   spin_lock(&swap_lock);
        if (nr_swap_pages <= 0)
                goto noswap;
        nr_swap_pages--;

I placed the printk intentionally before the noswap label.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-22 18:58 [PATCH] Warn if we run out of swap space Christoph Lameter
                   ` (2 preceding siblings ...)
  2009-05-24 13:44 ` KOSAKI Motohiro
@ 2009-06-01 16:19 ` Avi Kivity
  2009-06-01 17:29   ` Christoph Lameter
  2009-06-01 19:35   ` Andrew Morton
  3 siblings, 2 replies; 34+ messages in thread
From: Avi Kivity @ 2009-06-01 16:19 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: akpm, linux-mm, Pavel Machek, Dave Hansen

Christoph Lameter wrote:
> Subject: Warn if we run out of swap space
>
> Running out of swap space means that the evicton of anonymous pages may no longer
> be possible which can lead to OOM conditions.
>
> Print a warning when swap space first becomes exhausted.
>   

We really should have a machine readable channel for this sort of 
information, so it can be plumbed to a userspace notification bubble the 
user can ignore.

-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-06-01 16:19 ` Avi Kivity
@ 2009-06-01 17:29   ` Christoph Lameter
  2009-06-01 17:38     ` Avi Kivity
  2009-06-01 19:35   ` Andrew Morton
  1 sibling, 1 reply; 34+ messages in thread
From: Christoph Lameter @ 2009-06-01 17:29 UTC (permalink / raw)
  To: Avi Kivity; +Cc: akpm, linux-mm, Pavel Machek, Dave Hansen

On Mon, 1 Jun 2009, Avi Kivity wrote:

> We really should have a machine readable channel for this sort of information,
> so it can be plumbed to a userspace notification bubble the user can ignore.

Good idea. Create an event for udev?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-06-01 17:29   ` Christoph Lameter
@ 2009-06-01 17:38     ` Avi Kivity
  0 siblings, 0 replies; 34+ messages in thread
From: Avi Kivity @ 2009-06-01 17:38 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: akpm, linux-mm, Pavel Machek, Dave Hansen

Christoph Lameter wrote:
> On Mon, 1 Jun 2009, Avi Kivity wrote:
>
>   
>> We really should have a machine readable channel for this sort of information,
>> so it can be plumbed to a userspace notification bubble the user can ignore.
>>     
>
> Good idea. Create an event for udev?
>   

Sounds good.  The event should fire some configurable time before we 
actually run out, since the userspace program will likely need to 
allocate memory.

It might even allocate more swap space, thus giving the machine more 
breathing room.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-06-01 16:19 ` Avi Kivity
  2009-06-01 17:29   ` Christoph Lameter
@ 2009-06-01 19:35   ` Andrew Morton
  2009-06-01 19:44     ` Avi Kivity
  1 sibling, 1 reply; 34+ messages in thread
From: Andrew Morton @ 2009-06-01 19:35 UTC (permalink / raw)
  To: Avi Kivity; +Cc: cl, linux-mm, pavel, dave

On Mon, 01 Jun 2009 19:19:21 +0300
Avi Kivity <avi@redhat.com> wrote:

> Christoph Lameter wrote:
> > Subject: Warn if we run out of swap space
> >
> > Running out of swap space means that the evicton of anonymous pages may no longer
> > be possible which can lead to OOM conditions.
> >
> > Print a warning when swap space first becomes exhausted.
> >   
> 
> We really should have a machine readable channel for this sort of 
> information, so it can be plumbed to a userspace notification bubble the 
> user can ignore.

That could just be printk().  It's a question of a) how to tell
userspace which bits to pay attention to and maybe b) adding some
more structure to the text.

Perhaps careful use of faciliy levels would suffice for a), but I
expect that some new tagging scheme would be more practical.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-06-01 19:35   ` Andrew Morton
@ 2009-06-01 19:44     ` Avi Kivity
  2009-06-02  9:14       ` Pavel Machek
  2009-06-02  9:15       ` Pavel Machek
  0 siblings, 2 replies; 34+ messages in thread
From: Avi Kivity @ 2009-06-01 19:44 UTC (permalink / raw)
  To: Andrew Morton; +Cc: cl, linux-mm, pavel, dave

Andrew Morton wrote:
>> We really should have a machine readable channel for this sort of 
>> information, so it can be plumbed to a userspace notification bubble the 
>> user can ignore.
>>     
>
> That could just be printk().  It's a question of a) how to tell
> userspace which bits to pay attention to and maybe b) adding some
> more structure to the text.
>
> Perhaps careful use of faciliy levels would suffice for a), but I
> expect that some new tagging scheme would be more practical.
>   

I thought dmesg was an unreliable channel which can overflow.  It's also 
prone to attacks by spell checkers.

I prefer reliable binary interfaces to shell explorable text interfaces 
as I think any feature worth having is much more useful controlled by an 
application rather than a bored sysadmin.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-06-01 19:44     ` Avi Kivity
@ 2009-06-02  9:14       ` Pavel Machek
  2009-06-02  9:19         ` Avi Kivity
  2009-06-02  9:15       ` Pavel Machek
  1 sibling, 1 reply; 34+ messages in thread
From: Pavel Machek @ 2009-06-02  9:14 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Andrew Morton, cl, linux-mm, dave

On Mon 2009-06-01 22:44:20, Avi Kivity wrote:
> Andrew Morton wrote:
>>> We really should have a machine readable channel for this sort of  
>>> information, so it can be plumbed to a userspace notification bubble 
>>> the user can ignore.
>>>     
>>
>> That could just be printk().  It's a question of a) how to tell
>> userspace which bits to pay attention to and maybe b) adding some
>> more structure to the text.
>>
>> Perhaps careful use of faciliy levels would suffice for a), but I
>> expect that some new tagging scheme would be more practical.
>>   
>
> I thought dmesg was an unreliable channel which can overflow.  It's also  
> prone to attacks by spell checkers.

Well, I believe that any used-enough channecl will eventually
overflow. So dmesg still looks like the best we can do.

> I prefer reliable binary interfaces to shell explorable text interfaces  
> as I think any feature worth having is much more useful controlled by an  
> application rather than a bored sysadmin.

You are free to parse syslog. In fact, I guess some tags could be
added for messages where userland reaction is expected...
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-06-01 19:44     ` Avi Kivity
  2009-06-02  9:14       ` Pavel Machek
@ 2009-06-02  9:15       ` Pavel Machek
  2009-06-02  9:21         ` Avi Kivity
  2009-06-02  9:23         ` Avi Kivity
  1 sibling, 2 replies; 34+ messages in thread
From: Pavel Machek @ 2009-06-02  9:15 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Andrew Morton, cl, linux-mm, dave

On Mon 2009-06-01 22:44:20, Avi Kivity wrote:
> Andrew Morton wrote:
>>> We really should have a machine readable channel for this sort of  
>>> information, so it can be plumbed to a userspace notification bubble 
>>> the user can ignore.
>>>     
>>
>> That could just be printk().  It's a question of a) how to tell
>> userspace which bits to pay attention to and maybe b) adding some
>> more structure to the text.
>>
>> Perhaps careful use of faciliy levels would suffice for a), but I
>> expect that some new tagging scheme would be more practical.
>>   
>
> I thought dmesg was an unreliable channel which can overflow.  It's also  
> prone to attacks by spell checkers.
>
> I prefer reliable binary interfaces to shell explorable text interfaces  
> as I think any feature worth having is much more useful controlled by an  
> application rather than a bored sysadmin.

Ouch and please... don't stop useful printk() warnings just because
some 'pie-in-the-sky future binary protocol'. That's what happened in
ACPI land with battery critical, and it is also why I don't get
battery warnings on some of my machines.

State-of-the art userspace should not be required for reasonable
operation...
								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-06-02  9:14       ` Pavel Machek
@ 2009-06-02  9:19         ` Avi Kivity
  0 siblings, 0 replies; 34+ messages in thread
From: Avi Kivity @ 2009-06-02  9:19 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Andrew Morton, cl, linux-mm, dave

Pavel Machek wrote:
>>> Perhaps careful use of faciliy levels would suffice for a), but I
>>> expect that some new tagging scheme would be more practical.
>>>   
>>>       
>> I thought dmesg was an unreliable channel which can overflow.  It's also  
>> prone to attacks by spell checkers.
>>     
>
> Well, I believe that any used-enough channecl will eventually
> overflow. So dmesg still looks like the best we can do.
>   

No.  Two examples:

- eventfd won't overflow (but doesn't carry a lot of data)
- a channel which signals overflow reliably and allows the user to query 
state can recover from overflow.

>> I prefer reliable binary interfaces to shell explorable text interfaces  
>> as I think any feature worth having is much more useful controlled by an  
>> application rather than a bored sysadmin.
>>     
>
> You are free to parse syslog. In fact, I guess some tags could be
> added for messages where userland reaction is expected...

Why create a piece of text, hide it in a bunch of unrelated pieces of 
text, then try to extract it?

I want straightforward interfaces.

-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-06-02  9:15       ` Pavel Machek
@ 2009-06-02  9:21         ` Avi Kivity
  2009-06-02  9:30           ` Pavel Machek
  2009-06-02  9:23         ` Avi Kivity
  1 sibling, 1 reply; 34+ messages in thread
From: Avi Kivity @ 2009-06-02  9:21 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Andrew Morton, cl, linux-mm, dave

Pavel Machek wrote:
> Ouch and please... don't stop useful printk() warnings just because
> some 'pie-in-the-sky future binary protocol'. That's what happened in
> ACPI land with battery critical, and it is also why I don't get
> battery warnings on some of my machines.
>   

I don't oppose printk() on significant events (such as this) in addition 
to a proper programmatic interface.

> State-of-the art userspace should not be required for reasonable
> operation...
> 								Pavel
>   

On the other hand, we shouldn't need to cobble userspace out of a bunch 
of shell scripts because the kernel tries to communicate with users 
directly.

-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-06-02  9:15       ` Pavel Machek
  2009-06-02  9:21         ` Avi Kivity
@ 2009-06-02  9:23         ` Avi Kivity
  2009-06-02  9:26           ` Pavel Machek
  1 sibling, 1 reply; 34+ messages in thread
From: Avi Kivity @ 2009-06-02  9:23 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Andrew Morton, cl, linux-mm, dave

Pavel Machek wrote:
> Ouch and please... don't stop useful printk() warnings just because
> some 'pie-in-the-sky future binary protocol'. That's what happened in
> ACPI land with battery critical, and it is also why I don't get
> battery warnings on some of my machines.
>   

btw, adding a printk() for acpi battery state may have helped you and 
other kernel developers, but would have done nothing for ordinary humans 
using Linux on their laptops.  We should cater to the general population 
first and treat developer needs as nice-to-haves.

-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-06-02  9:23         ` Avi Kivity
@ 2009-06-02  9:26           ` Pavel Machek
  0 siblings, 0 replies; 34+ messages in thread
From: Pavel Machek @ 2009-06-02  9:26 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Andrew Morton, cl, linux-mm, dave

On Tue 2009-06-02 12:23:12, Avi Kivity wrote:
> Pavel Machek wrote:
>> Ouch and please... don't stop useful printk() warnings just because
>> some 'pie-in-the-sky future binary protocol'. That's what happened in
>> ACPI land with battery critical, and it is also why I don't get
>> battery warnings on some of my machines.
>>   
>
> btw, adding a printk() for acpi battery state may have helped you and  
> other kernel developers, but would have done nothing for ordinary humans  
> using Linux on their laptops.  We should cater to the general population  
> first and treat developer needs as nice-to-haves.

We already have the programatic interface, but it was used as a reason
not to merge printk(). And programatic interface helps nothing with
init=/bin/bash boot, minimal userland etc.
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-06-02  9:21         ` Avi Kivity
@ 2009-06-02  9:30           ` Pavel Machek
  2009-06-02  9:50             ` Avi Kivity
  0 siblings, 1 reply; 34+ messages in thread
From: Pavel Machek @ 2009-06-02  9:30 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Andrew Morton, cl, linux-mm, dave

On Tue 2009-06-02 12:21:11, Avi Kivity wrote:
> Pavel Machek wrote:
>> Ouch and please... don't stop useful printk() warnings just because
>> some 'pie-in-the-sky future binary protocol'. That's what happened in
>> ACPI land with battery critical, and it is also why I don't get
>> battery warnings on some of my machines.
>>   
>
> I don't oppose printk() on significant events (such as this) in addition  
> to a proper programmatic interface.

Good. So lets merge printk now, and someone can create proper
programmatic interface? :-).

(Top can already display swap usage, so I guess interface is really
there but needs to be polled which is ugly... but maybe workable for
this use?)
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-06-02  9:30           ` Pavel Machek
@ 2009-06-02  9:50             ` Avi Kivity
  0 siblings, 0 replies; 34+ messages in thread
From: Avi Kivity @ 2009-06-02  9:50 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Andrew Morton, cl, linux-mm, dave

Pavel Machek wrote:
> On Tue 2009-06-02 12:21:11, Avi Kivity wrote:
>   
>> Pavel Machek wrote:
>>     
>>> Ouch and please... don't stop useful printk() warnings just because
>>> some 'pie-in-the-sky future binary protocol'. That's what happened in
>>> ACPI land with battery critical, and it is also why I don't get
>>> battery warnings on some of my machines.
>>>   
>>>       
>> I don't oppose printk() on significant events (such as this) in addition  
>> to a proper programmatic interface.
>>     
>
> Good. So lets merge printk now, and someone can create proper
> programmatic interface? :-).
>
>   

No objection here.

> (Top can already display swap usage, so I guess interface is really
> there but needs to be polled which is ugly... but maybe workable for
> this use?)		

Don't say things like that where power people can hear you.

-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] Warn if we run out of swap space
  2009-05-27 13:54           ` Christoph Lameter
@ 2009-06-04  6:02             ` KOSAKI Motohiro
  0 siblings, 0 replies; 34+ messages in thread
From: KOSAKI Motohiro @ 2009-06-04  6:02 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: kosaki.motohiro, KAMEZAWA Hiroyuki, Christoph Lameter,
	Paul Mundt, Randy Dunlap, akpm, linux-mm, Pavel Machek,
	Dave Hansen

> On Wed, 27 May 2009, KAMEZAWA Hiroyuki wrote:
> 
> > >  3 files changed, 17 insertions(+)
> > >
> > > Index: linux-2.6/mm/swapfile.c
> > > ===================================================================
> > > --- linux-2.6.orig/mm/swapfile.c	2009-05-22 14:03:37.000000000 -0500
> > > +++ linux-2.6/mm/swapfile.c	2009-05-26 09:11:52.000000000 -0500
> > > @@ -374,6 +374,8 @@ no_page:
> > >  	return 0;
> > >  }
> > >
> > > +int out_of_swap_message_printed = 0;
> > > +
> > >  swp_entry_t get_swap_page(void)
> > >  {
> > >  	struct swap_info_struct *si;
> > > @@ -410,6 +412,11 @@ swp_entry_t get_swap_page(void)
> > >  	}
> > >
> > >  	nr_swap_pages++;
> > > +	if (!out_of_swap_message_printed) {
> > > +		out_of_swap_message_printed = 1;
> > > +		printk(KERN_WARNING "All of swap is in use. Some pages "
> > > +			"cannot be swapped out.\n");
> > > +	}
> > >  noswap:
> > >  	spin_unlock(&swap_lock);
> > BTW, hmm
> >
> > Isn't this should be
> > ==
> > noswap:
> > 	if (total_swap_pages && !out_of_swap_message_printed) {
> > 		....
> > 	}
> 
> Look at the beginning of get_swap_page():
> 
>    spin_lock(&swap_lock);
>         if (nr_swap_pages <= 0)
>                 goto noswap;
>         nr_swap_pages--;
> 
> I placed the printk intentionally before the noswap label.

I tested your patch. but it never output warning messages although swap full.

thanks.



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2009-06-04  6:02 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-22 18:58 [PATCH] Warn if we run out of swap space Christoph Lameter
2009-05-22 20:47 ` Pavel Machek
2009-05-23  4:38 ` Andrew Morton
2009-05-25  0:53   ` KAMEZAWA Hiroyuki
2009-05-24 13:44 ` KOSAKI Motohiro
2009-05-25  2:42   ` Randy Dunlap
2009-05-26  0:40     ` KOSAKI Motohiro
2009-05-26  1:05       ` Randy Dunlap
2009-05-26  1:08         ` KOSAKI Motohiro
2009-05-26  3:29     ` Paul Mundt
2009-05-26 14:23       ` Christoph Lameter
2009-05-26 20:15         ` Andrew Morton
2009-05-26 20:45           ` Randy Dunlap
2009-05-26 20:55             ` Andrew Morton
2009-05-27  0:25               ` KAMEZAWA Hiroyuki
2009-05-26 20:54           ` Christoph Lameter
2009-05-26 21:01             ` Andrew Morton
2009-05-26 21:05               ` Christoph Lameter
2009-05-27  0:42         ` KAMEZAWA Hiroyuki
2009-05-27 13:54           ` Christoph Lameter
2009-06-04  6:02             ` KOSAKI Motohiro
2009-06-01 16:19 ` Avi Kivity
2009-06-01 17:29   ` Christoph Lameter
2009-06-01 17:38     ` Avi Kivity
2009-06-01 19:35   ` Andrew Morton
2009-06-01 19:44     ` Avi Kivity
2009-06-02  9:14       ` Pavel Machek
2009-06-02  9:19         ` Avi Kivity
2009-06-02  9:15       ` Pavel Machek
2009-06-02  9:21         ` Avi Kivity
2009-06-02  9:30           ` Pavel Machek
2009-06-02  9:50             ` Avi Kivity
2009-06-02  9:23         ` Avi Kivity
2009-06-02  9:26           ` Pavel Machek

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