linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [patch 1/4] oom: extract deadlock helper function
@ 2007-06-27 14:44 David Rientjes
  2007-06-27 14:44 ` [patch 2/4] oom: select process to kill for cpusets David Rientjes
  2007-07-26  6:15 ` [patch 1/4] oom: extract deadlock helper function David Rientjes
  0 siblings, 2 replies; 25+ messages in thread
From: David Rientjes @ 2007-06-27 14:44 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Andrea Arcangeli, linux-mm

Extracts the jiffies comparison operation, the assignment of the
last_tif_memdie actual, and diagnostic message to its own function.

Cc: Andrea Arcangeli <andrea@suse.de>
Signed-off-by: David Rientjes <rientjes@google.com>
---
 mm/oom_kill.c |   27 +++++++++++++++++++++------
 1 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -28,6 +28,8 @@
 int sysctl_panic_on_oom;
 /* #define DEBUG */
 
+#define OOM_DEADLOCK_TIMEOUT	(10*HZ)
+
 unsigned long VM_is_OOM;
 static unsigned long last_tif_memdie_jiffies;
 
@@ -365,6 +367,22 @@ int unregister_oom_notifier(struct notifier_block *nb)
 }
 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
 
+/*
+ * Returns 1 if the OOM killer is deadlocked, meaning more than
+ * OOM_DEADLOCK_TIMEOUT time has elapsed since the last task was set to
+ * TIF_MEMDIE.  If it is deadlocked, the actual is updated to jiffies to check
+ * for future timeouts.  Otherwise, return 0.
+ */
+static int oom_is_deadlocked(unsigned long *last_tif_memdie)
+{
+	if (unlikely(time_before(jiffies, *last_tif_memdie +
+					  OOM_DEADLOCK_TIMEOUT)))
+		return 0;
+	*last_tif_memdie = jiffies;
+	printk("detected probable OOM deadlock, so killing another task\n");
+	return 1;
+}
+
 /**
  * out_of_memory - kill the "best" process when we run out of memory
  *
@@ -421,12 +439,9 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order)
 		 * so it's equivalent to write_lock_irq(tasklist_lock) as
 		 * far as VM_is_OOM is concerned.
 		 */
-		if (unlikely(test_bit(0, &VM_is_OOM))) {
-			if (time_before(jiffies, last_tif_memdie_jiffies + 10*HZ))
-				goto out;
-			printk("detected probable OOM deadlock, so killing another task\n");
-			last_tif_memdie_jiffies = jiffies;
-		}
+		if (unlikely(test_bit(0, &VM_is_OOM)) &&
+		    !oom_is_deadlocked(&last_tif_memdie_jiffies))
+			goto out;
 
 		if (sysctl_panic_on_oom) {
 			read_unlock(&tasklist_lock);

--
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] 25+ messages in thread

end of thread, other threads:[~2007-07-26  7:29 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-27 14:44 [patch 1/4] oom: extract deadlock helper function David Rientjes
2007-06-27 14:44 ` [patch 2/4] oom: select process to kill for cpusets David Rientjes
2007-06-27 14:44   ` [patch 3/4] oom: extract select helper function David Rientjes
2007-06-27 14:44     ` [patch 4/4] oom: serialize for cpusets David Rientjes
2007-06-27 21:53       ` Christoph Lameter
2007-06-27 22:13         ` Paul Jackson
2007-06-28  6:24           ` David Rientjes
2007-06-28  7:33             ` Paul Jackson
2007-06-28  8:05               ` David Rientjes
2007-06-28  9:03                 ` Paul Jackson
2007-06-28 18:13                   ` David Rientjes
2007-06-28 18:55                     ` Paul Jackson
2007-06-28 19:27                       ` Paul Menage
2007-06-28 20:15                         ` Paul Jackson
2007-06-28 20:43                       ` David Rientjes
2007-06-29  1:33                     ` Christoph Lameter
2007-06-29  4:07                       ` David Rientjes
2007-06-28  0:26         ` Andrea Arcangeli
2007-06-28 20:41       ` [patch 5/4] oom: add oom_kill_asking_task flag David Rientjes
2007-06-28 22:07         ` Paul Jackson
2007-06-27 21:52   ` [patch 2/4] oom: select process to kill for cpusets Christoph Lameter
2007-06-28  6:13     ` David Rientjes
2007-07-26  6:15 ` [patch 1/4] oom: extract deadlock helper function David Rientjes
2007-07-26  6:25   ` Andrew Morton
2007-07-26  7:29     ` David Rientjes

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