mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 14:04:27 -04:00
workqueue: Add warnings and fallback if system_{unbound}_wq is used
Currently many users transitioned already to the new introduced workqueue (system_percpu_wq, system_dfl_wq), but there are new users who still use the older system_wq and system_unbound_wq. This change try to push this transition forward, by warning whether the old workqueues are used. Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/ Suggested-by: Tejun Heo <tj@kernel.org> Signed-off-by: Marco Crivellari <marco.crivellari@suse.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
committed by
Tejun Heo
parent
611583a76e
commit
64d8eae3f8
@@ -409,6 +409,7 @@ enum wq_flags {
|
|||||||
__WQ_DRAINING = 1 << 16, /* internal: workqueue is draining */
|
__WQ_DRAINING = 1 << 16, /* internal: workqueue is draining */
|
||||||
__WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */
|
__WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */
|
||||||
__WQ_LEGACY = 1 << 18, /* internal: create*_workqueue() */
|
__WQ_LEGACY = 1 << 18, /* internal: create*_workqueue() */
|
||||||
|
__WQ_DEPRECATED = 1 << 19, /* internal: workqueue is deprecated */
|
||||||
|
|
||||||
/* BH wq only allows the following flags */
|
/* BH wq only allows the following flags */
|
||||||
__WQ_BH_ALLOWS = WQ_BH | WQ_HIGHPRI | WQ_PERCPU,
|
__WQ_BH_ALLOWS = WQ_BH | WQ_HIGHPRI | WQ_PERCPU,
|
||||||
|
|||||||
@@ -2280,6 +2280,14 @@ static void __queue_work(int cpu, struct workqueue_struct *wq,
|
|||||||
unsigned int work_flags;
|
unsigned int work_flags;
|
||||||
unsigned int req_cpu = cpu;
|
unsigned int req_cpu = cpu;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE: Check whether the used workqueue is deprecated and warn
|
||||||
|
*/
|
||||||
|
if (unlikely(wq->flags & __WQ_DEPRECATED))
|
||||||
|
pr_warn_once("workqueue: work func %ps enqueued on deprecated workqueue. "
|
||||||
|
"Use system_{percpu|dfl}_wq instead.\n",
|
||||||
|
work->func);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* While a work item is PENDING && off queue, a task trying to
|
* While a work item is PENDING && off queue, a task trying to
|
||||||
* steal the PENDING will busy-loop waiting for it to either get
|
* steal the PENDING will busy-loop waiting for it to either get
|
||||||
@@ -8013,12 +8021,12 @@ void __init workqueue_init_early(void)
|
|||||||
ordered_wq_attrs[i] = attrs;
|
ordered_wq_attrs[i] = attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
system_wq = alloc_workqueue("events", WQ_PERCPU, 0);
|
system_wq = alloc_workqueue("events", WQ_PERCPU | __WQ_DEPRECATED, 0);
|
||||||
system_percpu_wq = alloc_workqueue("events", WQ_PERCPU, 0);
|
system_percpu_wq = alloc_workqueue("events", WQ_PERCPU, 0);
|
||||||
system_highpri_wq = alloc_workqueue("events_highpri",
|
system_highpri_wq = alloc_workqueue("events_highpri",
|
||||||
WQ_HIGHPRI | WQ_PERCPU, 0);
|
WQ_HIGHPRI | WQ_PERCPU, 0);
|
||||||
system_long_wq = alloc_workqueue("events_long", WQ_PERCPU, 0);
|
system_long_wq = alloc_workqueue("events_long", WQ_PERCPU, 0);
|
||||||
system_unbound_wq = alloc_workqueue("events_unbound", WQ_UNBOUND, WQ_MAX_ACTIVE);
|
system_unbound_wq = alloc_workqueue("events_unbound", WQ_UNBOUND | __WQ_DEPRECATED, WQ_MAX_ACTIVE);
|
||||||
system_dfl_wq = alloc_workqueue("events_unbound", WQ_UNBOUND, WQ_MAX_ACTIVE);
|
system_dfl_wq = alloc_workqueue("events_unbound", WQ_UNBOUND, WQ_MAX_ACTIVE);
|
||||||
system_freezable_wq = alloc_workqueue("events_freezable",
|
system_freezable_wq = alloc_workqueue("events_freezable",
|
||||||
WQ_FREEZABLE | WQ_PERCPU, 0);
|
WQ_FREEZABLE | WQ_PERCPU, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user