Skip to content

Commit f11113d

Browse files
committed
Merge branch 'WQ_PERCPU' into for-6.17
2 parents fda6add + 930c2ea commit f11113d

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

Documentation/core-api/workqueue.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ resources, scheduled and executed.
183183
BH work items cannot sleep. All other features such as delayed queueing,
184184
flushing and canceling are supported.
185185

186+
``WQ_PERCPU``
187+
Work items queued to a per-cpu wq are bound to a specific CPU.
188+
This flag is the right choice when cpu locality is important.
189+
190+
This flag is the complement of ``WQ_UNBOUND``.
191+
186192
``WQ_UNBOUND``
187193
Work items queued to an unbound wq are served by the special
188194
worker-pools which host workers which are not bound to any

include/linux/workqueue.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ enum wq_flags {
402402
* http://thread.gmane.org/gmane.linux.kernel/1480396
403403
*/
404404
WQ_POWER_EFFICIENT = 1 << 7,
405+
WQ_PERCPU = 1 << 8, /* bound to a specific cpu */
405406

406407
__WQ_DESTROYING = 1 << 15, /* internal: workqueue is destroying */
407408
__WQ_DRAINING = 1 << 16, /* internal: workqueue is draining */
@@ -428,7 +429,7 @@ enum wq_consts {
428429
/*
429430
* System-wide workqueues which are always present.
430431
*
431-
* system_wq is the one used by schedule[_delayed]_work[_on]().
432+
* system_percpu_wq is the one used by schedule[_delayed]_work[_on]().
432433
* Multi-CPU multi-threaded. There are users which expect relatively
433434
* short queue flush time. Don't queue works which can run for too
434435
* long.
@@ -439,7 +440,7 @@ enum wq_consts {
439440
* system_long_wq is similar to system_wq but may host long running
440441
* works. Queue flushing might take relatively long.
441442
*
442-
* system_unbound_wq is unbound workqueue. Workers are not bound to
443+
* system_dfl_wq is unbound workqueue. Workers are not bound to
443444
* any specific CPU, not concurrency managed, and all queued works are
444445
* executed immediately as long as max_active limit is not reached and
445446
* resources are available.
@@ -456,10 +457,12 @@ enum wq_consts {
456457
* system_bh[_highpri]_wq are convenience interface to softirq. BH work items
457458
* are executed in the queueing CPU's BH context in the queueing order.
458459
*/
459-
extern struct workqueue_struct *system_wq;
460+
extern struct workqueue_struct *system_wq; /* use system_percpu_wq, this will be removed */
461+
extern struct workqueue_struct *system_percpu_wq;
460462
extern struct workqueue_struct *system_highpri_wq;
461463
extern struct workqueue_struct *system_long_wq;
462464
extern struct workqueue_struct *system_unbound_wq;
465+
extern struct workqueue_struct *system_dfl_wq;
463466
extern struct workqueue_struct *system_freezable_wq;
464467
extern struct workqueue_struct *system_power_efficient_wq;
465468
extern struct workqueue_struct *system_freezable_power_efficient_wq;

kernel/workqueue.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,12 +505,16 @@ static struct kthread_worker *pwq_release_worker __ro_after_init;
505505

506506
struct workqueue_struct *system_wq __ro_after_init;
507507
EXPORT_SYMBOL(system_wq);
508+
struct workqueue_struct *system_percpu_wq __ro_after_init;
509+
EXPORT_SYMBOL(system_percpu_wq);
508510
struct workqueue_struct *system_highpri_wq __ro_after_init;
509511
EXPORT_SYMBOL_GPL(system_highpri_wq);
510512
struct workqueue_struct *system_long_wq __ro_after_init;
511513
EXPORT_SYMBOL_GPL(system_long_wq);
512514
struct workqueue_struct *system_unbound_wq __ro_after_init;
513515
EXPORT_SYMBOL_GPL(system_unbound_wq);
516+
struct workqueue_struct *system_dfl_wq __ro_after_init;
517+
EXPORT_SYMBOL_GPL(system_dfl_wq);
514518
struct workqueue_struct *system_freezable_wq __ro_after_init;
515519
EXPORT_SYMBOL_GPL(system_freezable_wq);
516520
struct workqueue_struct *system_power_efficient_wq __ro_after_init;
@@ -7826,10 +7830,11 @@ void __init workqueue_init_early(void)
78267830
}
78277831

78287832
system_wq = alloc_workqueue("events", 0, 0);
7833+
system_percpu_wq = alloc_workqueue("events", 0, 0);
78297834
system_highpri_wq = alloc_workqueue("events_highpri", WQ_HIGHPRI, 0);
78307835
system_long_wq = alloc_workqueue("events_long", 0, 0);
7831-
system_unbound_wq = alloc_workqueue("events_unbound", WQ_UNBOUND,
7832-
WQ_MAX_ACTIVE);
7836+
system_unbound_wq = alloc_workqueue("events_unbound", WQ_UNBOUND, WQ_MAX_ACTIVE);
7837+
system_dfl_wq = alloc_workqueue("events_unbound", WQ_UNBOUND, WQ_MAX_ACTIVE);
78337838
system_freezable_wq = alloc_workqueue("events_freezable",
78347839
WQ_FREEZABLE, 0);
78357840
system_power_efficient_wq = alloc_workqueue("events_power_efficient",
@@ -7840,8 +7845,8 @@ void __init workqueue_init_early(void)
78407845
system_bh_wq = alloc_workqueue("events_bh", WQ_BH, 0);
78417846
system_bh_highpri_wq = alloc_workqueue("events_bh_highpri",
78427847
WQ_BH | WQ_HIGHPRI, 0);
7843-
BUG_ON(!system_wq || !system_highpri_wq || !system_long_wq ||
7844-
!system_unbound_wq || !system_freezable_wq ||
7848+
BUG_ON(!system_wq || !system_percpu_wq|| !system_highpri_wq || !system_long_wq ||
7849+
!system_unbound_wq || !system_freezable_wq || !system_dfl_wq ||
78457850
!system_power_efficient_wq ||
78467851
!system_freezable_power_efficient_wq ||
78477852
!system_bh_wq || !system_bh_highpri_wq);

0 commit comments

Comments
 (0)