Re: [PATCH] oom: Make coredump interruptible

From: Oleg Nesterov
Date: Wed Jun 09 2010 - 15:55:24 EST

On 06/04, Oleg Nesterov wrote:
> On 06/04, KOSAKI Motohiro wrote:
> >
> > In multi threaded OOM case, we have two problematic routine, coredump
> > and vmscan. Roland's idea can only solve the former.
> >
> > But I also interest vmscan quickly exit if OOM received.
> Yes, agreed. See another email from me, MMF_ flags looks "obviously
> useful" to me.

Well. But somehow we forgot about the !coredumping case... Suppose
that select_bad_process() chooses the process P to kill and we have
other processes (not sub-threads) which share the same ->mm.

In that case I am not sure we should blindly set MMF_OOMKILL. Suppose
that we kill P and after that the "out-of-memory" condition goes away.
But its ->mm still has MMF_OOMKILL set, and it is used. Who/when will
clear this flag?

Perhaps something like below makes sense for now.


--- x/fs/exec.c
+++ x/fs/exec.c
@@ -1594,6 +1594,7 @@ static inline int zap_threads(struct tas
if (!signal_group_exit(tsk->signal)) {
mm->core_state = core_state;
+ set_bit(MMF_COREDUMP, &mm->flags);
nr = zap_process(tsk, exit_code);
--- x/fs/binfmt_elf.c
+++ x/fs/binfmt_elf.c
@@ -2028,6 +2028,9 @@ static int elf_core_dump(struct coredump
struct page *page;
int stop;

+ if (!test_bit(MMF_COREDUMP, &current->mm->flags))
+ goto end_coredump;
page = get_dump_page(addr);
if (page) {
void *kaddr = kmap(page);
--- x/mm/oom_kill.c
+++ x/mm/oom_kill.c
@@ -414,6 +414,7 @@ static void __oom_kill_task(struct task_
p->rt.time_slice = HZ;
set_tsk_thread_flag(p, TIF_MEMDIE);

+ clear_bit(MMF_COREDUMP, &p->mm->flags);
force_sig(SIGKILL, p);

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at