Re: [PATCH] tracing/osnoise: Force quiescent states while tracing

From: Nicolas Saenz Julienne
Date: Tue Mar 01 2022 - 05:59:31 EST


On Mon, 2022-02-28 at 10:45 -0500, Steven Rostedt wrote:
> On Mon, 28 Feb 2022 15:14:23 +0100
> Nicolas Saenz Julienne <nsaenzju@xxxxxxxxxx> wrote:
>
> > @@ -1386,6 +1389,22 @@ static int run_osnoise(void)
> > osnoise_stop_tracing();
> > }
> >
> > + /*
> > + * Check if we're the only ones running on this nohz_full CPU
> > + * and that we're on a PREEMPT_RCU setup. If so, let's fake a
> > + * QS since there is no way for RCU to know we're not making
> > + * use of it.
> > + *
> > + * Otherwise it'll be done through cond_resched().
> > + */
> > + if (IS_ENABLED(CONFIG_PREEMPT_RCU) &&
> > + !housekeeping_cpu(raw_smp_processor_id(), HK_FLAG_MISC) &&
> > + tick_nohz_tick_stopped()) {
> > + local_irq_save(flags);
> > + rcu_momentary_dyntick_idle();
> > + local_irq_restore(flags);
> > + }
> > +
>
> This looks very specific and a corner case. Something that depends on how
> RCU works. This really should be in the RCU code such that if something
> changes, RCU maintainers are aware of this and can update this too.

The if statement could be relaxed to some extent (I'm looking into it ATM). I
made it more constraining to avoid the overhead for other users.

As for rcu_momentary_dyntick_idle(), I'm not the first one to use it for such
means. See multi_cpu_stop() in kernel/stop_machine.c. So I'm not sure it counts
as abusing RCU internals.

> I wonder if this is similar to what we have in trace_benchmark(). Would
> using: cond_resched_tasks_rcu_qs() work for you?

IIUC this only affects tasks_rcu, and doesn't help with regular RCU. We already
call cond_resched_tasks_rcu_qs() in osnoise when necesary, actually it was
introduced by you. :)

Thanks!

--
Nicolás Sáenz