Re: [PATCH] Warn if we run out of swap space

Randy Dunlap
2009-05-25T02:38:56Z

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