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

KAMEZAWA Hiroyuki
2009-05-27T00:43:19Z

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