[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAABZP2yDMTKqkj6r+hsQb=3zdoXOWMQ8Z3QKSxaaVTWv2eS-kw@mail.gmail.com>
Date: Thu, 24 Nov 2022 10:18:51 +0800
From: Zhouyi Zhou <zhouzhouyi@...il.com>
To: Frederic Weisbecker <frederic@...nel.org>
Cc: fweisbec@...il.com, tglx@...utronix.de, mingo@...nel.org,
dave@...olabs.net, paulmck@...nel.org, josh@...htriplett.org,
mpe@...erman.id.au, linuxppc-dev@...ts.ozlabs.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH linux-next][RFC]torture: avoid offline tick_do_timer_cpu
On Thu, Nov 24, 2022 at 6:37 AM Frederic Weisbecker <frederic@...nel.org> wrote:
>
> On Mon, Nov 21, 2022 at 11:51:40AM +0800, Zhouyi Zhou wrote:
> > During CPU-hotplug torture (CONFIG_NO_HZ_FULL=y), if we try to
> > offline tick_do_timer_cpu, the operation will fail because in
> > function tick_nohz_cpu_down:
> > ```
> > if (tick_nohz_full_running && tick_do_timer_cpu == cpu)
> > return -EBUSY;
> > ```
> > Above bug was first discovered in torture tests performed in PPC VM
> > of Open Source Lab of Oregon State University, and reproducable in RISC-V
> > and X86-64 (with additional kernel commandline cpu0_hotplug).
> >
> > In this patch, we avoid offline tick_do_timer_cpu by distribute
> > the offlining cpu among remaining cpus.
> >
> > Signed-off-by: Zhouyi Zhou <zhouzhouyi@...il.com>
> > ---
> > include/linux/tick.h | 1 +
> > kernel/time/tick-common.c | 1 +
> > kernel/time/tick-internal.h | 1 -
> > kernel/torture.c | 10 ++++++++++
> > 4 files changed, 12 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/linux/tick.h b/include/linux/tick.h
> > index bfd571f18cfd..23cc0b205853 100644
> > --- a/include/linux/tick.h
> > +++ b/include/linux/tick.h
> > @@ -14,6 +14,7 @@
> > #include <linux/rcupdate.h>
> >
> > #ifdef CONFIG_GENERIC_CLOCKEVENTS
> > +extern int tick_do_timer_cpu __read_mostly;
> > extern void __init tick_init(void);
> > /* Should be core only, but ARM BL switcher requires it */
> > extern void tick_suspend_local(void);
> > diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
> > index 46789356f856..87b9b9afa320 100644
> > --- a/kernel/time/tick-common.c
> > +++ b/kernel/time/tick-common.c
> > @@ -48,6 +48,7 @@ ktime_t tick_next_period;
> > * procedure also covers cpu hotplug.
> > */
> > int tick_do_timer_cpu __read_mostly = TICK_DO_TIMER_BOOT;
> > +EXPORT_SYMBOL_GPL(tick_do_timer_cpu);
>
> Please rather make a function for this. This is an internal value
> that we don't want to expose to modules.
>
> This can be:
>
> int tick_nohz_full_timekeeper(void)
> {
> if (tick_nohz_full_enabled() && tick_do_timer_cpu >= 0)
> return tick_do_timer_cpu;
> else
> return nr_cpu_ids;
> }
>
> And then just check if the value is below nr_cpu_ids.
Thank Paul and Frederic both for your guidance!
Things are much easier;-) and I will do it.
Cheers
Zhouyi
>
> Thanks.
Powered by blists - more mailing lists