linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0 of 2] oom incremental fixes
@ 2007-06-11 14:30 andrea
  2007-06-11 14:30 ` [PATCH 1 of 2] apply the anti deadlock features only to global oom andrea
  2007-06-11 14:30 ` [PATCH 2 of 2] run panic the same way in both places andrea
  0 siblings, 2 replies; 3+ messages in thread
From: andrea @ 2007-06-11 14:30 UTC (permalink / raw)
  To: linux-mm

These two are incremental with the previous patchbomb. If you prefer I remerge
1 in the middle I can do that, but then I'd probably need to resend more than
one ;).

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

* [PATCH 1 of 2] apply the anti deadlock features only to global oom
  2007-06-11 14:30 [PATCH 0 of 2] oom incremental fixes andrea
@ 2007-06-11 14:30 ` andrea
  2007-06-11 14:30 ` [PATCH 2 of 2] run panic the same way in both places andrea
  1 sibling, 0 replies; 3+ messages in thread
From: andrea @ 2007-06-11 14:30 UTC (permalink / raw)
  To: linux-mm

# HG changeset patch
# User Andrea Arcangeli <andrea@suse.de>
# Date 1181572232 -7200
# Node ID aa5f6b86a146552d4b0c26b2aa5cc009a3093e49
# Parent  1187bc6a44bb2b14560132ac5199849f3a830e48
apply the anti deadlock features only to global oom

Cc: Christoph Lameter <clameter@sgi.com>
The local numa oom will keep killing the current task hoping that's it's
not an innocent task and it won't alter the behavior of the rest of the
VM. The global oom will not wait for TIF_MEMDIE tasks anymore, so this
will be a really local event, not like before when the local-TIF_MEMDIE
was effectively a global flag that the global oom would depend on too.

Signed-off-by: Andrea Arcangeli <andrea@suse.de>

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -386,9 +386,6 @@ void out_of_memory(struct zonelist *zone
 		/* Got some memory back in the last second. */
 		return;
 
-	if (down_trylock(&OOM_lock))
-		return;
-
 	if (sysctl_panic_on_oom == 2)
 		panic("out of memory. Compulsory panic_on_oom is selected.\n");
 
@@ -398,32 +395,39 @@ void out_of_memory(struct zonelist *zone
 	 */
 	constraint = constrained_alloc(zonelist, gfp_mask);
 	cpuset_lock();
-	read_lock(&tasklist_lock);
-
-	/*
-	 * This holds the down(OOM_lock)+read_lock(tasklist_lock), 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;
-	}
 
 	switch (constraint) {
 	case CONSTRAINT_MEMORY_POLICY:
+		read_lock(&tasklist_lock);
 		oom_kill_process(current, points,
 				 "No available memory (MPOL_BIND)", gfp_mask, order);
+		read_unlock(&tasklist_lock);
 		break;
 
 	case CONSTRAINT_CPUSET:
+		read_lock(&tasklist_lock);
 		oom_kill_process(current, points,
 				 "No available memory in cpuset", gfp_mask, order);
+		read_unlock(&tasklist_lock);
 		break;
 
 	case CONSTRAINT_NONE:
+		if (down_trylock(&OOM_lock))
+			break;
+		read_lock(&tasklist_lock);
+
+		/*
+		 * This holds the down(OOM_lock)+read_lock(tasklist_lock),
+		 * 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 (sysctl_panic_on_oom)
 			panic("out of memory. panic_on_oom is selected\n");
 retry:
@@ -442,12 +446,11 @@ retry:
 		if (oom_kill_process(p, points, "Out of memory", gfp_mask, order))
 			goto retry;
 
+	out:
+		read_unlock(&tasklist_lock);
+		up(&OOM_lock);
 		break;
 	}
 
-out:
-	read_unlock(&tasklist_lock);
 	cpuset_unlock();
-
-	up(&OOM_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] 3+ messages in thread

* [PATCH 2 of 2] run panic the same way in both places
  2007-06-11 14:30 [PATCH 0 of 2] oom incremental fixes andrea
  2007-06-11 14:30 ` [PATCH 1 of 2] apply the anti deadlock features only to global oom andrea
@ 2007-06-11 14:30 ` andrea
  1 sibling, 0 replies; 3+ messages in thread
From: andrea @ 2007-06-11 14:30 UTC (permalink / raw)
  To: linux-mm

# HG changeset patch
# User Andrea Arcangeli <andrea@suse.de>
# Date 1181572232 -7200
# Node ID dffa158c3b3c7849ffb08ec0551ec999f50e2e59
# Parent  aa5f6b86a146552d4b0c26b2aa5cc009a3093e49
run panic the same way in both places

The other panic is called after releasing some core global lock, that
sounds safe to have for both panics (just in case panic tries to do
anything more than oops does).

Signed-off-by: Andrea Arcangeli <andrea@suse.de>

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -428,8 +428,11 @@ void out_of_memory(struct zonelist *zone
 			last_tif_memdie_jiffies = jiffies;
 		}
 
-		if (sysctl_panic_on_oom)
+		if (sysctl_panic_on_oom) {
+			read_unlock(&tasklist_lock);
+			cpuset_unlock();
 			panic("out of memory. panic_on_oom is selected\n");
+		}
 retry:
 		/*
 		 * Rambo mode: Shoot down a process and hope it solves whatever
@@ -437,7 +440,7 @@ retry:
 		 */
 		p = select_bad_process(&points);
 		/* Found nothing?!?! Either we hang forever, or we panic. */
-		if (!p) {
+		if (unlikely(!p)) {
 			read_unlock(&tasklist_lock);
 			cpuset_unlock();
 			panic("Out of memory and no killable processes...\n");

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

end of thread, other threads:[~2007-06-11 14:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-11 14:30 [PATCH 0 of 2] oom incremental fixes andrea
2007-06-11 14:30 ` [PATCH 1 of 2] apply the anti deadlock features only to global oom andrea
2007-06-11 14:30 ` [PATCH 2 of 2] run panic the same way in both places andrea

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