RCU nocb changes for v6.17
[email protected]
maintainercover RCU nocb changes for v6.17
From: "Neeraj Upadhyay (AMD)" <[email protected]>
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(-)
Signature · 1 line
2.40.1
[email protected]
maintainerPATCH 1/2 rcu/nocb: Dump gp state even if rdp gp itself is not offloaded
From: Frederic Weisbecker <[email protected]>
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.
--- kernel/rcu/tree_nocb.h | 3 +++ kernel/rcu/tree_stall.h | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-)
kernel/rcu/tree_nocb.h +3 -0
@@ -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),
kernel/rcu/tree_stall.h +1 -2
@@ -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 ();
Signature · 1 line
2.40.1
[email protected]
maintainerPATCH 2/2 rcu/nocb: Fix possible invalid rdp's->nocb_cb_kthread pointer access
In reply to [email protected]From: Zqiang <[email protected]>
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.
--- kernel/rcu/tree_nocb.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/rcu/tree_nocb.h +2 -3
@@ -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));
Signature · 1 line
2.40.1