rcu.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH rcu 0/2] RCU nocb changes for v6.17
@ 2025-07-09 10:46 neeraj.upadhyay
  2025-07-09 10:46 ` [PATCH rcu 1/2] rcu/nocb: Dump gp state even if rdp gp itself is not offloaded neeraj.upadhyay
  2025-07-09 10:46 ` [PATCH rcu 2/2] rcu/nocb: Fix possible invalid rdp's->nocb_cb_kthread pointer access neeraj.upadhyay
  0 siblings, 2 replies; 3+ messages in thread
From: neeraj.upadhyay @ 2025-07-09 10:46 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, paulmck, joelagnelf, frederic, boqun.feng, urezki,
	rostedt, mathieu.desnoyers, jiangshanlai, qiang.zhang1211,
	neeraj.iitr10, neeraj.upadhyay, Neeraj Upadhyay (AMD)

From: "Neeraj Upadhyay (AMD)" <neeraj.upadhyay@kernel.org>

Hello,

This patch series contains following updates to the RCU nocb code (rebased
on v6.16-rc3):

Frederic Weisbecker (1):
  rcu/nocb: Dump gp state even if rdp gp itself is not offloaded

Zqiang (1):
  rcu/nocb: Fix possible invalid rdp's->nocb_cb_kthread pointer access

 kernel/rcu/tree_nocb.h  | 8 +++++---
 kernel/rcu/tree_stall.h | 3 +--
 2 files changed, 6 insertions(+), 5 deletions(-)

-- 
2.40.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH rcu 1/2] rcu/nocb: Dump gp state even if rdp gp itself is not offloaded
  2025-07-09 10:46 [PATCH rcu 0/2] RCU nocb changes for v6.17 neeraj.upadhyay
@ 2025-07-09 10:46 ` neeraj.upadhyay
  2025-07-09 10:46 ` [PATCH rcu 2/2] rcu/nocb: Fix possible invalid rdp's->nocb_cb_kthread pointer access neeraj.upadhyay
  1 sibling, 0 replies; 3+ messages in thread
From: neeraj.upadhyay @ 2025-07-09 10:46 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, paulmck, joelagnelf, frederic, boqun.feng, urezki,
	rostedt, mathieu.desnoyers, jiangshanlai, qiang.zhang1211,
	neeraj.iitr10, neeraj.upadhyay, Neeraj Upadhyay (AMD)

From: Frederic Weisbecker <frederic@kernel.org>

When a stall is detected, the state of each NOCB CPU is dumped along
with the state of each NOCB group. The latter part however is
incidentally ignored if the NOCB group leader happens not to be
offloaded itself.

Fix this to make sure related precious informations aren't lost over
a stall report.

Reported-by: "Paul E. McKenney" <paulmck@kernel.org>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Reviewed-by: "Paul E. McKenney" <paulmck@kernel.org>
Signed-off-by: Neeraj Upadhyay (AMD) <neeraj.upadhyay@kernel.org>
---
 kernel/rcu/tree_nocb.h  | 3 +++
 kernel/rcu/tree_stall.h | 3 +--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
index b473ff056f49..cb29b6bb0ed4 100644
--- a/kernel/rcu/tree_nocb.h
+++ b/kernel/rcu/tree_nocb.h
@@ -1564,6 +1564,9 @@ static void show_rcu_nocb_state(struct rcu_data *rdp)
 	if (rdp->nocb_gp_rdp == rdp)
 		show_rcu_nocb_gp_state(rdp);
 
+	if (!rcu_segcblist_is_offloaded(&rdp->cblist))
+		return;
+
 	nocb_next_rdp = list_next_or_null_rcu(&rdp->nocb_gp_rdp->nocb_head_rdp,
 					      &rdp->nocb_entry_rdp,
 					      typeof(*rdp),
diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h
index 486c00536207..4fa64c959083 100644
--- a/kernel/rcu/tree_stall.h
+++ b/kernel/rcu/tree_stall.h
@@ -953,8 +953,7 @@ void show_rcu_gp_kthreads(void)
 	for_each_possible_cpu(cpu) {
 		rdp = per_cpu_ptr(&rcu_data, cpu);
 		cbs += data_race(READ_ONCE(rdp->n_cbs_invoked));
-		if (rcu_segcblist_is_offloaded(&rdp->cblist))
-			show_rcu_nocb_state(rdp);
+		show_rcu_nocb_state(rdp);
 	}
 	pr_info("RCU callbacks invoked since boot: %lu\n", cbs);
 	show_rcu_tasks_gp_kthreads();
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH rcu 2/2] rcu/nocb: Fix possible invalid rdp's->nocb_cb_kthread pointer access
  2025-07-09 10:46 [PATCH rcu 0/2] RCU nocb changes for v6.17 neeraj.upadhyay
  2025-07-09 10:46 ` [PATCH rcu 1/2] rcu/nocb: Dump gp state even if rdp gp itself is not offloaded neeraj.upadhyay
@ 2025-07-09 10:46 ` neeraj.upadhyay
  1 sibling, 0 replies; 3+ messages in thread
From: neeraj.upadhyay @ 2025-07-09 10:46 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, paulmck, joelagnelf, frederic, boqun.feng, urezki,
	rostedt, mathieu.desnoyers, jiangshanlai, qiang.zhang1211,
	neeraj.iitr10, neeraj.upadhyay, Neeraj Upadhyay (AMD)

From: Zqiang <qiang.zhang1211@gmail.com>

In the preparation stage of CPU online, if the corresponding
the rdp's->nocb_cb_kthread does not exist, will be created,
there is a situation where the rdp's rcuop kthreads creation fails,
and then de-offload this CPU's rdp, does not assign this CPU's
rdp->nocb_cb_kthread pointer, but this rdp's->nocb_gp_rdp and
rdp's->rdp_gp->nocb_gp_kthread is still valid.

This will cause the subsequent re-offload operation of this offline
CPU, which will pass the conditional check and the kthread_unpark()
will access invalid rdp's->nocb_cb_kthread pointer.

This commit therefore use rdp's->nocb_gp_kthread instead of
rdp_gp's->nocb_gp_kthread for safety check.

Signed-off-by: Zqiang <qiang.zhang1211@gmail.com>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Neeraj Upadhyay (AMD) <neeraj.upadhyay@kernel.org>
---
 kernel/rcu/tree_nocb.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
index cb29b6bb0ed4..08eb9b0e2fab 100644
--- a/kernel/rcu/tree_nocb.h
+++ b/kernel/rcu/tree_nocb.h
@@ -1146,7 +1146,6 @@ static bool rcu_nocb_rdp_offload_wait_cond(struct rcu_data *rdp)
 static int rcu_nocb_rdp_offload(struct rcu_data *rdp)
 {
 	int wake_gp;
-	struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;
 
 	WARN_ON_ONCE(cpu_online(rdp->cpu));
 	/*
@@ -1156,7 +1155,7 @@ static int rcu_nocb_rdp_offload(struct rcu_data *rdp)
 	if (!rdp->nocb_gp_rdp)
 		return -EINVAL;
 
-	if (WARN_ON_ONCE(!rdp_gp->nocb_gp_kthread))
+	if (WARN_ON_ONCE(!rdp->nocb_gp_kthread))
 		return -EINVAL;
 
 	pr_info("Offloading %d\n", rdp->cpu);
@@ -1166,7 +1165,7 @@ static int rcu_nocb_rdp_offload(struct rcu_data *rdp)
 
 	wake_gp = rcu_nocb_queue_toggle_rdp(rdp);
 	if (wake_gp)
-		wake_up_process(rdp_gp->nocb_gp_kthread);
+		wake_up_process(rdp->nocb_gp_kthread);
 
 	swait_event_exclusive(rdp->nocb_state_wq,
 			      rcu_nocb_rdp_offload_wait_cond(rdp));
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-09 10:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-09 10:46 [PATCH rcu 0/2] RCU nocb changes for v6.17 neeraj.upadhyay
2025-07-09 10:46 ` [PATCH rcu 1/2] rcu/nocb: Dump gp state even if rdp gp itself is not offloaded neeraj.upadhyay
2025-07-09 10:46 ` [PATCH rcu 2/2] rcu/nocb: Fix possible invalid rdp's->nocb_cb_kthread pointer access neeraj.upadhyay

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).