Re: [PATCH 4/5] x86: wire up TIF_NOTIFY_SIGNAL

Thomas Gleixner
2020-10-16T13:07:20Z

On Fri, Oct 16 2020 at 12:54, Oleg Nesterov wrote:
> On 10/16, Thomas Gleixner wrote:
>
> But again, I won't argue. And to remind, we do not really need to touch
> arch_do_signal() at all. We can just add
>
> if (test_thread_flag(TIF_NOTIFY_SIGNAL))
> tracehook_notify_signal();
>
> if (!task_sigpending(current))
> return 0;
>
> at the start of get_signal() and avoid the code duplication automatically.

That works as well and is smart, but it's completely non obvious while

if (ti_work & _TIF_NOTIFY_SIGNAL)
tracehook_notify_signal();

arch_do_signal_or_restart(ti_work & _TIF_SIGPENDING);

makes it entirely clear to follow the logic and it just operates on
cached ti_work.

You can still do this for the non generic entry architectures:

if (!IS_ENABLED(CONFIG_GENERIC_ENTRY) &&
(test_thread_flag(TIF_NOTIFY_SIGNAL))
tracehook_notify_signal();

to avoid the churn in arch/*.

Thanks,

tglx