[PATCH 11 of 13] not-wait-memdie

Andrea Arcangeli
2008-01-08T07:50:42Z

# Date 1199470022 -3600
# Node ID ecc696d359edebbfe35566510f78a4be445c8f67
# Parent 0a13c24681cf4851555c87358fc2ec2465f9ef39
not-wait-memdie

Don't wait tif-memdie tasks forever because they may be stuck in some kernel
lock owned by some task that requires memory to exit the critical section.

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
@@ -222,12 +222,16 @@ static struct task_struct *select_bad_pr
* being killed. Don't allow any other task access to the
* memory reserve.
*
- * Note: this may have a chance of deadlock if it gets
- * blocked waiting for another task which itself is waiting
- * for memory. Is there a better alternative?
+ * But if the TIF_MEMDIE task stays around for more than
+ * MEMDIE_DELAY jiffies, ignore it and fallback killing
+ * another task.
*/
- if (test_tsk_thread_flag(p, TIF_MEMDIE))
- return ERR_PTR(-1UL);
+ if (test_tsk_thread_flag(p, TIF_MEMDIE)) {
+ if (time_before(p->memdie_jiffies + MEMDIE_DELAY, jiffies))
+ continue;
+ else
+ return ERR_PTR(-1UL);
+ }

/*
* This is in the process of releasing memory so wait for it