Re: [PATCH 2/3] ptrace_untrace: use wake_up_process() instead ofbogus signal_wake_up()

From: Oleg Nesterov
Date: Sun Feb 08 2009 - 21:45:21 EST


On 02/08, Roland McGrath wrote:
>
> > Both ptrace_stop() and do_signal_stop() pathes always take ->siglock and
> > do recalc_sigpending() after wakeup.
>
> Yes, that's true. But so what? Why is this a reason to introduce yet
> another unconditional (i.e. wrong) wake_up_process? signal_wake_up does
> the job fine, i.e. it calls wake_up_state the right way.

We are holding ->siglock, and task->state is TASK_TRACED. We can not do
the "wrong" wakeup, afaics.

And even if we forget about the unneeded TIF_SIGPENDING/kick_process,
personally I can't agree that signal_wake_up() uses wake_up_state()
more "correctly". This doesn't matter of course, but TASK_INTERRUPTIBLE
(and to some extent TASK_WAKEKILL) has nothing to do here, imho.

Of course, the tracee can already spin for ->siglock in TASK_RUNNING
when we do wake_up_process(), but this is true for signal_wake_up()
as well, and this is fine.

> For exactly the
> reasons you cited, setting TIF_SIGPENDING is both superfluous and
> harmless--its effects will happen upon resume whether it was set or not.
> So what's wrong with signal_wake_up?

Because it complicates the understanding of this code. I spent a lot
of time trying to understand this signal_wake_up().

Perhaps this is just me. But when you see the code which does something,
it is always good to understand the reason, otherwise the code at least
looks wrong.

Or, at least we can add the comment

/*
* there are no reasons for signal_wake_up(), we could
* use wake_up_state() or wake_up_process() instead.
*/
signal_wake_up(child, 1);

Oleg.

--
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/