From: Frederic Weisbecker <frederic@kernel.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Frederic Weisbecker <frederic@kernel.org>,
"Paul E. McKenney" <paulmck@kernel.org>,
Uladzislau Rezki <urezki@gmail.com>,
Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
Joel Fernandes <joel@joelfernandes.org>,
Boqun Feng <boqun.feng@gmail.com>,
Zqiang <qiang.zhang1211@gmail.com>,
rcu@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Michal Hocko <mhocko@kernel.org>,
Vlastimil Babka <vbabka@suse.cz>
Subject: [PATCH 18/21] rcu: Use kthread preferred affinity for RCU boost
Date: Tue, 12 Nov 2024 15:22:42 +0100 [thread overview]
Message-ID: <20241112142248.20503-19-frederic@kernel.org> (raw)
In-Reply-To: <20241112142248.20503-1-frederic@kernel.org>
Now that kthreads have an infrastructure to handle preferred affinity
against CPU hotplug and housekeeping cpumask, convert RCU boost to use
it instead of handling all the constraints by itself.
Acked-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
kernel/rcu/tree.c | 27 +++++++++++++++++++--------
kernel/rcu/tree_plugin.h | 11 ++---------
2 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index b1f883fcd918..c9fd28f0f068 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -149,7 +149,6 @@ static int rcu_scheduler_fully_active __read_mostly;
static void rcu_report_qs_rnp(unsigned long mask, struct rcu_node *rnp,
unsigned long gps, unsigned long flags);
-static struct task_struct *rcu_boost_task(struct rcu_node *rnp);
static void invoke_rcu_core(void);
static void rcu_report_exp_rdp(struct rcu_data *rdp);
static void sync_sched_exp_online_cleanup(int cpu);
@@ -5008,6 +5007,22 @@ int rcutree_prepare_cpu(unsigned int cpu)
return 0;
}
+static void rcu_thread_affine_rnp(struct task_struct *t, struct rcu_node *rnp)
+{
+ cpumask_var_t affinity;
+ int cpu;
+
+ if (!zalloc_cpumask_var(&affinity, GFP_KERNEL))
+ return;
+
+ for_each_leaf_node_possible_cpu(rnp, cpu)
+ cpumask_set_cpu(cpu, affinity);
+
+ kthread_affine_preferred(t, affinity);
+
+ free_cpumask_var(affinity);
+}
+
/*
* Update kthreads affinity during CPU-hotplug changes.
*
@@ -5027,19 +5042,18 @@ static void rcutree_affinity_setting(unsigned int cpu, int outgoingcpu)
unsigned long mask;
struct rcu_data *rdp;
struct rcu_node *rnp;
- struct task_struct *task_boost, *task_exp;
+ struct task_struct *task_exp;
rdp = per_cpu_ptr(&rcu_data, cpu);
rnp = rdp->mynode;
- task_boost = rcu_boost_task(rnp);
task_exp = rcu_exp_par_gp_task(rnp);
/*
- * If CPU is the boot one, those tasks are created later from early
+ * If CPU is the boot one, this task is created later from early
* initcall since kthreadd must be created first.
*/
- if (!task_boost && !task_exp)
+ if (!task_exp)
return;
if (!zalloc_cpumask_var(&cm, GFP_KERNEL))
@@ -5061,9 +5075,6 @@ static void rcutree_affinity_setting(unsigned int cpu, int outgoingcpu)
if (task_exp)
set_cpus_allowed_ptr(task_exp, cm);
- if (task_boost)
- set_cpus_allowed_ptr(task_boost, cm);
-
mutex_unlock(&rnp->kthread_mutex);
free_cpumask_var(cm);
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 1c7cbd145d5e..223f3a02351e 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -1217,16 +1217,13 @@ static void rcu_spawn_one_boost_kthread(struct rcu_node *rnp)
raw_spin_lock_irqsave_rcu_node(rnp, flags);
rnp->boost_kthread_task = t;
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
+
sp.sched_priority = kthread_prio;
sched_setscheduler_nocheck(t, SCHED_FIFO, &sp);
+ rcu_thread_affine_rnp(t, rnp);
wake_up_process(t); /* get to TASK_INTERRUPTIBLE quickly. */
}
-static struct task_struct *rcu_boost_task(struct rcu_node *rnp)
-{
- return READ_ONCE(rnp->boost_kthread_task);
-}
-
#else /* #ifdef CONFIG_RCU_BOOST */
static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags)
@@ -1243,10 +1240,6 @@ static void rcu_spawn_one_boost_kthread(struct rcu_node *rnp)
{
}
-static struct task_struct *rcu_boost_task(struct rcu_node *rnp)
-{
- return NULL;
-}
#endif /* #else #ifdef CONFIG_RCU_BOOST */
/*
--
2.46.0
next prev parent reply other threads:[~2024-11-12 14:23 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 14:22 [PATCH 00/21] kthread: Introduce preferred affinity v5 Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 01/21] arm/bL_switcher: Use kthread_run_on_cpu() Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 02/21] x86/resctrl: " Frederic Weisbecker
2024-11-12 22:00 ` Fenghua Yu
2024-11-12 14:22 ` [PATCH 03/21] firmware: stratix10-svc: " Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 04/21] scsi: bnx2fc: Use kthread_create_on_cpu() Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 05/21] scsi: bnx2i: " Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 06/21] scsi: qedi: " Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 07/21] soc/qman: test: Use kthread_run_on_cpu() Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 08/21] kallsyms: " Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 09/21] lib: test_objpool: " Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 10/21] net: pktgen: Use kthread_create_on_cpu() Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 11/21] arm64: Keep first mismatched 32bits el0 capable CPU online through its callbacks Frederic Weisbecker
2024-11-28 16:26 ` Will Deacon
2024-11-29 22:15 ` Frederic Weisbecker
2024-12-09 16:23 ` Will Deacon
2024-11-12 14:22 ` [PATCH 12/21] sched,arm64: Handle CPU isolation on last resort fallback rq selection Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 13/21] kthread: Make sure kthread hasn't started while binding it Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 14/21] kthread: Default affine kthread to its preferred NUMA node Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 15/21] mm: Create/affine kcompactd to its preferred node Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 16/21] mm: Create/affine kswapd " Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 17/21] kthread: Implement preferred affinity Frederic Weisbecker
2024-11-12 14:22 ` Frederic Weisbecker [this message]
2024-11-12 14:22 ` [PATCH 19/21] kthread: Unify kthread_create_on_cpu() and kthread_create_worker_on_cpu() automatic format Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 20/21] treewide: Introduce kthread_run_worker[_on_cpu]() Frederic Weisbecker
2024-11-12 14:22 ` [PATCH 21/21] rcu: Use kthread preferred affinity for RCU exp kworkers Frederic Weisbecker
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=20241112142248.20503-19-frederic@kernel.org \
--to=frederic@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=boqun.feng@gmail.com \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@kernel.org \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=qiang.zhang1211@gmail.com \
--cc=rcu@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=urezki@gmail.com \
--cc=vbabka@suse.cz \
/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