* [PATCH] oom-killer kills more than needed
@ 2008-09-29 23:09 Chad Zanonie
0 siblings, 0 replies; 2+ messages in thread
From: Chad Zanonie @ 2008-09-29 23:09 UTC (permalink / raw)
To: linux-kernel
Signed-off-by: Chad Zanonie
This mod firstly replaces a !p->mm check with PF_KTHREAD to more
accurately identify
kthreads. Secondly, it adds a (p->state & TASK_DEAD) check to identify processes
that have released their mm entirely. Not waiting for a process to finish
releasing its memory entirely can cause the OOM killer to kill another
application unnecessarily (while p->mm is null but memory isn't yet available).
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 64e5b4b..f325a87 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -216,7 +216,7 @@ static struct task_struct
*select_bad_process(unsigned long *ppoints,
* skip kernel threads and tasks which have already released
* their mm.
*/
- if (!p->mm)
+ if (p->flags & PF_KTHREAD || p->state & TASK_DEAD)
continue;
/* skip the init task */
if (is_global_init(p))
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] oom-killer kills more than needed
@ 2008-09-19 18:06 Chad Zanonie
0 siblings, 0 replies; 2+ messages in thread
From: Chad Zanonie @ 2008-09-19 18:06 UTC (permalink / raw)
To: linux-kernel
Signed-off-by: Chad Zanonie <chad.zanonie@gmail.com>
Possibility exists for an exiting application to be in between
marking its mm NULL and calling mmput when out_of_memory is
invoked. select_bad_process() will continue past this process as
opposed to returning -1UL due to its mm being NULL. This causes
the oom killer in certain scenarios to not only kill the memory
culprit, but also kill the runner up.
EXIT_DEAD seems to be the only flag that guarantees that mmput()
has finished. Checking for PF_KTHREAD should replace p->mm
regardless. Adding EXIT_DEAD to the check seems to prevent
unnecessary kills in local testing.
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 64e5b4b..ad3928a 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -216,7 +216,7 @@ static struct task_struct
*select_bad_process(unsigned long *ppoints,
* skip kernel threads and tasks which have already
released
* their mm.
*/
- if (!p->mm)
+ if (p->flags & PF_KTHREAD || p->flags & EXIT_DEAD)
continue;
/* skip the init task */
if (is_global_init(p))
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-09-29 23:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-29 23:09 [PATCH] oom-killer kills more than needed Chad Zanonie
-- strict thread matches above, loose matches on Subject: below --
2008-09-19 18:06 Chad Zanonie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®