Re: [PATCH v3 tip/core/rcu 3/9] rcu: Add synchronous grace-period waiting for RCU-tasks

Peter Zijlstra
2014-08-06T08:47:41Z

[-- Attachment #1: Type: text/plain, Size: 2059 bytes --]

On Tue, Aug 05, 2014 at 06:21:39PM -0700, Paul E. McKenney wrote:
> > Yeah, idle threads can be affected by the trampolines. That is, we can
> > still hook a trampoline to some function in the idle loop.
> >
> > But we should be able to make the hardware call that puts the CPU to
> > sleep a quiescent state too. May need to be arch dependent. :-/
>
> OK, my plan for this eventuality is to do the following:
>
> 1. Ignore the ->on_rq field, as idle tasks are always on a runqueue.
>
> 2. Watch the context-switch counter.
>
> 3. Ignore dyntick-idle state for idle tasks.
>
> 4. If there is no quiescent state from a given idle task after
> a few seconds, schedule rcu_tasks_kthread() on top of the
> offending CPU.
>
> Your idea is an interesting one, but does require another set of
> dyntick-idle-like functions and counters. Or moving the current
> rcu_idle_enter() and rcu_idle_exit() calls deeper into the idle loop.
>
> Not sure which is a better approach. Alternatively, we could just
> rely on #4 above, on the grounds that battery life should not be
> too badly degraded by the occasional RCU-tasks interference.
>
> Note that this is a different situation than NO_HZ_FULL in realtime
> environments, where the worst case causes trouble even if it happens
> very infrequently.

Or you could shoot all CPUs with resched_cpu() which would have them
cycle through schedule() even if there's nothing but the idle thread to
run. That guarantees they'll go to sleep again in a !trampoline.

But I still very much hate the polling stuff...

Can't we abuse the preempt notifiers? Say we make it possible to install
preemption notifiers cross-task, then the task-rcu can install a
preempt-out notifier which completes the rcu-task wait.

After all, since we tagged it it was !running, and being scheduled out
means it ran (once) and therefore isn't on a trampoline anymore.

And the tick, which checks to see if the task got to userspace can do
the same, remove the notifier and then complete.

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]