Skip to content

Commit 2cf4528

Browse files
Frederic Weisbeckerpaulmckrcu
authored andcommitted
rcu/nocb: Create kthreads on all CPUs if "rcu_nocbs=" or "nohz_full=" are passed
In order to be able to (de-)offload any CPU using cpusets in the future, create the NOCB data structures for all possible CPUs. For now this is done only as long as the "rcu_nocbs=" or "nohz_full=" kernel parameters are passed to avoid the unnecessary overhead for most users. Note that the rcuog and rcuoc kthreads are not created until at least one of the corresponding CPUs comes online. This approach avoids the creation of excess kthreads when firmware lies about the number of CPUs present on the system. Reviewed-by: Neeraj Upadhyay <quic_neeraju@quicinc.com> Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Cc: Boqun Feng <boqun.feng@gmail.com> Cc: Uladzislau Rezki <urezki@gmail.com> Cc: Josh Triplett <josh@joshtriplett.org> Cc: Joel Fernandes <joel@joelfernandes.org> Tested-by: Juri Lelli <juri.lelli@redhat.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent a81aeaf commit 2cf4528

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

kernel/rcu/tree_nocb.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,11 +1237,8 @@ static void rcu_spawn_one_nocb_kthread(int cpu)
12371237
struct rcu_data *rdp_gp;
12381238
struct task_struct *t;
12391239

1240-
/*
1241-
* If this isn't a no-CBs CPU or if it already has an rcuo kthread,
1242-
* then nothing to do.
1243-
*/
1244-
if (!rcu_is_nocb_cpu(cpu) || rdp->nocb_cb_kthread)
1240+
/* If there already is an rcuo kthread, then nothing to do. */
1241+
if (rdp->nocb_cb_kthread)
12451242
return;
12461243

12471244
/* If we didn't spawn the GP kthread first, reorganize! */
@@ -1269,7 +1266,7 @@ static void rcu_spawn_one_nocb_kthread(int cpu)
12691266
*/
12701267
static void rcu_spawn_cpu_nocb_kthread(int cpu)
12711268
{
1272-
if (rcu_scheduler_fully_active)
1269+
if (rcu_scheduler_fully_active && rcu_nocb_is_setup)
12731270
rcu_spawn_one_nocb_kthread(cpu);
12741271
}
12751272

@@ -1319,7 +1316,7 @@ static void __init rcu_organize_nocb_kthreads(void)
13191316
* Should the corresponding CPU come online in the future, then
13201317
* we will spawn the needed set of rcu_nocb_kthread() kthreads.
13211318
*/
1322-
for_each_cpu(cpu, rcu_nocb_mask) {
1319+
for_each_possible_cpu(cpu) {
13231320
rdp = per_cpu_ptr(&rcu_data, cpu);
13241321
if (rdp->cpu >= nl) {
13251322
/* New GP kthread, set up for CBs & next GP. */
@@ -1343,7 +1340,8 @@ static void __init rcu_organize_nocb_kthreads(void)
13431340
pr_cont(" %d", cpu);
13441341
}
13451342
rdp->nocb_gp_rdp = rdp_gp;
1346-
list_add_tail(&rdp->nocb_entry_rdp, &rdp_gp->nocb_head_rdp);
1343+
if (cpumask_test_cpu(cpu, rcu_nocb_mask))
1344+
list_add_tail(&rdp->nocb_entry_rdp, &rdp_gp->nocb_head_rdp);
13471345
}
13481346
if (gotnocbs && dump_tree)
13491347
pr_cont("%s\n", gotnocbscbs ? "" : " (self only)");

0 commit comments

Comments
 (0)