From: Joel Fernandes <joel@joelfernandes.org>
To: Frederic Weisbecker <frederic@kernel.org>
Cc: "Paul E. McKenney" <paulmck@kernel.org>,
Zhouyi Zhou <zhouzhouyi@gmail.com>,
"moderated list:ARM/STM32 ARCHITECTURE"
<linux-arm-kernel@lists.infradead.org>,
Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
rcu <rcu@vger.kernel.org>
Subject: Re: arm64 torture test hotplug failures (offlining causes -EBUSY)
Date: Thu, 19 Jan 2023 20:25:22 +0000 [thread overview]
Message-ID: <Y8mnMiIqA8EBsiCV@google.com> (raw)
In-Reply-To: <Y8lMZ+E+pNKARLAf@lothringen>
On Thu, Jan 19, 2023 at 02:57:59PM +0100, Frederic Weisbecker wrote:
> On Wed, Jan 18, 2023 at 10:37:08PM +0000, Joel Fernandes wrote:
> >
> > That's a great idea. I found a way to do that without having to do the
> > EXPORT_SYMBOL (like in Zhouyi's patch).
> >
> > Would the following be acceptable (only build-tested)?
> >
> > I can run more tests and submit a patch:
> >
> > diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
> > index 55405ebf23ab..f73bc520b70e 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..d1cc7525240e 100644
> > --- a/kernel/time/tick-sched.c
> > +++ b/kernel/time/tick-sched.c
> > @@ -522,6 +522,11 @@ static int tick_nohz_cpu_down(unsigned int cpu)
> > return 0;
> > }
> >
> > +bool tick_nohz_cpu_hotpluggable(unsigned int cpu)
> > +{
> > + return tick_nohz_cpu_down(cpu) == 0;
> > +}
> > +
>
> Can you make it the opposite? Have tick_nohz_cpu_down() call
> tick_nohz_cpu_hotpluggable()? To avoid future accidents.
>
> Thanks.
You mean move the logic of tick_nohz_cpu_down() into
tick_nohz_cpu_hotpluggable()? That wont work because
tick_nohz_cpu_hotpluggable() returns a boolean, while tick_nohz_cpu_down(cpu)
returns an integer.
I could do something like the following and that should prevent the accident
you mentioned, which I think is that someone accidentally adds some code with
side-effects to tick_nohz_cpu_down() and ends up changing the behavior of
tick_nohz_cpu_hotpluggable(). Or was there a different accident you were
referring to?
I will submit a patch like the following, then. Thanks.
---8<-----------------------
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 4c98849577d4..7af8e33735a3 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 ba2ac1469d47..6a2e52d5f0d0 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -532,7 +532,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)
+static int tick_nohz_cpu_hotplug_ret(unsigned int cpu)
{
/*
* The tick_do_timer_cpu CPU handles housekeeping duty (unbound
@@ -544,6 +544,16 @@ static int tick_nohz_cpu_down(unsigned int cpu)
return 0;
}
+static int tick_nohz_cpu_down(unsigned int cpu)
+{
+ return tick_nohz_cpu_hotplug_ret(cpu);
+}
+
+bool tick_nohz_cpu_hotpluggable(unsigned int cpu)
+{
+ return tick_nohz_cpu_hotplug_ret(cpu) == 0;
+}
+
void __init tick_nohz_init(void)
{
int cpu, ret;
--
2.39.0.246.g2a6d74b583-goog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2023-01-19 20:26 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-16 17:03 arm64 torture test hotplug failures (offlining causes -EBUSY) Joel Fernandes
2023-01-16 18:03 ` Marc Zyngier
2023-01-16 22:43 ` Joel Fernandes
2023-01-16 18:32 ` Zhouyi Zhou
2023-01-16 22:38 ` Joel Fernandes
2023-01-17 0:15 ` Joel Fernandes
2023-01-17 0:37 ` Zhouyi Zhou
2023-01-17 1:45 ` Joel Fernandes
2023-01-17 3:15 ` Zhouyi Zhou
2023-01-17 4:34 ` Joel Fernandes
2023-01-17 11:42 ` Zhouyi Zhou
2023-01-17 19:50 ` Joel Fernandes
2023-01-18 10:15 ` Zhouyi Zhou
2023-01-18 15:51 ` Joel Fernandes
2023-01-17 4:30 ` Paul E. McKenney
2023-01-17 4:36 ` Joel Fernandes
2023-01-17 4:54 ` Paul E. McKenney
2023-01-17 20:02 ` Joel Fernandes
2023-01-17 20:42 ` Paul E. McKenney
2023-01-18 2:17 ` Joel Fernandes
2023-01-18 4:00 ` Paul E. McKenney
2023-01-18 16:51 ` Will Deacon
2023-01-18 17:56 ` Paul E. McKenney
2023-01-18 22:01 ` Joel Fernandes
2023-01-19 9:12 ` Mark Rutland
2023-01-18 22:37 ` Joel Fernandes
2023-01-18 22:39 ` Joel Fernandes
2023-01-19 0:15 ` Paul E. McKenney
2023-01-19 0:53 ` Joel Fernandes
2023-01-19 3:21 ` Zhouyi Zhou
2023-01-19 8:26 ` Joel Fernandes
2023-01-19 12:17 ` Zhouyi Zhou
2023-01-19 13:57 ` Frederic Weisbecker
2023-01-19 20:25 ` Joel Fernandes [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y8mnMiIqA8EBsiCV@google.com \
--to=joel@joelfernandes.org \
--cc=catalin.marinas@arm.com \
--cc=frederic@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
--cc=will@kernel.org \
--cc=zhouzhouyi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).