@@ -4396,33 +4396,39 @@ rcu_boot_init_percpu_data(int cpu)
43964396
43974397#ifdef CONFIG_RCU_EXP_KTHREAD
43984398struct kthread_worker * rcu_exp_gp_kworker ;
4399- struct kthread_worker * rcu_exp_par_gp_kworker ;
44004399
4401- static void __init rcu_start_exp_gp_kworkers ( void )
4400+ static void rcu_spawn_exp_par_gp_kworker ( struct rcu_node * rnp )
44024401{
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 " ;
44054404 struct sched_param param = { .sched_priority = kthread_prio };
4405+ int rnp_index = rnp - rcu_get_root ();
44064406
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 );
44114414 return ;
44124415 }
4416+ WRITE_ONCE (rnp -> exp_kworker , kworker );
4417+ sched_setscheduler_nocheck (kworker -> task , SCHED_FIFO , & param );
4418+ }
44134419
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 );
44194428 rcu_exp_gp_kworker = NULL ;
44204429 return ;
44214430 }
4422-
44234431 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 );
44264432}
44274433
44284434static inline void rcu_alloc_par_gp_wq (void )
@@ -4431,7 +4437,11 @@ static inline void rcu_alloc_par_gp_wq(void)
44314437#else /* !CONFIG_RCU_EXP_KTHREAD */
44324438struct workqueue_struct * rcu_par_gp_wq ;
44334439
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 )
44354445{
44364446}
44374447
@@ -4442,6 +4452,17 @@ static inline void rcu_alloc_par_gp_wq(void)
44424452}
44434453#endif /* CONFIG_RCU_EXP_KTHREAD */
44444454
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+
44454466/*
44464467 * Invoked early in the CPU-online process, when pretty much all services
44474468 * are available. The incoming CPU is not present.
@@ -4490,7 +4511,7 @@ int rcutree_prepare_cpu(unsigned int cpu)
44904511 rdp -> rcu_iw_gp_seq = rdp -> gp_seq - 1 ;
44914512 trace_rcu_grace_period (rcu_state .name , rdp -> gp_seq , TPS ("cpuonl" ));
44924513 raw_spin_unlock_irqrestore_rcu_node (rnp , flags );
4493- rcu_spawn_one_boost_kthread (rnp );
4514+ rcu_spawn_rnp_kthreads (rnp );
44944515 rcu_spawn_cpu_nocb_kthread (cpu );
44954516 WRITE_ONCE (rcu_state .n_online_cpus , rcu_state .n_online_cpus + 1 );
44964517
@@ -4812,10 +4833,10 @@ static int __init rcu_spawn_gp_kthread(void)
48124833 * due to rcu_scheduler_fully_active.
48134834 */
48144835 rcu_spawn_cpu_nocb_kthread (smp_processor_id ());
4815- rcu_spawn_one_boost_kthread (rdp -> mynode );
4836+ rcu_spawn_rnp_kthreads (rdp -> mynode );
48164837 rcu_spawn_core_kthreads ();
48174838 /* Create kthread worker for expedited GPs */
4818- rcu_start_exp_gp_kworkers ();
4839+ rcu_start_exp_gp_kworker ();
48194840 return 0 ;
48204841}
48214842early_initcall (rcu_spawn_gp_kthread );
0 commit comments