Re: [PATCH v2] kernel/signal: Signal-based pre-coredump notification

From: Oleg Nesterov
Date: Wed Oct 24 2018 - 09:52:24 EST


On 10/23, Enke Chen wrote:
>
> >> + /*
> >> + * Send the pre-coredump signal to the parent if requested.
> >> + */
> >> + read_lock(&tasklist_lock);
> >> + notify = do_notify_parent_predump(current);
> >> + read_unlock(&tasklist_lock);
> >> + if (notify)
> >> + cond_resched();
> >
> > Hmm. I do not understand why do we need cond_resched(). And even if we need it,
> > why we can't call it unconditionally?
>
> Remember the goal is to allow the parent (e.g., a process manager) to take early
> action. The "yield" before doing coredump will help.

I don't see how can it actually help...

cond_resched() is nop if CONFIG_PREEMPT or should_resched() == 0.

and the coredumping thread will certainly need to sleep/wait anyway.

> > And once again, SIGCHLD/SIGUSR do not queue, this means that PR_SET_PREDUMP_SIG
> > is pointless if you have 2 or more children.
>
> Hmm, could you point me to the code where SIGCHLD/SIGUSR is treated differently
> w.r.t. queuing? That does not sound right to me.

see the legacy_queue() check. Any signal < SIGRTMIN do not queue. IOW, if SIGCHLD
is already pending, then next SIGCHLD is simply ignored.

Oleg.