Re: [PATCH linux-next][RFC]torture: avoid offline tick_do_timer_cpu

From: Paul E. McKenney
Date: Wed Nov 23 2022 - 18:00:36 EST


On Wed, Nov 23, 2022 at 11:25:43PM +0100, Frederic Weisbecker wrote:
> On Mon, Nov 21, 2022 at 05:37:54PM -0800, Paul E. McKenney wrote:
> > On Mon, Nov 21, 2022 at 11:51:40AM +0800, Zhouyi Zhou wrote:
> > > @@ -358,7 +359,16 @@ torture_onoff(void *arg)
> > > schedule_timeout_interruptible(HZ / 10);
> > > continue;
> > > }
> > > +#ifdef CONFIG_NO_HZ_FULL
> > > + /* do not offline tick do timer cpu */
> > > + if (tick_nohz_full_running) {
> > > + cpu = (torture_random(&rand) >> 4) % maxcpu;
> > > + if (cpu >= tick_do_timer_cpu)
> >
> > Why is this ">=" instead of "=="?
> >
> > > + cpu = (cpu + 1) % (maxcpu + 1);
> > > + } else
> > > +#else
> > > cpu = (torture_random(&rand) >> 4) % (maxcpu + 1);
> > > +#endif
> >
> > What happens if the value of tick_do_timer_cpu changes between the time of
> > the check above and the call to torture_offline() below? Alternatively,
> > how is such a change in value prevented?
>
> It can't, currently tick_do_timer_cpu is fixed when nohz_full is running.
> It can however have special values at early boot such as TICK_DO_TIMER_NONE.
> But if rcutorture is initialized after smp, it should be ok.

Ah, getting ahead of myself, thank you for the info!

So the thing to do would be to generate only maxcpu-1 choices.

Thanx, Paul

> Thanks.
>
> >
> > Thanx, Paul
> >
> > > if (!torture_offline(cpu,
> > > &n_offline_attempts, &n_offline_successes,
> > > &sum_offline, &min_offline, &max_offline))
> > > --
> > > 2.34.1
> > >