Linux 6.5 Workqueues Add Automatic CPU-Intensive Detection & Monitoring

Written by Michael Larabel in Linux Kernel on 4 July 2023 at 06:13 AM EDT. 5 Comments
LINUX KERNEL
Tejun Heo last week submitted the workqueue changes for the Linux 6.5 kernel and they include an interesting addition.

The workqueue code for Linux 6.5 adds automayic CPU intensive detection and monitoring. The patch series from Tejun that's been ongoing for several months explains:
"To support per-cpu work items that may occupy the CPU for a substantial period of time, workqueue has WQ_CPU_INTENSIVE flag which exempts work items issued through the marked workqueue from concurrency management - they're started immediately and don't block other work items. While this works, it's error-prone in that a workqueue user can easily forget to set the flag or set it unnecessarily. Furthermore, the impacts of the wrong flag setting can be rather indirect and challenging to root-cause.

This patchset makes workqueue auto-detect CPU intensive work items based on CPU consumption. If a work item consumes more than the threshold (10ms by default) of CPU time, it's automatically marked as CPU intensive when it gets scheduled out which unblocks starting of pending per-cpu work items.

The mechanism isn't foolproof in that the detection delays can add up if many CPU-hogging work items are queued at the same time. However, in such situations, the bigger problem likely is the CPU being saturated with per-cpu work items and the solution would be making them UNBOUND. Future changes will make UNBOUND workqueues more attractive by improving their locality behaviors and configurability. We might eventually remove the explicit WQ_CPU_INTENSIVE flag."

So now with Linux 6.5 these heavy per-CPU work items will be excluded from concurrency management in order to avoid delaying the execution of other work items.

More details on this workqueues change for Linux 6.5 via this pull.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week