Re: [RFC PATCH v2 1/2] workqueue: Add warnings and fallback if system_{unbound}_wq is used
From: Marco Crivellari
Date: Thu May 28 2026 - 10:21:18 EST
On Wed, May 27, 2026 at 8:32 PM Tejun Heo <tj@xxxxxxxxxx> wrote:
>
> Hello,
>
> On Tue, May 26, 2026 at 05:00:40PM +0200, Marco Crivellari wrote:
> > 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
> > workqueus are used and redirecting them old used workqueue with the appropriate
> > new one.
> >
> > Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@xxxxxxxxxxxxx/
> > Suggested-by: Tejun Heo <tj@xxxxxxxxxx>
> > Signed-off-by: Marco Crivellari <marco.crivellari@xxxxxxxx>
> > ---
> > kernel/workqueue.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 72 insertions(+)
> >
> > diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> > index 33b721a9af02..e17617e205b1 100644
> > --- a/kernel/workqueue.c
> > +++ b/kernel/workqueue.c
> > @@ -2437,6 +2437,24 @@ bool queue_work_on(int cpu, struct workqueue_struct *wq,
> > bool ret = false;
> > unsigned long irq_flags;
> >
> > + /*
> > + * NOTE: These checks are here to assure that no users will still
> > + * rely on system_wq and system_unbound_wq.
> > + * They can be removed along with those workqueue when the
> > + * time comes.
> > + */
> > + if (unlikely(wq == system_wq)) {
>
> Can you add an internal flag to mark the workqueues and use a helper so that
> the warning messages aren't replicated in multiple places? Also, do we need
> to have the warning on delayed_queue? Just put it in a single spot where
> they'll all converge.
Hello Tejun,
That's maybe a silly observation on my side.
If I remove the checks from where I placed them and move them deeper
(__queue_work() for example), I won't know how to print the "caller,"
making it harder for people to understand which code is using the
deprecated workqueue.
Printing the stack with dump_stack() is not doable.
Do you have suggestions?
Thanks!
--
Marco Crivellari
SUSE Labs