@@ -505,12 +505,16 @@ static struct kthread_worker *pwq_release_worker __ro_after_init;
505
505
506
506
struct workqueue_struct * system_wq __ro_after_init ;
507
507
EXPORT_SYMBOL (system_wq );
508
+ struct workqueue_struct * system_percpu_wq __ro_after_init ;
509
+ EXPORT_SYMBOL (system_percpu_wq );
508
510
struct workqueue_struct * system_highpri_wq __ro_after_init ;
509
511
EXPORT_SYMBOL_GPL (system_highpri_wq );
510
512
struct workqueue_struct * system_long_wq __ro_after_init ;
511
513
EXPORT_SYMBOL_GPL (system_long_wq );
512
514
struct workqueue_struct * system_unbound_wq __ro_after_init ;
513
515
EXPORT_SYMBOL_GPL (system_unbound_wq );
516
+ struct workqueue_struct * system_dfl_wq __ro_after_init ;
517
+ EXPORT_SYMBOL_GPL (system_dfl_wq );
514
518
struct workqueue_struct * system_freezable_wq __ro_after_init ;
515
519
EXPORT_SYMBOL_GPL (system_freezable_wq );
516
520
struct workqueue_struct * system_power_efficient_wq __ro_after_init ;
@@ -1686,17 +1690,14 @@ static void __pwq_activate_work(struct pool_workqueue *pwq,
1686
1690
static bool tryinc_node_nr_active (struct wq_node_nr_active * nna )
1687
1691
{
1688
1692
int max = READ_ONCE (nna -> max );
1693
+ int old = atomic_read (& nna -> nr );
1689
1694
1690
- while (true) {
1691
- int old , tmp ;
1692
-
1693
- old = atomic_read (& nna -> nr );
1695
+ do {
1694
1696
if (old >= max )
1695
1697
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;
1700
1701
}
1701
1702
1702
1703
/**
@@ -2221,12 +2222,9 @@ static int wq_select_unbound_cpu(int cpu)
2221
2222
}
2222
2223
2223
2224
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 ;
2230
2228
__this_cpu_write (wq_rr_cpu_last , new_cpu );
2231
2229
2232
2230
return new_cpu ;
@@ -4629,7 +4627,7 @@ void free_workqueue_attrs(struct workqueue_attrs *attrs)
4629
4627
*
4630
4628
* Return: The allocated new workqueue_attr on success. %NULL on failure.
4631
4629
*/
4632
- struct workqueue_attrs * alloc_workqueue_attrs (void )
4630
+ struct workqueue_attrs * alloc_workqueue_attrs_noprof (void )
4633
4631
{
4634
4632
struct workqueue_attrs * attrs ;
4635
4633
@@ -5682,12 +5680,12 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt,
5682
5680
else
5683
5681
wq_size = sizeof (* wq );
5684
5682
5685
- wq = kzalloc (wq_size , GFP_KERNEL );
5683
+ wq = kzalloc_noprof (wq_size , GFP_KERNEL );
5686
5684
if (!wq )
5687
5685
return NULL ;
5688
5686
5689
5687
if (flags & WQ_UNBOUND ) {
5690
- wq -> unbound_attrs = alloc_workqueue_attrs ();
5688
+ wq -> unbound_attrs = alloc_workqueue_attrs_noprof ();
5691
5689
if (!wq -> unbound_attrs )
5692
5690
goto err_free_wq ;
5693
5691
}
@@ -5777,9 +5775,9 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt,
5777
5775
}
5778
5776
5779
5777
__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 , ...)
5783
5781
{
5784
5782
struct workqueue_struct * wq ;
5785
5783
va_list args ;
@@ -5794,7 +5792,7 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
5794
5792
5795
5793
return wq ;
5796
5794
}
5797
- EXPORT_SYMBOL_GPL (alloc_workqueue );
5795
+ EXPORT_SYMBOL_GPL (alloc_workqueue_noprof );
5798
5796
5799
5797
#ifdef CONFIG_LOCKDEP
5800
5798
__printf (1 , 5 )
@@ -6770,31 +6768,6 @@ long work_on_cpu_key(int cpu, long (*fn)(void *),
6770
6768
return wfc .ret ;
6771
6769
}
6772
6770
EXPORT_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 );
6798
6771
#endif /* CONFIG_SMP */
6799
6772
6800
6773
#ifdef CONFIG_FREEZER
@@ -7830,10 +7803,11 @@ void __init workqueue_init_early(void)
7830
7803
}
7831
7804
7832
7805
system_wq = alloc_workqueue ("events" , 0 , 0 );
7806
+ system_percpu_wq = alloc_workqueue ("events" , 0 , 0 );
7833
7807
system_highpri_wq = alloc_workqueue ("events_highpri" , WQ_HIGHPRI , 0 );
7834
7808
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 );
7837
7811
system_freezable_wq = alloc_workqueue ("events_freezable" ,
7838
7812
WQ_FREEZABLE , 0 );
7839
7813
system_power_efficient_wq = alloc_workqueue ("events_power_efficient" ,
@@ -7844,8 +7818,8 @@ void __init workqueue_init_early(void)
7844
7818
system_bh_wq = alloc_workqueue ("events_bh" , WQ_BH , 0 );
7845
7819
system_bh_highpri_wq = alloc_workqueue ("events_bh_highpri" ,
7846
7820
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 ||
7849
7823
!system_power_efficient_wq ||
7850
7824
!system_freezable_power_efficient_wq ||
7851
7825
!system_bh_wq || !system_bh_highpri_wq );
0 commit comments