From nobody Mon Jun 8 12:13:19 2026 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 27AF84A32 for ; Fri, 29 May 2026 13:06:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780060019; cv=none; b=mDpFD2rJowVWOb1zGT49X5nwnGTgfaD8KAtMbVz/h5QNjCiJbQedIZjNxJEsHOwsHptjQVvqnOQqe3cPbAcPLSaWtZjTTErA+JEKsk7Xa7J+d+X6gXLDsgU4uD2zZdF+f+NTQO7QbpscWxwhqk4QGO5LkKfcGzdZD82ZYCXp/Ec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780060019; c=relaxed/simple; bh=kaknLVm/ejtE3PJJFt4brgxbN5nVEFJEcDGaQI6SW0A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u95e/hz+UZOtxNTz32KH7mvKqV9xbkX+J4/ZUCTN7O1A1P/kQWPT6xgkVDtoswqjz5Z358EoOz+uPXPZ/YqnoN3HtfGmACHYwXFEu29G3OVo9LWYWlciP560/Iuy7c9P1CwTo0FB8llv8jbfFQiLvJcoawIJiZfoltyhMZlFwK4= 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=UNwH+8a0; arc=none smtp.client-ip=209.85.221.47 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="UNwH+8a0" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-45ef616daf6so166794f8f.3 for ; Fri, 29 May 2026 06:06:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1780060017; x=1780664817; 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=SbYrHRmw6BxgxF1GNas9TQg628Cva+DmGIs/8xUdTyE=; b=UNwH+8a064AKJH1x71SEuIH9/iDzFiYaT+XWvCj5SAVqNSkHU0x46iLLbA1BQTPf0F zxkeSv8JEnFXSdSJ7aVG7o053Bo49Ue6QXu7UUmFtw71qO7AkkaJCHCAzCHafnOr3+sg 8QeFYKjM9nBCBjDGmvEuBfbSEWXOPMooXVYzL0yrkMvGdWRCO3XrYZMq5ghCs7HwmFkP 8a3/WL7p3bFh/kh7nRcfVFLN0EXHITUBXmcjTJNrOudxheGcOwa84mvm1owaJS+6b3mz 1Zv7TI7Bk7CDo/PoCbsLeoj1fOGNSxljXvm5ov50tHD9ipK93IyvbilMEPaqu5KdmUIA NyBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780060017; x=1780664817; 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=SbYrHRmw6BxgxF1GNas9TQg628Cva+DmGIs/8xUdTyE=; b=ZLxxG3Z5vHCBwsIvZvpFNgMu5wENmM5FncSSuHVOS74NdDX5aWlqJn0FWH/P05v//9 Y5lUGj4VnTgbk1Em4BtPTbEhKxfuZA6Z30niZfRnWDHJXBgklhPHMpYve+KeMBY+Eskc ZD4wQpkrl7x49JGFSJ0WzdlTlOy++MjQumRhbenmp/e8Ri6bXnPnHyljLg13UbX6uQKI Bu++dUg5rYojVROAS3tv+Z4GuNTe+NMNQQsmX5VC4qv1BIZ9vO8jvMWv4KO6j8LGVe8U fgOJ2NY1UJDLIyknCuLUvAVWPPw22I2zq+z1okCws+42kSwSkH8jWxjsQVKdYyFUzNY+ MZBg== X-Gm-Message-State: AOJu0YxRceBM/dNNWI5YBUshsild7E+UViYv9q7se00GtGpAiGVMVA96 3oLGaUIxzs+GeLNs0L4kNm5t8O70oJChqOXDSC9HlR5mcJuZfk8jtNOahP3bgT54KptEV/j7EZA or6JcoWo= X-Gm-Gg: Acq92OFeucOAan8/2Q46zwnA59Z0z/5LRk3dQOKdZraT1NLPpZ2mEi3EJ9+pPAQdHKE xC5yCbwB4NP+au/UGP5w5A5ZIGlITG6W4H86xiS5e5W987RFEEpjcK8zoMUDUNVBey3gOaW+xFT E9v4vaDT/icO3NTPRNwErNoMpKx4LJm9E4ULh2Wanyl8qkPyQ/NyR3weCUcdnY5iKGN+Yj1sLyi IX4y5fkyTS1+N0mSBP+esZwpHha2PEpqY58roN+BiuzkTSVTzD6+FKYhdKKFfMaN8PgEfKr3P9r hrsoZmi0lzO1jhQQIVSOxY0s+mFG3eZ/UCqRX9i2K5VQ/qWeWkwYJP19oqJVv6iLFN0P+xLS+KI pkAkayBG9rOTu4DGdKv7IMPNN0/8QcPv6cd6V5PivMGfj7jgMbzLqsgj09Y9MudNl+elBohxVRX OomdeUAmoaPqky0HJWSVRbCgTJJHS7uA26meFqbfPBi8EkyoqP8Q== X-Received: by 2002:a05:6000:4912:b0:446:96b1:f53 with SMTP id ffacd0b85a97d-45ef144bf59mr5210121f8f.26.1780060016626; Fri, 29 May 2026 06:06:56 -0700 (PDT) Received: from linux.fritz.box ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45ef34a037fsm3408549f8f.4.2026.05.29.06.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 06:06:56 -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: [PATCH v4 1/2] workqueue: Add warnings and fallback if system_{unbound}_wq is used Date: Fri, 29 May 2026 15:06:39 +0200 Message-ID: <20260529130640.220328-2-marco.crivellari@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529130640.220328-1-marco.crivellari@suse.com> References: <20260529130640.220328-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 workqueues are used. Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/ Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari --- include/linux/workqueue.h | 1 + kernel/workqueue.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index 6177624539b3..a283766a192a 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -409,6 +409,7 @@ enum wq_flags { __WQ_DRAINING =3D 1 << 16, /* internal: workqueue is draining */ __WQ_ORDERED =3D 1 << 17, /* internal: workqueue is ordered */ __WQ_LEGACY =3D 1 << 18, /* internal: create*_workqueue() */ + __WQ_DEPRECATED =3D 1 << 19, /* internal: workqueue is deprecated */ =20 /* BH wq only allows the following flags */ __WQ_BH_ALLOWS =3D WQ_BH | WQ_HIGHPRI | WQ_PERCPU, diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 33b721a9af02..0b55f8009eed 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -2280,6 +2280,14 @@ static void __queue_work(int cpu, struct workqueue_s= truct *wq, unsigned int work_flags; unsigned int req_cpu =3D cpu; =20 + /* + * 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 * steal the PENDING will busy-loop waiting for it to either get @@ -8037,12 +8045,12 @@ void __init workqueue_init_early(void) ordered_wq_attrs[i] =3D attrs; } =20 - system_wq =3D alloc_workqueue("events", WQ_PERCPU, 0); + system_wq =3D alloc_workqueue("events", WQ_PERCPU | __WQ_DEPRECATED, 0); system_percpu_wq =3D alloc_workqueue("events", WQ_PERCPU, 0); system_highpri_wq =3D alloc_workqueue("events_highpri", WQ_HIGHPRI | WQ_PERCPU, 0); system_long_wq =3D alloc_workqueue("events_long", WQ_PERCPU, 0); - system_unbound_wq =3D alloc_workqueue("events_unbound", WQ_UNBOUND, WQ_MA= X_ACTIVE); + system_unbound_wq =3D alloc_workqueue("events_unbound", WQ_UNBOUND | __WQ= _DEPRECATED, WQ_MAX_ACTIVE); system_dfl_wq =3D alloc_workqueue("events_unbound", WQ_UNBOUND, WQ_MAX_AC= TIVE); system_freezable_wq =3D alloc_workqueue("events_freezable", WQ_FREEZABLE | WQ_PERCPU, 0); --=20 2.54.0 From nobody Mon Jun 8 12:13:19 2026 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 EDA22226CFE for ; Fri, 29 May 2026 13:06:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780060020; cv=none; b=JT8KIfXJJfZ0SaASUV3Pwx9ybGJD9i0tttC4GZAmwapb5ZsEg/zCKeuWx+30x+msDOC0ehUbpnl6RoYF65QKcCndymYh4UHDVOSkIRlByM1DCJPqGrHxW+Zw/3o16qjBkj/JlIRYkc1Yt1Ms8S+xkRXr7OyB+a8bByfCNVpR1HE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780060020; c=relaxed/simple; bh=v4pmw03u9pnJ5U9ooZIIDu/L7JcxF2qJwqm2/tdLvH4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BJsUSdfyVTitpzFSBGLn2vAIEAph+8iU4zW7fweBUiqd4KprHJmigy9YeIv3lfpi7YtAt9jfuSboji+ixfPLHVUzC/TGDDvwaldySlGz18IYvdAqZZQYsCVa6YNnSIwMtqjW+4iubvYwE01pb0tJRRecRdURehfZqRc1L6KOjbY= 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=fAlq11gn; arc=none smtp.client-ip=209.85.128.46 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="fAlq11gn" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-48a563e4ef7so98578325e9.0 for ; Fri, 29 May 2026 06:06:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1780060017; x=1780664817; 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=GJNHJDm8mZQsArmBizVHlrsmkMedRbaOFc+QNKkEcYA=; b=fAlq11gnfH2MENHvEPcUY/YAxqziK3P/WBuEVdEtBFzwWUOb2UYJ9ssh+FSTBjSAfn uXvrflgpJUDxXJKG5JNa7eFxDS1Aqai0v97WxIIxEnbuSND+x5Tuv8OZWrHK5Qotij6g Gy8BZNLIlEoxlaqMec9XUx01dD/0zKknYVm5NCQGf5UZDcBxeUy+Z8acnS8n+ldapnGQ gj0Ncj/PorSJAoqYl+KVKgfgHO/i8rljgVrc6K6Cy3JG6X5aBYe6gXQBxJ2ucYQn1ilV LICc/dECBxd35C2fJfrcv8s7y4gHG5WEfPpx+lFvzhwcRkrRk13WYUsrYmKb73Rcceki eelg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780060017; x=1780664817; 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=GJNHJDm8mZQsArmBizVHlrsmkMedRbaOFc+QNKkEcYA=; b=avDalT77Sq+cDdK28fHD5Bl1eHFb9FWv/Q5JOGSAHs60vzDI0M6l3YXYXEhxIll2wr vuB7OLopuG8PSUw937wlrajerbaXFS/4JSkdv57Wq+jgz5Q7a7InCyUusZnJOOPgnqvK f4bYJljQBBtlwKFbGcIYbsuKY16wNjvjKW9bJrvK+/IHssmBTRnrl90pa8cFYnGF0NpT qXG3nPPHIsHvfMVfKkB4Nze3uY/YJh6X7RhbIGUDn8MgkkoGS/chceD06ez1CxoK3qbh CaSld5ir5Z+Vu1NL7/6S2F1e5Sbxk7ulq76LkO+K+ky/Bvs1uGdKObIPiLyV9CERNCgy jS3Q== X-Gm-Message-State: AOJu0YzPRhx670xcwBMVMrZongyRRjuVmC2euvColymBgR5sn6PwOiCp CCNIbwmZ4XpByTZciS2rsVn36x1LzYavOA3CYApwTzpIPvB5Xb7iOoTuHrZj9GCQLiSQRoz2CB8 MeN/SEBE= X-Gm-Gg: Acq92OGQw7KosEpV0nUwDBudYn1fYvZrFlt34HdBTPlI1x1J3F96iQWHf8BCrD47Jwj 149AKAc3GRcaVEJGyG5GSTYGD3YiL0ryTCcvfvGhQcmgRW9va8cUjNVxZa6hJ5k0Jvr64dgBUZT 4JhQmn8MA1MuMKm6bC2jpa8XpWusoKxenxkBEGvhs6VDXAkiHUYXo3fnAp5qJpy7O/taaxKPWlF 5mJu5svW+t+Gye6pDM2Ty7NYYmuOB7X7/gUu0/6MQBI/n2hqMTJgW/lYxgPa8tO7zY/B3wMUCas uJTSztdhSwOG+9XpKLgCsmpu8IWPeArrGcR/t0IiAHWDlWFGnki03SLZjShtaiQ1uIp3paHC470 Ud9FqwGCZOgawYRPwH4LTu4yHjjFXMmE/How2UCpXqvzBMIvlpyGwGo/cPgHpOfkdxtDjrl4KRc dG9aSLSCaeDNC+r7O5adnbIf5KB3g0oyBBJIDa5XFp/8bFHZZvEw== X-Received: by 2002:a05:600c:3587:b0:48e:635a:18d2 with SMTP id 5b1f17b1804b1-4909c07258cmr53340335e9.2.1780060017388; Fri, 29 May 2026 06:06:57 -0700 (PDT) Received: from linux.fritz.box ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45ef34a037fsm3408549f8f.4.2026.05.29.06.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 06:06:57 -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: [PATCH v4 2/2] workqueue: Add warnings and ensure one among WQ_PERCPU or WQ_UNBOUND is present Date: Fri, 29 May 2026 15:06:40 +0200 Message-ID: <20260529130640.220328-3-marco.crivellari@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529130640.220328-1-marco.crivellari@suse.com> References: <20260529130640.220328-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 one between WQ_PERCPU or WQ_UNBOUND. So act as following: - if neither of them is present, set WQ_PERCPU - if both are present, remove WQ_PERCPU Along with this change, WARN_ONCE(), 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 0b55f8009eed..d4799e93d10f 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5826,7 +5826,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) @@ -5850,6 +5850,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 (unlikely(!(flags & (WQ_UNBOUND | WQ_PERCPU)))) { + WARN_ONCE(1, "workqueue: %s is using neither WQ_PERCPU or WQ_UNBOUND. " + "Setting WQ_PERCPU.\n", wq->name); + flags |=3D WQ_PERCPU; + } else if(unlikely((flags & WQ_PERCPU) && (flags & WQ_UNBOUND))) { + WARN_ONCE(1, "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