Lines Matching +full:cpu +full:- +full:2
32 worker thread per CPU and a single threaded (ST) wq had one worker
33 thread system-wide. A single MT wq needed to keep around the same
35 wq users over the years and with the number of CPU cores continuously
42 worker pool. An MT wq could provide only one execution context per CPU
60 * Use per-CPU unified worker pools shared by all wq to provide
85 worker-pools.
87 The cmwq design differentiates between the user-facing workqueues that
89 which manages worker-pools and processes the queued work items.
91 There are two worker-pools, one for normal work items and the other
92 for high priority ones, for each possible CPU and some extra
93 worker-pools to serve work items queued on unbound workqueues - the
98 Each per-CPU BH worker pool contains only one pseudo worker which represents
106 things like CPU locality, concurrency limits, priority and more. To
110 When a work item is queued to a workqueue, the target worker-pool is
112 and appended on the shared worklist of the worker-pool. For example,
114 be queued on the worklist of either normal or highpri worker-pool that
115 is associated to the CPU the issuer is running on.
123 Each worker-pool bound to an actual CPU implements concurrency
124 management by hooking into the scheduler. The worker-pool is notified
127 not expected to hog a CPU and consume many cycles. That means
130 workers on the CPU, the worker-pool doesn't start execution of a new
132 schedules a new worker so that the CPU doesn't sit idle while there
152 wq's that have a rescue-worker reserved for execution under memory
153 pressure. Else it is possible that the worker-pool deadlocks waiting
162 removal. ``alloc_workqueue()`` takes three arguments - ``@name``,
173 ---------
177 workqueues are always per-CPU and all BH work items are executed in the
178 queueing CPU's softirq context in the queueing order.
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.
194 worker-pools which host workers which are not bound to any
195 specific CPU. This makes the wq behave as a simple execution
197 worker-pools try to start execution of work items as soon as
206 * Long running CPU intensive workloads which can be better
221 worker-pool of the target cpu. Highpri worker-pools are
224 Note that normal and highpri worker-pools don't interact with
229 Work items of a CPU intensive wq do not contribute to the
230 concurrency level. In other words, runnable CPU intensive
232 worker-pool from starting execution. This is useful for bound
233 work items which are expected to hog CPU cycles so that their
236 Although CPU intensive work items don't contribute to the
239 non-CPU-intensive work items can delay execution of CPU
246 --------------
249 CPU which can be assigned to the work items of a wq. For example, with
251 at the same time per CPU. This is always a per-CPU attribute, even for
278 Work items w0, w1, w2 are queued to a bound wq q0 on the same CPU.
279 w0 burns CPU for 5ms then sleeps for 10ms then burns CPU for 5ms
280 again before finishing. w1 and w2 burn CPU for 5ms then sleep for
288 0 w0 starts and burns CPU
290 15 w0 wakes up and burns CPU
292 20 w1 starts and burns CPU
295 35 w2 starts and burns CPU
302 0 w0 starts and burns CPU
304 5 w1 starts and burns CPU
306 10 w2 starts and burns CPU
308 15 w0 wakes up and burns CPU
313 If ``@max_active`` == 2, ::
316 0 w0 starts and burns CPU
318 5 w1 starts and burns CPU
320 15 w0 wakes up and burns CPU
323 20 w2 starts and burns CPU
331 0 w0 starts and burns CPU
333 5 w1 and w2 start and burn CPU
336 15 w0 wakes up and burns CPU
371 * Unless work items are expected to consume a huge amount of CPU
381 scope of "cache_shard", it will group CPUs into sub-LLC shards. A work item
383 within the same shard as the issuing CPU.
393 ``cpu``
394 CPUs are not grouped. A work item issued on one CPU is processed by a
395 worker on the same CPU. This makes unbound workqueues behave as per-cpu
400 logical threads of each physical CPU core are grouped together.
408 CPUs are grouped into sub-LLC shards of at most ``wq_cache_shard_size``
418 work item on a CPU close to the issuing CPU.
436 item starts execution, workqueue makes a best-effort attempt to ensure
455 kernel, there exists a pronounced trade-off between locality and utilization
459 the same number of consumed CPU cycles. However, higher locality may also
462 testing with dm-crypt clearly illustrates this trade-off.
464 The tests are run on a CPU with 12-cores/24-threads split across four L3
465 caches (AMD Ryzen 9 3900x). CPU clock boost is turned off for consistency.
466 ``/dev/dm-0`` is a dm-crypt device created on NVME SSD (Samsung 990 PRO) and
471 -------------------------------------------------------------
475 $ fio --filename=/dev/dm-0 --direct=1 --rw=randrw --bs=32k --ioengine=libaio \
476 --iodepth=64 --runtime=60 --numjobs=24 --time_based --group_reporting \
477 --name=iops-test-job --verify=sha512
479 There are 24 issuers, each issuing 64 IOs concurrently. ``--verify=sha512``
482 are the read bandwidths and CPU utilizations depending on different affinity
484 MiBps, and CPU util in percents.
486 .. list-table::
488 :header-rows: 1
490 * - Affinity
491 - Bandwidth (MiBps)
492 - CPU util (%)
494 * - system
495 - 1159.40 ±1.34
496 - 99.31 ±0.02
498 * - cache
499 - 1166.40 ±0.89
500 - 99.34 ±0.01
502 * - cache (strict)
503 - 1166.00 ±0.71
504 - 99.35 ±0.01
508 machine but the cache-affine ones outperform by 0.6% thanks to improved
512 Scenario 2: Fewer issuers, enough work for saturation
513 -----------------------------------------------------
517 $ fio --filename=/dev/dm-0 --direct=1 --rw=randrw --bs=32k \
518 --ioengine=libaio --iodepth=64 --runtime=60 --numjobs=8 \
519 --time_based --group_reporting --name=iops-test-job --verify=sha512
521 The only difference from the previous scenario is ``--numjobs=8``. There are
525 .. list-table::
527 :header-rows: 1
529 * - Affinity
530 - Bandwidth (MiBps)
531 - CPU util (%)
533 * - system
534 - 1155.40 ±0.89
535 - 97.41 ±0.05
537 * - cache
538 - 1154.40 ±1.14
539 - 96.15 ±0.09
541 * - cache (strict)
542 - 1112.00 ±4.64
543 - 93.26 ±0.35
547 less CPU but the better efficiency puts it at the same bandwidth as
556 -----------------------------------------------------------
560 $ fio --filename=/dev/dm-0 --direct=1 --rw=randrw --bs=32k \
561 --ioengine=libaio --iodepth=64 --runtime=60 --numjobs=4 \
562 --time_based --group_reporting --name=iops-test-job --verify=sha512
564 Again, the only difference is ``--numjobs=4``. With the number of issuers
568 .. list-table::
570 :header-rows: 1
572 * - Affinity
573 - Bandwidth (MiBps)
574 - CPU util (%)
576 * - system
577 - 993.60 ±1.82
578 - 75.49 ±0.06
580 * - cache
581 - 973.40 ±1.52
582 - 74.90 ±0.07
584 * - cache (strict)
585 - 828.20 ±4.49
586 - 66.84 ±0.29
589 2% bandwidth loss compared to "system" and "cache (struct)" whopping 20%.
593 ------------------------------
600 While the loss of work-conservation in certain scenarios hurts, it is a lot
606 that may consume a significant amount of CPU are recommended to configure
610 * An unbound workqueue with strict "cpu" affinity scope behaves the same as
611 ``WQ_CPU_INTENSIVE`` per-cpu workqueue. There is no real advanage to the
617 * The loss of work-conservation in non-strict affinity scopes is likely
620 work-conservation in most cases. As such, it is possible that future
627 Use tools/workqueue/wq_dump.py to examine unbound CPU affinity
635 CPU
637 pod_cpus [0]=00000001 [1]=00000002 [2]=00000004 [3]=00000008
638 pod_node [0]=0 [1]=0 [2]=1 [3]=1
639 cpu_pod [0]=0 [1]=1 [2]=2 [3]=3
643 pod_cpus [0]=00000001 [1]=00000002 [2]=00000004 [3]=00000008
644 pod_node [0]=0 [1]=0 [2]=1 [3]=1
645 cpu_pod [0]=0 [1]=1 [2]=2 [3]=3
648 nr_pods 2
651 cpu_pod [0]=0 [1]=0 [2]=1 [3]=1
654 nr_pods 2
657 cpu_pod [0]=0 [1]=0 [2]=1 [3]=1
662 pod_node [0]=-1
663 cpu_pod [0]=0 [1]=0 [2]=0 [3]=0
667 pool[00] ref= 1 nice= 0 idle/workers= 4/ 4 cpu= 0
668 pool[01] ref= 1 nice=-20 idle/workers= 2/ 2 cpu= 0
669 pool[02] ref= 1 nice= 0 idle/workers= 4/ 4 cpu= 1
670 pool[03] ref= 1 nice=-20 idle/workers= 2/ 2 cpu= 1
671 pool[04] ref= 1 nice= 0 idle/workers= 4/ 4 cpu= 2
672 pool[05] ref= 1 nice=-20 idle/workers= 2/ 2 cpu= 2
673 pool[06] ref= 1 nice= 0 idle/workers= 3/ 3 cpu= 3
674 pool[07] ref= 1 nice=-20 idle/workers= 2/ 2 cpu= 3
678 pool[11] ref= 1 nice=-20 idle/workers= 1/ 1 cpus=0000000f
679 pool[12] ref= 2 nice=-20 idle/workers= 1/ 1 cpus=00000003
680 pool[13] ref= 2 nice=-20 idle/workers= 1/ 1 cpus=0000000c
682 Workqueue CPU -> pool
684 [ workqueue \ CPU 0 1 2 3 dfl]
685 events percpu 0 2 4 6
687 events_long percpu 0 2 4 6
689 events_freezable percpu 0 2 4 6
690 events_power_efficient percpu 0 2 4 6
691 events_freezable_pwr_ef percpu 0 2 4 6
692 rcu_gp percpu 0 2 4 6
693 rcu_par_gp percpu 0 2 4 6
694 slub_flushwq percpu 0 2 4 6
708 events 18545 0 6.1 0 5 - -
709 events_highpri 8 0 0.0 0 0 - -
710 events_long 3 0 0.0 0 0 - -
711 events_unbound 38306 0 0.1 - 7 - -
712 events_freezable 0 0 0.0 0 0 - -
713 events_power_efficient 29598 0 0.2 0 0 - -
714 events_freezable_pwr_ef 10 0 0.0 0 0 - -
715 sock_diag_events 0 0 0.0 0 0 - -
718 events 18548 0 6.1 0 5 - -
719 events_highpri 8 0 0.0 0 0 - -
720 events_long 3 0 0.0 0 0 - -
721 events_unbound 38322 0 0.1 - 7 - -
722 events_freezable 0 0 0.0 0 0 - -
723 events_power_efficient 29603 0 0.2 0 0 - -
724 events_freezable_pwr_ef 10 0 0.0 0 0 - -
725 sock_diag_events 0 0 0.0 0 0 - -
742 root 5672 0.0 0.0 0 0 ? S 12:07 0:00 [kworker/1:2]
746 If kworkers are going crazy (using too much cpu), there are two types
750 2. A single work item that consumes lots of cpu cycles
772 Non-reentrance Conditions
775 Workqueue guarantees that a work item cannot be re-entrant if the following
779 2. No one queues the work item to another workqueue.
783 executed by at most one worker system-wide at any given time.
793 .. kernel-doc:: include/linux/workqueue.h
795 .. kernel-doc:: kernel/workqueue.c