Re: [PATCH tip/core/rcu 01/22] sched: Make non-production PREEMPT cond_resched() help Tasks RCU

From: Peter Zijlstra
Date: Mon Apr 23 2018 - 10:12:11 EST


On Mon, Apr 23, 2018 at 09:47:42AM -0400, Steven Rostedt wrote:
> On Mon, 23 Apr 2018 05:40:00 -0700
> "Paul E. McKenney" <paulmck@xxxxxxxxxxxxxxxxxx> wrote:
>
> > > I'm confused.. why is having this conditional on TRACEPOINT_BENCHMARK a
> > > sane idea?
> >
> > Because the TRACEPOINT_BENCHMARK tests are insane, so a similar
> > level of insanity is required to make things work. Plus having this
> > be unconditional would not be good for performance, as 0day has been
> > telling me frequently over the past couple of years.
>
> Just for some context. The tracepoint benchmark (which should never be
> enabled in any production machine), will start a thread when the
> benchmark trace event is enabled. This thread will never exit (until
> the trace event is disabled), and does a benchmark loop and constantly
> calls "cond_resched()" to allow other tasks to run. The point is, this
> thread will never have a quiescent state for task_rcu, unless we tell
> rcu that cond_resched() is a quiescent state. But this is only required
> because the tracepoint benchmark has this nasty thread, that is only
> used for debugging and benchmarking the tracepoint (during development).
>
> I also suggested having a direct call into RCU from the thread to tell
> RCU that it entered a quiescent state, but Paul didn't like that idea
> as it caused the tracepoint benchmark to call too deep into RCU
> internals.
>
> http://lkml.kernel.org/r/20180227153646.GD3777@xxxxxxxxxxxxxxxxxx

That thread using cond_resched_task_rcu_qs() seems like a _lot_ better
than having cond_resched() semantics change depending on random
!scheduler config parameters.