Messages in this thread | | | Date | Tue, 1 Jun 2010 22:18:43 +0200 | From | Oleg Nesterov <> | Subject | Re: [PATCH 2/5] oom: select_bad_process: PF_EXITING check should take ->mm into account |
| |
On 06/01, KOSAKI Motohiro wrote: > > > I'd like to add a note... with or without this, we have problems > > with the coredump. A thread participating in the coredumping > > (group-leader in this case) can have PF_EXITING && mm, but this doesn't > > mean it is going to exit soon, and the dumper can use a lot more memory. > > Sure. I think coredump sould do nothing if oom occur. > So, merely making PF_COREDUMP is bad idea? I mean > > task-flags allocator > ------------------------------------------------ > none N/A > TIF_MEMDIE allow to use emergency memory. > don't call page reclaim. > PF_COREDUMP N/A > TIF_MEMDIE+PF_COREDUMP disallow to use emergency memory. > don't call page reclaim. > > In other word, coredump path makes allocation failure if the task > marked as TIF_MEMDIE.
Perhaps... But where should TIF_MEMDIE go this case? Let me clarify.
Two threads, group-leader L and its sub-thread T. T dumps the code. In this case both threads have ->mm != NULL, L has PF_EXITING.
The first problem is, select_bad_process() always return -1 in this case (even if the caller is T, this doesn't matter).
The second problem is that we should add TIF_MEMDIE to T, not L.
This is more or less easy. For simplicity, let's suppose we removed this PF_EXITING check from select_bad_process().
Otoh, if we make do_coredump() interruptible (and we should do this in any case), then perhaps the TIF_MEMDIE+PF_COREDUMP is not really needed? Afaics we always send SIGKILL along with TIF_MEMDIE.
> > And, as it was already discussed, we only check the group-leader here. > > But I can't suggest something better. > > I guess signal_group_exit() is enough in practical case.
Unlike SIGNAL_GROUP_EXIT check, signal_group_exit() can also mean exec. This is probably correct. If we see the task inside de_thread() he is going to free its old mm soon.
The problem is this check doesn't cover the case when a single-threaded task exits (even if it does sys_exit_group). And it is not enough to remove the thread_group_empty-case-optimization from do_group_exit(), it can call sys_exit() instead.
But anyway I agree, select_bad_process can probably check
signal_group_exit() || (PF_EXITINF && thread_group_empty())
And in that case it is better to remove the "&& p->mm" part of the current check.
Oleg.
| |