Re: [PATCH v2 RESEND] tick/nohz: Fix cpu_is_hotpluggable() by checking with nohz subsystem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 25, 2023 at 2:58 PM Joel Fernandes <joel@xxxxxxxxxxxxxxxxx> wrote:
>
>
>
> > On Jan 24, 2023, at 7:13 PM, Zhouyi Zhou <zhouzhouyi@xxxxxxxxx> wrote:
> >
> > On Wed, Jan 25, 2023 at 6:56 AM Paul E. McKenney <paulmck@xxxxxxxxxx> wrote:
> >>
> >>> On Tue, Jan 24, 2023 at 05:31:26PM +0000, Joel Fernandes (Google) wrote:
> >>> For CONFIG_NO_HZ_FULL systems, the tick_do_timer_cpu cannot be offlined.
> >>> However, cpu_is_hotpluggable() still returns true for those CPUs. This causes
> >>> torture tests that do offlining to end up trying to offline this CPU causing
> >>> test failures. Such failure happens on all architectures.
> >>>
> >>> Fix it by asking the opinion of the nohz subsystem on whether the CPU can
> >>> be hotplugged.
> >>>
> >>> [ Apply Frederic Weisbecker feedback on refactoring tick_nohz_cpu_down(). ]
> >>>
> >>> For drivers/base/ portion:
> >>> Acked-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> >>>
> >>> Cc: Frederic Weisbecker <frederic@xxxxxxxxxx>
> >>> Cc: "Paul E. McKenney" <paulmck@xxxxxxxxxx>
> >>> Cc: Zhouyi Zhou <zhouzhouyi@xxxxxxxxx>
> >>> Cc: Will Deacon <will@xxxxxxxxxx>
> >>> Cc: Marc Zyngier <maz@xxxxxxxxxx>
> >>> Cc: rcu <rcu@xxxxxxxxxxxxxxx>
> >>> Cc: stable@xxxxxxxxxxxxxxx
> >>> Fixes: 2987557f52b9 ("driver-core/cpu: Expose hotpluggability to the rest of the kernel")
> >>> Signed-off-by: Joel Fernandes (Google) <joel@xxxxxxxxxxxxxxxxx>
> >>
> >> Queued for further review and testing, thank you both!
> >>
> >> It might be a few hours until it becomes publicly visible, but it will
> >> get there.
> > A new round of rcutorture test on fixed linux-5.15.y[3] has been
> > performed in the PPC VM of Open Source Lab of Oregon State University
> > [1], which will last about 29 hours. The test result on original
> > linux-5.15.y is at [2].
> >
> > [1] http://140.211.169.189/linux-stable-rc/tools/testing/selftests/rcutorture/res/2023.01.25-00.04.30-torture/
> > [2] http://140.211.169.189/linux-stable-rc/tools/testing/selftests/rcutorture/res/2023.01.18-13.22.39-torture/
> > [3] http://140.211.169.189/linux-stable-rc/
> >
> > Happy to benefit the community and this is a fruitful learning journey ;-)
>
> Thanks a lot Zhouyi! After testing something your reply can also optionally include:
>
> Tested-by: Zhouyi Zhou <zhouzhoui@xxxxxxxxx>
>
> Thanks.
I see. Thank Joel for your guidance and your encouragement ;-)
>
> Have fun at the university. I miss my university days.
Many thanks, I also miss my university days and days as a graduate
student [1], but I am no longer young ;-)
The open source Lab of Oregon State University lent me their VM hoping
to contribute to the open source
community, but I feel like being in university again while I am having
fun in the VM ;-)

[1] https://wiki.freebsd.org/ZhouyiZHOU

Have a nice day ;-)
Cheers
Zhouyi
>
>  - Joel
>
>
> >
> > Cheers
> > Zhouyi
> >>
> >>                                                        Thanx, Paul
> >>
> >>> ---
> >>> Sorry, resending with CC to stable.
> >>>
> >>> drivers/base/cpu.c       |  3 ++-
> >>> include/linux/tick.h     |  2 ++
> >>> kernel/time/tick-sched.c | 11 ++++++++---
> >>> 3 files changed, 12 insertions(+), 4 deletions(-)
> >>>
> >>> diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
> >>> index 55405ebf23ab..450dca235a2f 100644
> >>> --- a/drivers/base/cpu.c
> >>> +++ b/drivers/base/cpu.c
> >>> @@ -487,7 +487,8 @@ static const struct attribute_group *cpu_root_attr_groups[] = {
> >>> bool cpu_is_hotpluggable(unsigned int cpu)
> >>> {
> >>>      struct device *dev = get_cpu_device(cpu);
> >>> -     return dev && container_of(dev, struct cpu, dev)->hotpluggable;
> >>> +     return dev && container_of(dev, struct cpu, dev)->hotpluggable
> >>> +             && tick_nohz_cpu_hotpluggable(cpu);
> >>> }
> >>> EXPORT_SYMBOL_GPL(cpu_is_hotpluggable);
> >>>
> >>> diff --git a/include/linux/tick.h b/include/linux/tick.h
> >>> index bfd571f18cfd..9459fef5b857 100644
> >>> --- a/include/linux/tick.h
> >>> +++ b/include/linux/tick.h
> >>> @@ -216,6 +216,7 @@ extern void tick_nohz_dep_set_signal(struct task_struct *tsk,
> >>>                                   enum tick_dep_bits bit);
> >>> extern void tick_nohz_dep_clear_signal(struct signal_struct *signal,
> >>>                                     enum tick_dep_bits bit);
> >>> +extern bool tick_nohz_cpu_hotpluggable(unsigned int cpu);
> >>>
> >>> /*
> >>>  * The below are tick_nohz_[set,clear]_dep() wrappers that optimize off-cases
> >>> @@ -280,6 +281,7 @@ static inline void tick_nohz_full_add_cpus_to(struct cpumask *mask) { }
> >>>
> >>> static inline void tick_nohz_dep_set_cpu(int cpu, enum tick_dep_bits bit) { }
> >>> static inline void tick_nohz_dep_clear_cpu(int cpu, enum tick_dep_bits bit) { }
> >>> +static inline bool tick_nohz_cpu_hotpluggable(unsigned int cpu) { return true; }
> >>>
> >>> static inline void tick_dep_set(enum tick_dep_bits bit) { }
> >>> static inline void tick_dep_clear(enum tick_dep_bits bit) { }
> >>> diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
> >>> index 9c6f661fb436..63e3e8ebcd64 100644
> >>> --- a/kernel/time/tick-sched.c
> >>> +++ b/kernel/time/tick-sched.c
> >>> @@ -510,7 +510,7 @@ void __init tick_nohz_full_setup(cpumask_var_t cpumask)
> >>>      tick_nohz_full_running = true;
> >>> }
> >>>
> >>> -static int tick_nohz_cpu_down(unsigned int cpu)
> >>> +bool tick_nohz_cpu_hotpluggable(unsigned int cpu)
> >>> {
> >>>      /*
> >>>       * The tick_do_timer_cpu CPU handles housekeeping duty (unbound
> >>> @@ -518,8 +518,13 @@ static int tick_nohz_cpu_down(unsigned int cpu)
> >>>       * CPUs. It must remain online when nohz full is enabled.
> >>>       */
> >>>      if (tick_nohz_full_running && tick_do_timer_cpu == cpu)
> >>> -             return -EBUSY;
> >>> -     return 0;
> >>> +             return false;
> >>> +     return true;
> >>> +}
> >>> +
> >>> +static int tick_nohz_cpu_down(unsigned int cpu)
> >>> +{
> >>> +     return tick_nohz_cpu_hotpluggable(cpu) ? 0 : -EBUSY;
> >>> }
> >>>
> >>> void __init tick_nohz_init(void)
> >>> --
> >>> 2.39.1.405.gd4c25cc71f-goog
> >>>




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux