Re: [RFC] TIF_NOTIFY_RESUME, arch/*/*/*signal*.c and all such

From: Oleg Nesterov
Date: Thu Apr 26 2012 - 09:23:03 EST


On 04/25, Al Viro wrote:
>
> do_signal()
> {
> if (we have any business doing restarts)
> // note: we won't get here on subsequent calls of do_signal()
> // due to the checks above; same logics that currently prevents
> // double restarts
> set NEED_RESTART flag
> sig = get_signal_to_deliver(...)
> if (sig) {
> if (NEED_RESTART set) {
> clear NEED_RESTART
> same thing we do at that spot now - restart or EINTR
> handle_signal(...)
> ...
> return;
> }
> }
> /* no handler */
> if (test_and_clear_...(RESTORE_SIGMASK))
> set_current_blocked(&current->saved_sigmask);
> }

OK,

> and in asm glue,

Ah. So we are going to change the ret_from_sys_call-like code.

> check
> NEED_RESTART and if it's set do what we currently do for restarts on
> handlerless signal.

and probably we should clear NEED_RESTART?

OK, thanks, I am starting to understand.

However. Perhaps I missed something, but this doesn't look 100% correct.
Although even _if_ I am right I guess this is pure theoretical problem.

Suppose that we restart the syscall which returned ERESTARTNOHAND. I mean,
the task has already returned to the user-mode and CPU is going to execute
the syscall insn.

What if, say, reschedule interrupt comes before the task enters the kernel
again? The new signal can come before this task returns to the user-mode,
ret_from_intr: will notice it and it is still possible to run a signal
handler before re-entering the syscall.

No?

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/