Re: [RFC][PATCH 6/7] context_tracking: Provide SMP ordering using RCU

Peter Zijlstra
2021-09-22T19:48:26Z

On Wed, Sep 22, 2021 at 09:33:43PM +0200, Peter Zijlstra wrote:

> Anyway, lemme see if I get your proposal; lets say the counter starts at
> 0 and is in kernel space.
>
> 0x00(0) - kernel
> 0x02(2) - user
> 0x04(0) - kernel
>
> So far so simple, then NMI on top of that goes:
>
> 0x00(0) - kernel
> 0x03(3) - kernel + nmi
> 0x04(0) - kernel
> 0x06(2) - user
> 0x09(1) - user + nmi
> 0x0a(2) - user
>
> Which then gives us:
>
> (0) := kernel
> (1) := nmi-from-user
> (2) := user
> (3) := nmi-from-kernel
>
> Which should work I suppose. But like I said above, I'd be happier if
> this counter would live in context_tracking rather than RCU.

Furthermore, if we have this counter, the we can also do things like:

seq = context_tracking_seq_cpu(that_cpu);
if ((seq & 3) != USER)
// nohz_fail, do something
set_tsk_thread_flag(curr_task(that_cpu), TIF_DO_SOME_WORK);
if (seq == context_tracking_seq_cpu(that_cpu))
// success!!

To remotely set pending state. Allowing yet more NOHZ_FULL fixes, like,
for example, eliding the text_poke IPIs.