Skip to content

Commit 7ab044a

Browse files
committed
Merge tag 'wq-for-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq
Pull workqueue updates from Tejun Heo: - Concurrency-managed per-cpu work items that hog CPUs and delay the execution of other work items are now automatically detected and excluded from concurrency management. Reporting on such work items can also be enabled through a config option. - Added tools/workqueue/wq_monitor.py which improves visibility into workqueue usages and behaviors. - Arnd's minimal fix for gcc-13 enum warning on 32bit compiles, superseded by commit afa4bb7 in mainline. * tag 'wq-for-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq: workqueue: Disable per-cpu CPU hog detection when wq_cpu_intensive_thresh_us is 0 workqueue: Fix WARN_ON_ONCE() triggers in worker_enter_idle() workqueue: fix enum type for gcc-13 workqueue: Track and monitor per-workqueue CPU time usage workqueue: Report work funcs that trigger automatic CPU_INTENSIVE mechanism workqueue: Automatically mark CPU-hogging work items CPU_INTENSIVE workqueue: Improve locking rule description for worker fields workqueue: Move worker_set/clr_flags() upwards workqueue: Re-order struct worker fields workqueue: Add pwq->stats[] and a monitoring script Further upgrade queue_work_on() comment
2 parents 18eb3b6 + 18c8ae8 commit 7ab044a

7 files changed

Lines changed: 499 additions & 75 deletions

File tree

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6972,6 +6972,18 @@
69726972
it can be updated at runtime by writing to the
69736973
corresponding sysfs file.
69746974

6975+
workqueue.cpu_intensive_thresh_us=
6976+
Per-cpu work items which run for longer than this
6977+
threshold are automatically considered CPU intensive
6978+
and excluded from concurrency management to prevent
6979+
them from noticeably delaying other per-cpu work
6980+
items. Default is 10000 (10ms).
6981+
6982+
If CONFIG_WQ_CPU_INTENSIVE_REPORT is set, the kernel
6983+
will report the work functions which violate this
6984+
threshold repeatedly. They are likely good
6985+
candidates for using WQ_UNBOUND workqueues instead.
6986+
69756987
workqueue.disable_numa
69766988
By default, all work items queued to unbound
69776989
workqueues are affine to the NUMA nodes they're

Documentation/core-api/workqueue.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,37 @@ Guidelines
348348
level of locality in wq operations and work item execution.
349349

350350

351+
Monitoring
352+
==========
353+
354+
Use tools/workqueue/wq_monitor.py to monitor workqueue operations: ::
355+
356+
$ tools/workqueue/wq_monitor.py events
357+
total infl CPUtime CPUhog CMwake mayday rescued
358+
events 18545 0 6.1 0 5 - -
359+
events_highpri 8 0 0.0 0 0 - -
360+
events_long 3 0 0.0 0 0 - -
361+
events_unbound 38306 0 0.1 - - - -
362+
events_freezable 0 0 0.0 0 0 - -
363+
events_power_efficient 29598 0 0.2 0 0 - -
364+
events_freezable_power_ 10 0 0.0 0 0 - -
365+
sock_diag_events 0 0 0.0 0 0 - -
366+
367+
total infl CPUtime CPUhog CMwake mayday rescued
368+
events 18548 0 6.1 0 5 - -
369+
events_highpri 8 0 0.0 0 0 - -
370+
events_long 3 0 0.0 0 0 - -
371+
events_unbound 38322 0 0.1 - - - -
372+
events_freezable 0 0 0.0 0 0 - -
373+
events_power_efficient 29603 0 0.2 0 0 - -
374+
events_freezable_power_ 10 0 0.0 0 0 - -
375+
sock_diag_events 0 0 0.0 0 0 - -
376+
377+
...
378+
379+
See the command's help message for more info.
380+
381+
351382
Debugging
352383
=========
353384

@@ -387,6 +418,7 @@ the stack trace of the offending worker thread. ::
387418
The work item's function should be trivially visible in the stack
388419
trace.
389420

421+
390422
Non-reentrance Conditions
391423
=========================
392424

kernel/sched/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5670,6 +5670,9 @@ void scheduler_tick(void)
56705670

56715671
perf_event_task_tick();
56725672

5673+
if (curr->flags & PF_WQ_WORKER)
5674+
wq_worker_tick(curr);
5675+
56735676
#ifdef CONFIG_SMP
56745677
rq->idle_balance = idle_cpu(cpu);
56755678
trigger_load_balance(rq);

0 commit comments

Comments
 (0)