linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: Andrew Morton <akpm@digeo.com>
Cc: Joern Engel <joern@wohnheim.fh-wedel.de>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] stop swapoff 3/3 OOMkill
Date: Thu, 17 Apr 2003 21:49:47 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.44.0304172147330.2039-100000@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.44.0304172142530.2039-100000@localhost.localdomain>

Current behaviour is that once swapoff has filled memory, other tasks
get OOMkilled one by one until it completes, or more likely hangs.
Better that swapoff be the first choice for OOMkill.

I feel a little ashamed of adding another PF_flag for this, and it
may be done in other ways; but I've found none compellingly elegant.
And it would be enough for sys_swapoff to return failure rather than
be killed (along with any other tasks sharing its mm); but the OOMkill
mechanism gets the job done, I don't think we need complicate it.

--- swapoff2/include/linux/sched.h	Mon Apr 14 13:05:34 2003
+++ swapoff3/include/linux/sched.h	Thu Apr 17 18:33:00 2003
@@ -477,6 +477,7 @@
 #define PF_FROZEN	0x00010000	/* frozen for system suspend */
 #define PF_FSTRANS	0x00020000	/* inside a filesystem transaction */
 #define PF_KSWAPD	0x00040000	/* I am kswapd */
+#define PF_SWAPOFF	0x00080000	/* I am in swapoff */
 
 #if CONFIG_SMP
 extern void set_cpus_allowed(task_t *p, unsigned long new_mask);
--- swapoff2/mm/oom_kill.c	Tue Mar 25 08:06:56 2003
+++ swapoff3/mm/oom_kill.c	Thu Apr 17 18:33:00 2003
@@ -129,6 +129,8 @@
 				chosen = p;
 				maxpoints = points;
 			}
+			if (p->flags & PF_SWAPOFF)
+				return p;
 		}
 	while_each_thread(g, p);
 	return chosen;
--- swapoff2/mm/swapfile.c	Thu Apr 17 18:32:50 2003
+++ swapoff3/mm/swapfile.c	Thu Apr 17 18:33:00 2003
@@ -1060,7 +1060,9 @@
 	total_swap_pages -= p->pages;
 	p->flags &= ~SWP_WRITEOK;
 	swap_list_unlock();
+	current->flags |= PF_SWAPOFF;
 	err = try_to_unuse(type);
+	current->flags &= ~PF_SWAPOFF;
 	if (err) {
 		/* re-insert swap space back into swap_list */
 		swap_list_lock();


  parent reply	other threads:[~2003-04-17 20:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-17 20:46 [PATCH] stop swapoff 1/3 vm_enough_memory? Hugh Dickins
2003-04-17 20:47 ` [PATCH] stop swapoff 2/3 EINTR Hugh Dickins
2003-04-17 20:49 ` Hugh Dickins [this message]
2003-04-17 21:55   ` [PATCH] stop swapoff 3/3 OOMkill Andrew Morton
2003-04-17 23:10     ` Hugh Dickins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0304172147330.2039-100000@localhost.localdomain \
    --to=hugh@veritas.com \
    --cc=akpm@digeo.com \
    --cc=joern@wohnheim.fh-wedel.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).