@@ -4396,33 +4396,39 @@ rcu_boot_init_percpu_data(int cpu)
4396
4396
4397
4397
#ifdef CONFIG_RCU_EXP_KTHREAD
4398
4398
struct kthread_worker * rcu_exp_gp_kworker ;
4399
- struct kthread_worker * rcu_exp_par_gp_kworker ;
4400
4399
4401
- static void __init rcu_start_exp_gp_kworkers ( void )
4400
+ static void rcu_spawn_exp_par_gp_kworker ( struct rcu_node * rnp )
4402
4401
{
4403
- const char * par_gp_kworker_name = "rcu_exp_par_gp_kthread_worker" ;
4404
- const char * gp_kworker_name = "rcu_exp_gp_kthread_worker " ;
4402
+ struct kthread_worker * kworker ;
4403
+ const char * name = "rcu_exp_par_gp_kthread_worker/%d " ;
4405
4404
struct sched_param param = { .sched_priority = kthread_prio };
4405
+ int rnp_index = rnp - rcu_get_root ();
4406
4406
4407
- rcu_exp_gp_kworker = kthread_create_worker (0 , gp_kworker_name );
4408
- if (IS_ERR_OR_NULL (rcu_exp_gp_kworker )) {
4409
- pr_err ("Failed to create %s!\n" , gp_kworker_name );
4410
- rcu_exp_gp_kworker = NULL ;
4407
+ if (rnp -> exp_kworker )
4408
+ return ;
4409
+
4410
+ kworker = kthread_create_worker (0 , name , rnp_index );
4411
+ if (IS_ERR_OR_NULL (kworker )) {
4412
+ pr_err ("Failed to create par gp kworker on %d/%d\n" ,
4413
+ rnp -> grplo , rnp -> grphi );
4411
4414
return ;
4412
4415
}
4416
+ WRITE_ONCE (rnp -> exp_kworker , kworker );
4417
+ sched_setscheduler_nocheck (kworker -> task , SCHED_FIFO , & param );
4418
+ }
4413
4419
4414
- rcu_exp_par_gp_kworker = kthread_create_worker (0 , par_gp_kworker_name );
4415
- if (IS_ERR_OR_NULL (rcu_exp_par_gp_kworker )) {
4416
- pr_err ("Failed to create %s!\n" , par_gp_kworker_name );
4417
- rcu_exp_par_gp_kworker = NULL ;
4418
- kthread_destroy_worker (rcu_exp_gp_kworker );
4420
+ static void __init rcu_start_exp_gp_kworker (void )
4421
+ {
4422
+ const char * name = "rcu_exp_gp_kthread_worker" ;
4423
+ struct sched_param param = { .sched_priority = kthread_prio };
4424
+
4425
+ rcu_exp_gp_kworker = kthread_create_worker (0 , name );
4426
+ if (IS_ERR_OR_NULL (rcu_exp_gp_kworker )) {
4427
+ pr_err ("Failed to create %s!\n" , name );
4419
4428
rcu_exp_gp_kworker = NULL ;
4420
4429
return ;
4421
4430
}
4422
-
4423
4431
sched_setscheduler_nocheck (rcu_exp_gp_kworker -> task , SCHED_FIFO , & param );
4424
- sched_setscheduler_nocheck (rcu_exp_par_gp_kworker -> task , SCHED_FIFO ,
4425
- & param );
4426
4432
}
4427
4433
4428
4434
static inline void rcu_alloc_par_gp_wq (void )
@@ -4431,7 +4437,11 @@ static inline void rcu_alloc_par_gp_wq(void)
4431
4437
#else /* !CONFIG_RCU_EXP_KTHREAD */
4432
4438
struct workqueue_struct * rcu_par_gp_wq ;
4433
4439
4434
- static void __init rcu_start_exp_gp_kworkers (void )
4440
+ static void rcu_spawn_exp_par_gp_kworker (struct rcu_node * rnp )
4441
+ {
4442
+ }
4443
+
4444
+ static void __init rcu_start_exp_gp_kworker (void )
4435
4445
{
4436
4446
}
4437
4447
@@ -4442,6 +4452,17 @@ static inline void rcu_alloc_par_gp_wq(void)
4442
4452
}
4443
4453
#endif /* CONFIG_RCU_EXP_KTHREAD */
4444
4454
4455
+ static void rcu_spawn_rnp_kthreads (struct rcu_node * rnp )
4456
+ {
4457
+ if ((IS_ENABLED (CONFIG_RCU_EXP_KTHREAD ) ||
4458
+ IS_ENABLED (CONFIG_RCU_BOOST )) && rcu_scheduler_fully_active ) {
4459
+ mutex_lock (& rnp -> kthread_mutex );
4460
+ rcu_spawn_one_boost_kthread (rnp );
4461
+ rcu_spawn_exp_par_gp_kworker (rnp );
4462
+ mutex_unlock (& rnp -> kthread_mutex );
4463
+ }
4464
+ }
4465
+
4445
4466
/*
4446
4467
* Invoked early in the CPU-online process, when pretty much all services
4447
4468
* are available. The incoming CPU is not present.
@@ -4490,7 +4511,7 @@ int rcutree_prepare_cpu(unsigned int cpu)
4490
4511
rdp -> rcu_iw_gp_seq = rdp -> gp_seq - 1 ;
4491
4512
trace_rcu_grace_period (rcu_state .name , rdp -> gp_seq , TPS ("cpuonl" ));
4492
4513
raw_spin_unlock_irqrestore_rcu_node (rnp , flags );
4493
- rcu_spawn_one_boost_kthread (rnp );
4514
+ rcu_spawn_rnp_kthreads (rnp );
4494
4515
rcu_spawn_cpu_nocb_kthread (cpu );
4495
4516
WRITE_ONCE (rcu_state .n_online_cpus , rcu_state .n_online_cpus + 1 );
4496
4517
@@ -4812,10 +4833,10 @@ static int __init rcu_spawn_gp_kthread(void)
4812
4833
* due to rcu_scheduler_fully_active.
4813
4834
*/
4814
4835
rcu_spawn_cpu_nocb_kthread (smp_processor_id ());
4815
- rcu_spawn_one_boost_kthread (rdp -> mynode );
4836
+ rcu_spawn_rnp_kthreads (rdp -> mynode );
4816
4837
rcu_spawn_core_kthreads ();
4817
4838
/* Create kthread worker for expedited GPs */
4818
- rcu_start_exp_gp_kworkers ();
4839
+ rcu_start_exp_gp_kworker ();
4819
4840
return 0 ;
4820
4841
}
4821
4842
early_initcall (rcu_spawn_gp_kthread );
0 commit comments