Re: [PATCH 1/3 for 2.6.38] oom: oom_kill_process: don't set TIF_MEMDIEif !p->mm

From: David Rientjes
Date: Tue Mar 15 2011 - 15:51:43 EST


On Tue, 15 Mar 2011, Oleg Nesterov wrote:

> When I did this change I looked at 81236810226f71bd9ff77321c8e8276dae7efc61
> and the changelog says:
>
> __oom_kill_task() is called to elevate the task's timeslice and give it
> access to memory reserves so that it may quickly exit.
>
> This privilege is unnecessary, however, if the task has already detached
> its mm.
>
> Now you are saing this is pointless.
>

If you have the commit id, do a "git blame 8123681022", because I see a:

5081dde3 (Nick Piggin 2006-09-25 23:31:32 -0700 222) if (!p->mm)
5081dde3 (Nick Piggin 2006-09-25 23:31:32 -0700 223) continue;

in select_bad_process() and it's also iterating over every thread:

a49335cc (Paul Jackson 2005-09-06 15:18:09 -0700 215) do_each_thread(g, p) {

It's pointless since oom-skip-zombies-when-iterating-tasklist.patch in
-mm reintroduced the filter for !p->mm in select_bad_process() which was
still there when 81236810 was merged; it's a small optimization, though,
to avoid races where the mm becomes detached between the process'
selection in select_bad_process() and its kill in oom_kill_process().

> The problem is, we can't trust per-thread PF_EXITING checks. But I guess
> we will discuss this more anyway.
>

My approach, as you saw with
oom-avoid-deferring-oom-killer-if-exiting-task-is-being-traced.patch in
-mm is to add exceptions to the oom killer when we can't trust that
PF_EXITING will soon be exiting. I think that's a much more long-term
maintainable solution instead of inferring the status of a thread based on
external circumstances (such as number of threads in the thread group)
that could easily change out from under us and once again break the oom
killer.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/