@@ -505,12 +505,16 @@ static struct kthread_worker *pwq_release_worker __ro_after_init;
505505
506506struct workqueue_struct * system_wq __ro_after_init ;
507507EXPORT_SYMBOL (system_wq );
508+ struct workqueue_struct * system_percpu_wq __ro_after_init ;
509+ EXPORT_SYMBOL (system_percpu_wq );
508510struct workqueue_struct * system_highpri_wq __ro_after_init ;
509511EXPORT_SYMBOL_GPL (system_highpri_wq );
510512struct workqueue_struct * system_long_wq __ro_after_init ;
511513EXPORT_SYMBOL_GPL (system_long_wq );
512514struct workqueue_struct * system_unbound_wq __ro_after_init ;
513515EXPORT_SYMBOL_GPL (system_unbound_wq );
516+ struct workqueue_struct * system_dfl_wq __ro_after_init ;
517+ EXPORT_SYMBOL_GPL (system_dfl_wq );
514518struct workqueue_struct * system_freezable_wq __ro_after_init ;
515519EXPORT_SYMBOL_GPL (system_freezable_wq );
516520struct workqueue_struct * system_power_efficient_wq __ro_after_init ;
@@ -1686,17 +1690,14 @@ static void __pwq_activate_work(struct pool_workqueue *pwq,
16861690static bool tryinc_node_nr_active (struct wq_node_nr_active * nna )
16871691{
16881692 int max = READ_ONCE (nna -> max );
1693+ int old = atomic_read (& nna -> nr );
16891694
1690- while (true) {
1691- int old , tmp ;
1692-
1693- old = atomic_read (& nna -> nr );
1695+ do {
16941696 if (old >= max )
16951697 return false;
1696- tmp = atomic_cmpxchg_relaxed (& nna -> nr , old , old + 1 );
1697- if (tmp == old )
1698- return true;
1699- }
1698+ } while (!atomic_try_cmpxchg_relaxed (& nna -> nr , & old , old + 1 ));
1699+
1700+ return true;
17001701}
17011702
17021703/**
@@ -2221,12 +2222,9 @@ static int wq_select_unbound_cpu(int cpu)
22212222 }
22222223
22232224 new_cpu = __this_cpu_read (wq_rr_cpu_last );
2224- new_cpu = cpumask_next_and (new_cpu , wq_unbound_cpumask , cpu_online_mask );
2225- if (unlikely (new_cpu >= nr_cpu_ids )) {
2226- new_cpu = cpumask_first_and (wq_unbound_cpumask , cpu_online_mask );
2227- if (unlikely (new_cpu >= nr_cpu_ids ))
2228- return cpu ;
2229- }
2225+ new_cpu = cpumask_next_and_wrap (new_cpu , wq_unbound_cpumask , cpu_online_mask );
2226+ if (unlikely (new_cpu >= nr_cpu_ids ))
2227+ return cpu ;
22302228 __this_cpu_write (wq_rr_cpu_last , new_cpu );
22312229
22322230 return new_cpu ;
@@ -4629,7 +4627,7 @@ void free_workqueue_attrs(struct workqueue_attrs *attrs)
46294627 *
46304628 * Return: The allocated new workqueue_attr on success. %NULL on failure.
46314629 */
4632- struct workqueue_attrs * alloc_workqueue_attrs (void )
4630+ struct workqueue_attrs * alloc_workqueue_attrs_noprof (void )
46334631{
46344632 struct workqueue_attrs * attrs ;
46354633
@@ -5682,12 +5680,12 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt,
56825680 else
56835681 wq_size = sizeof (* wq );
56845682
5685- wq = kzalloc (wq_size , GFP_KERNEL );
5683+ wq = kzalloc_noprof (wq_size , GFP_KERNEL );
56865684 if (!wq )
56875685 return NULL ;
56885686
56895687 if (flags & WQ_UNBOUND ) {
5690- wq -> unbound_attrs = alloc_workqueue_attrs ();
5688+ wq -> unbound_attrs = alloc_workqueue_attrs_noprof ();
56915689 if (!wq -> unbound_attrs )
56925690 goto err_free_wq ;
56935691 }
@@ -5777,9 +5775,9 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt,
57775775}
57785776
57795777__printf (1 , 4 )
5780- struct workqueue_struct * alloc_workqueue (const char * fmt ,
5781- unsigned int flags ,
5782- int max_active , ...)
5778+ struct workqueue_struct * alloc_workqueue_noprof (const char * fmt ,
5779+ unsigned int flags ,
5780+ int max_active , ...)
57835781{
57845782 struct workqueue_struct * wq ;
57855783 va_list args ;
@@ -5794,7 +5792,7 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
57945792
57955793 return wq ;
57965794}
5797- EXPORT_SYMBOL_GPL (alloc_workqueue );
5795+ EXPORT_SYMBOL_GPL (alloc_workqueue_noprof );
57985796
57995797#ifdef CONFIG_LOCKDEP
58005798__printf (1 , 5 )
@@ -6770,31 +6768,6 @@ long work_on_cpu_key(int cpu, long (*fn)(void *),
67706768 return wfc .ret ;
67716769}
67726770EXPORT_SYMBOL_GPL (work_on_cpu_key );
6773-
6774- /**
6775- * work_on_cpu_safe_key - run a function in thread context on a particular cpu
6776- * @cpu: the cpu to run on
6777- * @fn: the function to run
6778- * @arg: the function argument
6779- * @key: The lock class key for lock debugging purposes
6780- *
6781- * Disables CPU hotplug and calls work_on_cpu(). The caller must not hold
6782- * any locks which would prevent @fn from completing.
6783- *
6784- * Return: The value @fn returns.
6785- */
6786- long work_on_cpu_safe_key (int cpu , long (* fn )(void * ),
6787- void * arg , struct lock_class_key * key )
6788- {
6789- long ret = - ENODEV ;
6790-
6791- cpus_read_lock ();
6792- if (cpu_online (cpu ))
6793- ret = work_on_cpu_key (cpu , fn , arg , key );
6794- cpus_read_unlock ();
6795- return ret ;
6796- }
6797- EXPORT_SYMBOL_GPL (work_on_cpu_safe_key );
67986771#endif /* CONFIG_SMP */
67996772
68006773#ifdef CONFIG_FREEZER
@@ -7830,10 +7803,11 @@ void __init workqueue_init_early(void)
78307803 }
78317804
78327805 system_wq = alloc_workqueue ("events" , 0 , 0 );
7806+ system_percpu_wq = alloc_workqueue ("events" , 0 , 0 );
78337807 system_highpri_wq = alloc_workqueue ("events_highpri" , WQ_HIGHPRI , 0 );
78347808 system_long_wq = alloc_workqueue ("events_long" , 0 , 0 );
7835- system_unbound_wq = alloc_workqueue ("events_unbound" , WQ_UNBOUND ,
7836- WQ_MAX_ACTIVE );
7809+ system_unbound_wq = alloc_workqueue ("events_unbound" , WQ_UNBOUND , WQ_MAX_ACTIVE );
7810+ system_dfl_wq = alloc_workqueue ( "events_unbound" , WQ_UNBOUND , WQ_MAX_ACTIVE );
78377811 system_freezable_wq = alloc_workqueue ("events_freezable" ,
78387812 WQ_FREEZABLE , 0 );
78397813 system_power_efficient_wq = alloc_workqueue ("events_power_efficient" ,
@@ -7844,8 +7818,8 @@ void __init workqueue_init_early(void)
78447818 system_bh_wq = alloc_workqueue ("events_bh" , WQ_BH , 0 );
78457819 system_bh_highpri_wq = alloc_workqueue ("events_bh_highpri" ,
78467820 WQ_BH | WQ_HIGHPRI , 0 );
7847- BUG_ON (!system_wq || !system_highpri_wq || !system_long_wq ||
7848- !system_unbound_wq || !system_freezable_wq ||
7821+ BUG_ON (!system_wq || !system_percpu_wq || ! system_highpri_wq || !system_long_wq ||
7822+ !system_unbound_wq || !system_freezable_wq || ! system_dfl_wq ||
78497823 !system_power_efficient_wq ||
78507824 !system_freezable_power_efficient_wq ||
78517825 !system_bh_wq || !system_bh_highpri_wq );
0 commit comments