Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'wq-for-6.5-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq

Pull workqueue fixes from Tejun Heo:

- The recently added cpu_intensive auto detection and warning mechanism
was spuriously triggered on slow CPUs.

While not causing serious issues, it's still a nuisance and can cause
unintended concurrency management behaviors.

Relax the threshold on machines with lower BogoMIPS. While BogoMIPS
is not an accurate measure of performance by most measures, we don't
have to be accurate and it has rough but strong enough correlation.

- A correction in Kconfig help text

* tag 'wq-for-6.5-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
workqueue: Scale up wq_cpu_intensive_thresh_us if BogoMIPS is below 4000
workqueue: Fix cpu_intensive_thresh_us name in help text

+43 -2
+42 -1
kernel/workqueue.c
··· 52 52 #include <linux/sched/debug.h> 53 53 #include <linux/nmi.h> 54 54 #include <linux/kvm_para.h> 55 + #include <linux/delay.h> 55 56 56 57 #include "workqueue_internal.h" 57 58 ··· 339 338 * Per-cpu work items which run for longer than the following threshold are 340 339 * automatically considered CPU intensive and excluded from concurrency 341 340 * management to prevent them from noticeably delaying other per-cpu work items. 341 + * ULONG_MAX indicates that the user hasn't overridden it with a boot parameter. 342 + * The actual value is initialized in wq_cpu_intensive_thresh_init(). 342 343 */ 343 - static unsigned long wq_cpu_intensive_thresh_us = 10000; 344 + static unsigned long wq_cpu_intensive_thresh_us = ULONG_MAX; 344 345 module_param_named(cpu_intensive_thresh_us, wq_cpu_intensive_thresh_us, ulong, 0644); 345 346 346 347 static bool wq_disable_numa; ··· 6516 6513 !system_freezable_power_efficient_wq); 6517 6514 } 6518 6515 6516 + static void __init wq_cpu_intensive_thresh_init(void) 6517 + { 6518 + unsigned long thresh; 6519 + unsigned long bogo; 6520 + 6521 + /* if the user set it to a specific value, keep it */ 6522 + if (wq_cpu_intensive_thresh_us != ULONG_MAX) 6523 + return; 6524 + 6525 + /* 6526 + * The default of 10ms is derived from the fact that most modern (as of 6527 + * 2023) processors can do a lot in 10ms and that it's just below what 6528 + * most consider human-perceivable. However, the kernel also runs on a 6529 + * lot slower CPUs including microcontrollers where the threshold is way 6530 + * too low. 6531 + * 6532 + * Let's scale up the threshold upto 1 second if BogoMips is below 4000. 6533 + * This is by no means accurate but it doesn't have to be. The mechanism 6534 + * is still useful even when the threshold is fully scaled up. Also, as 6535 + * the reports would usually be applicable to everyone, some machines 6536 + * operating on longer thresholds won't significantly diminish their 6537 + * usefulness. 6538 + */ 6539 + thresh = 10 * USEC_PER_MSEC; 6540 + 6541 + /* see init/calibrate.c for lpj -> BogoMIPS calculation */ 6542 + bogo = max_t(unsigned long, loops_per_jiffy / 500000 * HZ, 1); 6543 + if (bogo < 4000) 6544 + thresh = min_t(unsigned long, thresh * 4000 / bogo, USEC_PER_SEC); 6545 + 6546 + pr_debug("wq_cpu_intensive_thresh: lpj=%lu BogoMIPS=%lu thresh_us=%lu\n", 6547 + loops_per_jiffy, bogo, thresh); 6548 + 6549 + wq_cpu_intensive_thresh_us = thresh; 6550 + } 6551 + 6519 6552 /** 6520 6553 * workqueue_init - bring workqueue subsystem fully online 6521 6554 * ··· 6566 6527 struct workqueue_struct *wq; 6567 6528 struct worker_pool *pool; 6568 6529 int cpu, bkt; 6530 + 6531 + wq_cpu_intensive_thresh_init(); 6569 6532 6570 6533 /* 6571 6534 * It'd be simpler to initialize NUMA in workqueue_init_early() but
+1 -1
lib/Kconfig.debug
··· 1200 1200 help 1201 1201 Say Y here to enable reporting of concurrency-managed per-cpu work 1202 1202 items that hog CPUs for longer than 1203 - workqueue.cpu_intensive_threshold_us. Workqueue automatically 1203 + workqueue.cpu_intensive_thresh_us. Workqueue automatically 1204 1204 detects and excludes them from concurrency management to prevent 1205 1205 them from stalling other per-cpu work items. Occassional 1206 1206 triggering may not necessarily indicate a problem. Repeated