From nobody Mon Jun 8 20:45:24 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB4A7403155 for ; Tue, 26 May 2026 15:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779807688; cv=none; b=WYi4y8vI0t7k5IDS8BWJvuet5TWc5ka+N5QdbHQ3W49tg3zJFE52WPh1GAtp/1E+mMiOvi7ocxYuFwUOQuSuz8rIqdWp4ZYZw6Dbfs0jeH3eAlZUlCKXzx4wScTGkry5TWbuREKCb09u4DycB4MzkxUfWeaoAF8GBD1NnvzHs/Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779807688; c=relaxed/simple; bh=7fqF8wPuMdvOYLtQJV5oksjv897cu/VBFTWwzP2VxxE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lgx0fw/FwoVltFJ1McVLhOYQq1jTgA86rfdzQCXclcwntH9MBOYFu6rZjRQv2X4PjcOa0pGqUY699OHp8MYsQmtAxAdzs4waAi1o6lVUm1u8oQkeW1g8v9VimRxcp/qOhhU5YphSNk6PU6D61VTIcaoDTSSWUfI7Y8ms7n9BBf4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=X0WtIsoP; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="X0WtIsoP" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-49041fb8c23so34745055e9.0 for ; Tue, 26 May 2026 08:01:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1779807685; x=1780412485; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iGRmf066qXCz9WHWhHDiq2wFPvpv41Fo2uyMaoNqLIA=; b=X0WtIsoPFNmEyyPjxtrPfzgPwXduowAXQxbeBen81qKQhu5icG7Ck41tSTjzf+4Q99 NLiPg65j8pOdrvkZKvclzKB7B9yBW/pAYI97vXOFg/DQAdgKG4JQ8srMV0WGjF78EkYa 2tWiM5d9z3tDKaLfJ/uoA9Tgxk97vvBc0mZ4mYoCxJCo1/km3K/L5SK1lvpXWyBWUhbg PiwwSiXZMHJo0s6PnrU2PKRI6Xe9kezPn4R6pHuDQ3QOcEjW0wrblNDJUd1KqMLgWUb2 NmQX/4kE7fGDHijySEcADXpveKtWhJpbWcPpcRBD5q6Agb/K7FWnTVBXYHvU1ONSyS61 sgOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779807685; x=1780412485; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=iGRmf066qXCz9WHWhHDiq2wFPvpv41Fo2uyMaoNqLIA=; b=ezKJZ9wnccteMLTIxh92EmrcFxMrEfISr4lujjohvpD+HwIEuNTl0iy78icwZlnDrl hVUWZUvVO/LeneY4huBZBMxe+zhWBqfJ0A8lcWW4ZxsW4TtkF7Nmx3Fk82ggkvyCFgQ8 2VspAlhTIb4z3pWWjGldbJY+vtxK97dAm1vFB8B+BcDJxWCGiJYbMpCxhXG/3bZ+dkE2 eFn/Nj3cf+Hh03mo+GdCaPUpyvAH4O/Jg2O4ny9wEDRR2/nNRziLNYSdBjplm79MZlRE tiRAkvqpFwRdwMR1SZ2WWOIMGaLSbyu83TxTnEhqmizJS5Dwy5zMR+vL9R3Kg2sz62IT 0v5w== X-Gm-Message-State: AOJu0Yz5mkAXpush17EBBYxzWJME4kcM4skOC4b+jotSDKBZnq8cE3lH WO3I4TpglCs9r5CvLYRFDQuMGpoWeveTZqbdm6iJnpQ46ffFxf3PUKZ0LxPaLLCpvt+pUxBc+Bz /bRmC054= X-Gm-Gg: Acq92OHA9EAc9lHkOEHP1SK13AKSieyf+FUY8Zdc7SB/s9+gwcpdttUyo/qWxjCJzli /3hBa5M09hG16bM2rrPJO1RHTgHJeih3EwVe0VPRdzFhvz/mbey6EoPz94SC/fXGViYmKuDkPac 3XV78RXqHEpjPzKYPyRfH9NjqdEAJlfUsk/S12vtX/m7VCJFe0ykesfbmQ0jt6NYGpuIkk1UkSj S2EwfbH5iZITPeiJPHjfzoLhxu+gIylicCuwcdGNqJfXxftIC/rwZqAWP/fza0D9nOikIpGNSXv e0zMm27fKWYFRys0nWGK40y1xh+BcQBDdmvIv96qoAiW3Lx3bBxythQ3ieuJzEZqptev36hhLX3 dCSLm/kv8sg+4FCuyRhW2y/JPLZcDSUGdcZEeRnh53cTjaF1qD8H/q16l23CQwPmgX8mBMc+zVO I7bSE41UByeV4/vXTyMqwe9RR4Y4/kss59F1L4olI5Fh9GdTkR9y5Vhr9mag== X-Received: by 2002:a05:600c:4510:b0:490:3d2e:b67d with SMTP id 5b1f17b1804b1-490428eb9aamr292508865e9.30.1779807670919; Tue, 26 May 2026 08:01:10 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490428e6d68sm113956585e9.22.2026.05.26.08.01.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2026 08:01:10 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Breno Leitao Subject: [RFC PATCH v2 1/2] workqueue: Add warnings and fallback if system_{unbound}_wq is used Date: Tue, 26 May 2026 17:00:40 +0200 Message-ID: <20260526150041.365392-2-marco.crivellari@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526150041.365392-1-marco.crivellari@suse.com> References: <20260526150041.365392-1-marco.crivellari@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 appropr= iate new one. Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/ Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari --- 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 =3D false; unsigned long irq_flags; =20 + /* + * 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 =3D=3D system_wq)) { + pr_warn_once("workqueue: system_wq will be removed shortly. " + "Use system_percpu_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq =3D system_percpu_wq; + } else if (unlikely(wq =3D=3D system_unbound_wq)) { + pr_warn_once("workqueue: system_unbound_wq will be removed shortly. " + "Use system_dfl_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq =3D system_dfl_wq; + } + local_irq_save(irq_flags); =20 if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work)) && @@ -2604,6 +2622,24 @@ bool queue_delayed_work_on(int cpu, struct workqueue= _struct *wq, bool ret =3D false; unsigned long irq_flags; =20 + /* + * 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 =3D=3D system_wq)) { + pr_warn_once("workqueue: system_wq will be removed shortly. " + "Use system_percpu_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq =3D system_percpu_wq; + } else if (unlikely(wq =3D=3D system_unbound_wq)) { + pr_warn_once("workqueue: system_unbound_wq will be removed shortly. " + "Use system_dfl_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq =3D system_dfl_wq; + } + /* read the comment in __queue_work() */ local_irq_save(irq_flags); =20 @@ -2642,6 +2678,24 @@ bool mod_delayed_work_on(int cpu, struct workqueue_s= truct *wq, unsigned long irq_flags; bool ret; =20 + /* + * 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 =3D=3D system_wq)) { + pr_warn_once("workqueue: system_wq will be removed shortly. " + "Use system_percpu_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq =3D system_percpu_wq; + } else if (unlikely(wq =3D=3D system_unbound_wq)) { + pr_warn_once("workqueue: system_unbound_wq will be removed shortly. " + "Use system_dfl_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq =3D system_dfl_wq; + } + ret =3D work_grab_pending(&dwork->work, WORK_CANCEL_DELAYED, &irq_flags); =20 if (!clear_pending_if_disabled(&dwork->work)) @@ -2676,6 +2730,24 @@ bool queue_rcu_work(struct workqueue_struct *wq, str= uct rcu_work *rwork) { struct work_struct *work =3D &rwork->work; =20 + /* + * 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 =3D=3D system_wq)) { + pr_warn_once("workqueue: system_wq will be removed shortly. " + "Use system_percpu_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq =3D system_percpu_wq; + } else if (unlikely(wq =3D=3D system_unbound_wq)) { + pr_warn_once("workqueue: system_unbound_wq will be removed shortly. " + "Use system_dfl_wq instead. Caller: %ps\n", + __builtin_return_address(0)); + wq =3D system_dfl_wq; + } + /* * rcu_work can't be canceled or disabled. Warn if the user reached * inside @rwork and disabled the inner work. --=20 2.54.0 From nobody Mon Jun 8 20:45:24 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39D303D3D19 for ; Tue, 26 May 2026 15:01:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779807675; cv=none; b=WlDoVnZ4YKTRWsHaEXXbHCDDNzLeEIJyajc1NgCHv/suje3YRKyoeUt6VIGoDBoTlSv428vx1Nq5BrXjz5J7XvvxkXliFj4ei/vUwa+Gh6RC4pYUQQ/8UNZZluuPjVQCsZfU1MDxAn51iPtYtKZ8Qve7WhdFnKeCUVjkOCbp14s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779807675; c=relaxed/simple; bh=8NUWCwnuTCRDXivRJ1QMMVi34YQ4Ztx++ebgCl8t8n4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZDweIyMIvyP31l1nka6x53ZO5Yl3Ztw1gXtMtSI3yxDdI7KBrhMJkyU+dRo1ZlfzPjeuIXvYx/bne9eMbhOFOgKDCcQCplIwUjz930SrpW0RlX7Z3I9ZeP2rCcM/6WGda3bcYuUewsABQ1cJ8uAqrwnhdnbSghE2NH4Oyt6/s2c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=J7BzbxSS; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="J7BzbxSS" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-49050bfe053so9377965e9.3 for ; Tue, 26 May 2026 08:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1779807673; x=1780412473; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W+CmQhk/7vmuRpLpIIArTiWt/Sy+XHTkZj6hqKBfYJ8=; b=J7BzbxSS3159nR7nOQ10osf1eNG9l6xoDdZiyT14apNFemUt/BICoH5A4SxLknaEI8 y+6COe2jR8LOB0O1PlhEHyw9AMmFaB7mz8EkqCyjHSU/aIYSPSbUoHMaGv2cdTSsi2EP QtX1yoWtonjObXpeiQ750wvymyVbw0OYvz62P4V3i85KACtTjoodxJEGLsUQkeJdXTWt yf0AuUyzrIIgodixiLIVubm4DktnxEqY5YmJniRteKo+VM5YJUW6uUS0IJZOmudk2BDb L38GDticYPmIkpEk4glj5yQRwQicZmWWpEhH1fKTwEhvipg43jEhdYdqxPtsuEdJh+Y0 RjjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779807673; x=1780412473; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=W+CmQhk/7vmuRpLpIIArTiWt/Sy+XHTkZj6hqKBfYJ8=; b=rGdFrU7KxC88RTUTk9DlgPfA2qJAfYKzm9qzIU+oaX0CCpuOhPRvWtpMhAeiQlU3eD gPrKwwg4z3CpS1PQXh6xEJ5xQfg02lUrx/d9rmLw5Ti07Gtz5EJ101lqsoAM4AEHBgVs EQknxxn6maehZ+ulTOkCTvxQNAPxD300Z7mXpaF/VHvQ5lsyCIvWNBLlwUHEvW2UAV3O 1gScixtMa7rsZH+EBbzHyxFeTo9cCLPBGQ3yf9jjAUu0/1/kPsjwSf91K4TqC9YnUUgs WXdKJ4UjQ9Kk9LV169yqyL9KaiLjsFDbUVBeokSnbBItl2EYiZyU+mY+96sb5ezTtcnp UeRg== X-Gm-Message-State: AOJu0YwiNjMsC8scusboWEiiU2t4ck4yeBqxGXQ0HFFyalXf35/9qik6 eiK5AlDKaFZMAOJ2aOKUP4r4Ih8Zkx9MKsxqb6557to9ByU8K71CWZzq53C8FCB/VjMyIbdv8ld vEoi0V1E= X-Gm-Gg: Acq92OEsgB7TFrOlvOxBQQhkSIjEyywG2eV6ELiiGKXHhyURDCOhMNu5/cg6TNlSogr TlXVkpoY9vyz3BJV2wBfAvR14foxK5Fcq/4a7Atek2DSU3oHC065GUv0usXBl49gdVil8cln99N D+HU+aBNqXasF07x11HwXnZSAqwyzq/FjMaOtf/VZIH0qmNurB1Dt65YI3wn3Rg2membJMPu/Xo cxDGt/WGf/7Dn5x2ltu8cFxLai6xX53Q2Lb1RgjxtDx5ZttrXb4erMuRpYjkdaBWQznB5/cfHPA fTG3NCXmzjo7eoUh/21WJBdSIoa8cqoh9YstBC5zKw9EpYZHA0TPRrZMJ+C1sVtTf8FRyCKgvGf aKj9G0rMW3KN3Nxu8HHAosm+L7ctR7dtOhebn967dcKpyXrbMc2Qe25eVCJeLUgwPmnFP2COCr5 +/2weZ6C6QQlTK/n9vqdX3OVbrxmnWErMhaYs+itRsUV2Kxb4= X-Received: by 2002:a05:600c:1c10:b0:490:5380:f2cb with SMTP id 5b1f17b1804b1-4905380f463mr265474755e9.0.1779807672163; Tue, 26 May 2026 08:01:12 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490428e6d68sm113956585e9.22.2026.05.26.08.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2026 08:01:11 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Breno Leitao Subject: [RFC PATCH v2 2/2] workqueue: Add warnings and ensure one among WQ_PERCPU or WQ_UNBOUND is present Date: Tue, 26 May 2026 17:00:41 +0200 Message-ID: <20260526150041.365392-3-marco.crivellari@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526150041.365392-1-marco.crivellari@suse.com> References: <20260526150041.365392-1-marco.crivellari@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently there are no checks in order to enforce the use of WQ_PERCPU and avoid this flag is used if WQ_UNBOUND is already present. So act as following: - if neither of them is present, set WQ_PERCPU - if both are present, remove WQ_PERCPU Along with this change, print a warning, so that the code still uses both or neither of them, can be changed. Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/ Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari --- kernel/workqueue.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index e17617e205b1..d28eb5923a1c 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5890,7 +5890,7 @@ static struct workqueue_struct *__alloc_workqueue(con= st char *fmt, =20 /* see the comment above the definition of WQ_POWER_EFFICIENT */ if ((flags & WQ_POWER_EFFICIENT) && wq_power_efficient) - flags |=3D WQ_UNBOUND; + flags =3D (flags & ~WQ_PERCPU) | WQ_UNBOUND; =20 /* allocate wq and format name */ if (flags & WQ_UNBOUND) @@ -5914,6 +5914,23 @@ static struct workqueue_struct *__alloc_workqueue(co= nst char *fmt, pr_warn_once("workqueue: name exceeds WQ_NAME_LEN. Truncating to: %s\n", wq->name); =20 + /* + * One among WQ_PERCPU and WQ_UNBOUND must be set, but not both. + * - If neither is set, default to WQ_PERCPU + * - If both are set, default to WQ_UNBOUND + * + * This code can be removed after workqueue are unbound by default + */ + if (!(flags & (WQ_UNBOUND | WQ_PERCPU))) { + pr_warn_ratelimited("workqueue: %s is using neither WQ_PERCPU or WQ_UNBO= UND. " + "Setting WQ_PERCPU.\n", wq->name); + flags |=3D WQ_PERCPU; + } else if((flags & WQ_PERCPU) && (flags & WQ_UNBOUND)) { + pr_warn_ratelimited("workqueue: %s uses both WQ_PERCPU and WQ_UNBOUND. " + "Dropped WQ_PERCPU, keeping WQ_UNBOUND.\n", wq->name); + flags &=3D (~WQ_PERCPU); + } + if (flags & WQ_BH) { /* * BH workqueues always share a single execution context per CPU --=20 2.54.0