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

From: Oleg Nesterov
Date: Thu Oct 15 2020 - 11:18:07 EST


On 10/15, Thomas Gleixner wrote:
>
> On Thu, Oct 15 2020 at 16:34, Oleg Nesterov wrote:
> > On 10/15, Thomas Gleixner wrote:
> >> Instead of adding this to every architectures signal magic, we can
> >> handle TIF_NOTIFY_SIGNAL in the core code:
> >>
> >> static void handle_singal_work(ti_work, regs)
> >> {
> >> if (ti_work & _TIF_NOTIFY_SIGNAL)
> >> tracehook_notify_signal();
> >>
> >> arch_do_signal(ti_work, regs);
> >> }
> >>
> >> loop {
> >> if (ti_work & (SIGPENDING | NOTIFY_SIGNAL))
> >> handle_signal_work(ti_work, regs);
> >> }
> >
> > To me this looks like unnecessary complication. We need to change
> > every architecture anyway, how can this helper help?
>
> You need to change ONE architecture because nobody else uses the common
> entry loop right now.

so we need to change other arches to use the common entry loop.

> For those who move over they have to supply
> arch_do_signal() anyway,

and this arch_do_signal() should be changed to check _TIF_SIGPENDING.



See also my replies to 3/5. I strongly disagree with CONFIG_GENERIC_ENTRY.
But even if we require CONFIG_GENERIC_ENTRY, why do we want this helper?

We can just change exit_to_user_mode_loop() to do

if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) {
if (ti_work & _TIF_NOTIFY_SIGNAL)
tracehook_notify_signal();
arch_do_signal(ti_work, regs);
}

but I'd prefer to handle SIGPENDING/NOTIFY_SIGNAL in one place.

Oleg.