[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240117163511.88173-3-longman@redhat.com>
Date: Wed, 17 Jan 2024 11:35:05 -0500
From: Waiman Long <longman@...hat.com>
To: Tejun Heo <tj@...nel.org>,
Zefan Li <lizefan.x@...edance.com>,
Johannes Weiner <hannes@...xchg.org>,
Frederic Weisbecker <frederic@...nel.org>,
Jonathan Corbet <corbet@....net>,
"Paul E. McKenney" <paulmck@...nel.org>,
Neeraj Upadhyay <quic_neeraju@...cinc.com>,
Joel Fernandes <joel@...lfernandes.org>,
Josh Triplett <josh@...htriplett.org>,
Boqun Feng <boqun.feng@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Lai Jiangshan <jiangshanlai@...il.com>,
Zqiang <qiang.zhang1211@...il.com>,
Davidlohr Bueso <dave@...olabs.net>,
Shuah Khan <shuah@...nel.org>
Cc: cgroups@...r.kernel.org,
linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org,
rcu@...r.kernel.org,
linux-kselftest@...r.kernel.org,
Mrunal Patel <mpatel@...hat.com>,
Ryan Phillips <rphillips@...hat.com>,
Brent Rowsell <browsell@...hat.com>,
Peter Hunt <pehunt@...hat.com>,
Cestmir Kalina <ckalina@...hat.com>,
Nicolas Saenz Julienne <nsaenz@...nel.org>,
Alex Gladkov <agladkov@...hat.com>,
Marcelo Tosatti <mtosatti@...hat.com>,
Phil Auld <pauld@...hat.com>,
Paul Gortmaker <paul.gortmaker@...driver.com>,
Daniel Bristot de Oliveira <bristot@...nel.org>,
Juri Lelli <juri.lelli@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Costa Shulyupin <cshulyup@...hat.com>,
Waiman Long <longman@...hat.com>
Subject: [RFC PATCH 2/8] rcu/nocb: Prepare to change nocb cpumask from CPU-hotplug protected cpuset caller
From: Frederic Weisbecker <frederic@...nel.org>
cpusets is going to use the NOCB (de-)offloading interface while
holding hotplug lock. Therefore pull out the responsibility of protecting
against concurrent CPU-hotplug changes to the callers of
rcu_nocb_cpumask_update().
Signed-off-by: Frederic Weisbecker <frederic@...nel.org>
Cc: Zefan Li <lizefan.x@...edance.com>
Cc: Tejun Heo <tj@...nel.org>
Cc: Johannes Weiner <hannes@...xchg.org>
Cc: Paul E. McKenney <paulmck@...nel.org>
Cc: Phil Auld <pauld@...hat.com>
Cc: Nicolas Saenz Julienne <nsaenz@...nel.org>
Cc: Marcelo Tosatti <mtosatti@...hat.com>
Cc: Paul Gortmaker <paul.gortmaker@...driver.com>
Cc: Waiman Long <longman@...hat.com>
Cc: Daniel Bristot de Oliveira <bristot@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
---
kernel/rcu/rcutorture.c | 2 ++
kernel/rcu/tree_nocb.h | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 228a5488eb5e..e935152346ff 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -2139,6 +2139,7 @@ static int rcu_nocb_toggle(void *arg)
do {
r = torture_random(&rand);
cpu = (r >> 1) % (maxcpu + 1);
+ cpus_read_lock();
if (r & 0x1) {
rcu_nocb_cpumask_update(cpumask_of(cpu), true);
atomic_long_inc(&n_nocb_offload);
@@ -2146,6 +2147,7 @@ static int rcu_nocb_toggle(void *arg)
rcu_nocb_cpumask_update(cpumask_of(cpu), false);
atomic_long_inc(&n_nocb_deoffload);
}
+ cpus_read_unlock();
toggle_delay = torture_random(&rand) % toggle_fuzz + toggle_interval;
set_current_state(TASK_INTERRUPTIBLE);
schedule_hrtimeout(&toggle_delay, HRTIMER_MODE_REL);
diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
index 60b0a15ed6e2..bbcf6f4152a3 100644
--- a/kernel/rcu/tree_nocb.h
+++ b/kernel/rcu/tree_nocb.h
@@ -1301,12 +1301,13 @@ int rcu_nocb_cpumask_update(const struct cpumask *cpumask, bool offload)
int err_cpu;
cpumask_var_t saved_nocb_mask;
+ lockdep_assert_cpus_held();
+
if (!alloc_cpumask_var(&saved_nocb_mask, GFP_KERNEL))
return -ENOMEM;
cpumask_copy(saved_nocb_mask, rcu_nocb_mask);
- cpus_read_lock();
mutex_lock(&rcu_state.barrier_mutex);
for_each_cpu(cpu, cpumask) {
if (offload) {
@@ -1340,7 +1341,6 @@ int rcu_nocb_cpumask_update(const struct cpumask *cpumask, bool offload)
}
mutex_unlock(&rcu_state.barrier_mutex);
- cpus_read_unlock();
free_cpumask_var(saved_nocb_mask);
--
2.39.3
Powered by blists - more mailing lists