Skip to content

Commit db7ee3c

Browse files
author
Frederic Weisbecker
committed
rcu: Use kthread preferred affinity for RCU boost
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 <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]>
1 parent 4d13f43 commit db7ee3c

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

kernel/rcu/tree.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ static int rcu_scheduler_fully_active __read_mostly;
149149

150150
static void rcu_report_qs_rnp(unsigned long mask, struct rcu_node *rnp,
151151
unsigned long gps, unsigned long flags);
152-
static struct task_struct *rcu_boost_task(struct rcu_node *rnp);
153152
static void invoke_rcu_core(void);
154153
static void rcu_report_exp_rdp(struct rcu_data *rdp);
155154
static void sync_sched_exp_online_cleanup(int cpu);
@@ -5011,6 +5010,22 @@ int rcutree_prepare_cpu(unsigned int cpu)
50115010
return 0;
50125011
}
50135012

5013+
static void rcu_thread_affine_rnp(struct task_struct *t, struct rcu_node *rnp)
5014+
{
5015+
cpumask_var_t affinity;
5016+
int cpu;
5017+
5018+
if (!zalloc_cpumask_var(&affinity, GFP_KERNEL))
5019+
return;
5020+
5021+
for_each_leaf_node_possible_cpu(rnp, cpu)
5022+
cpumask_set_cpu(cpu, affinity);
5023+
5024+
kthread_affine_preferred(t, affinity);
5025+
5026+
free_cpumask_var(affinity);
5027+
}
5028+
50145029
/*
50155030
* Update kthreads affinity during CPU-hotplug changes.
50165031
*
@@ -5030,19 +5045,18 @@ static void rcutree_affinity_setting(unsigned int cpu, int outgoingcpu)
50305045
unsigned long mask;
50315046
struct rcu_data *rdp;
50325047
struct rcu_node *rnp;
5033-
struct task_struct *task_boost, *task_exp;
5048+
struct task_struct *task_exp;
50345049

50355050
rdp = per_cpu_ptr(&rcu_data, cpu);
50365051
rnp = rdp->mynode;
50375052

5038-
task_boost = rcu_boost_task(rnp);
50395053
task_exp = rcu_exp_par_gp_task(rnp);
50405054

50415055
/*
5042-
* If CPU is the boot one, those tasks are created later from early
5056+
* If CPU is the boot one, this task is created later from early
50435057
* initcall since kthreadd must be created first.
50445058
*/
5045-
if (!task_boost && !task_exp)
5059+
if (!task_exp)
50465060
return;
50475061

50485062
if (!zalloc_cpumask_var(&cm, GFP_KERNEL))
@@ -5064,9 +5078,6 @@ static void rcutree_affinity_setting(unsigned int cpu, int outgoingcpu)
50645078
if (task_exp)
50655079
set_cpus_allowed_ptr(task_exp, cm);
50665080

5067-
if (task_boost)
5068-
set_cpus_allowed_ptr(task_boost, cm);
5069-
50705081
mutex_unlock(&rnp->kthread_mutex);
50715082

50725083
free_cpumask_var(cm);

kernel/rcu/tree_plugin.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,16 +1217,13 @@ static void rcu_spawn_one_boost_kthread(struct rcu_node *rnp)
12171217
raw_spin_lock_irqsave_rcu_node(rnp, flags);
12181218
rnp->boost_kthread_task = t;
12191219
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
1220+
12201221
sp.sched_priority = kthread_prio;
12211222
sched_setscheduler_nocheck(t, SCHED_FIFO, &sp);
1223+
rcu_thread_affine_rnp(t, rnp);
12221224
wake_up_process(t); /* get to TASK_INTERRUPTIBLE quickly. */
12231225
}
12241226

1225-
static struct task_struct *rcu_boost_task(struct rcu_node *rnp)
1226-
{
1227-
return READ_ONCE(rnp->boost_kthread_task);
1228-
}
1229-
12301227
#else /* #ifdef CONFIG_RCU_BOOST */
12311228

12321229
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)
12431240
{
12441241
}
12451242

1246-
static struct task_struct *rcu_boost_task(struct rcu_node *rnp)
1247-
{
1248-
return NULL;
1249-
}
12501243
#endif /* #else #ifdef CONFIG_RCU_BOOST */
12511244

12521245
/*

0 commit comments

Comments
 (0)