From nobody Mon Jun 8 14:35:52 2026 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 938223F9F30 for ; Thu, 28 May 2026 16:02:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779984138; cv=none; b=bVcJQ8SwkZPk/ON8UB+YEDkz7uNZ1WRcIZSTsCiPKa/1E749QBJDDdVXutcWGeWOSyrikPQtylOjsihr+YMTcziTqtzamejFcKUjaTfkMWHkPDYNCDQEPw+SiEeKrwwG4fMj4rQlKRkCapiVdmOd43OdUsRvFUSBtE2w7DmNsSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779984138; c=relaxed/simple; bh=8q0RU0n36CW1cmM/8ov90DkKuwjsjdpHEyF97J9vzZE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M4zhzghJiFuB6UsT55BDlLrH6t68fwED+s9rNgfNZ/NO9yjVLx68Fv/+wFPFN6sJf0ZeFfuiQF5HRjwuKnZCER8MY8uapb5fbKii1ZN385MV6+XJptMll2P2KP36IlYppLOa0TtKja8K5pmJRCUL636sQaJAboEJuVzi9slcpEs= 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=MJvtxblK; arc=none smtp.client-ip=209.85.128.45 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="MJvtxblK" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-490426d72f7so62685185e9.3 for ; Thu, 28 May 2026 09:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1779984135; x=1780588935; 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=SOQfICDOy4zz0ZfHYqt2AUylQX0hOHHbtScJIYp7QGs=; b=MJvtxblK4av/z45bNxa9EkTCDGRG1uxGOWYeGWTaKfmqePSVhwhBnSxsZ4DysmMFsx vT0UejjLD1C79ocAY0HX2+XNtHCqBOdy8jKBqH+ivCE1bsw5u7clzbT/jGLu82pcov3l AXnaAwws8a9nGC2gpQNW5xqkBGYFCdsItro+H/gqALjV6s7CPfMwqOCoqO1CSwAhaFTB LHJOvnghBT/oYl4/RdrQBhmZELAGnvfRejMrG9T2f0hfNUk89EkhjQtz6QxklrbfhXr6 9q0UAJ8/nUSn4RUD6jTKKAraIT72NsGECaOmQAHpaY7UL23j2HgG+NT+26KM4Z9FHmJE +yBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779984135; x=1780588935; 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=SOQfICDOy4zz0ZfHYqt2AUylQX0hOHHbtScJIYp7QGs=; b=Opk98S4bPUt8NJD7dVQy/IYaE7GJXTg2OYZyjfl99fEnvUDrv52lOk/6aqG1hbTFRA 485H4+7HazJyjkmeAz2e3TSfOUxSWlTMn+Jn2fp/CLztMeu6eRT7GM40PM6CkEOWjf+u OdF3VHc2E/2vT9IrLBlh+r4HQXaeIyQxaOf6iN9bdlxx3KyU90Q+J3vSKgPJVrEejbbE XjxZpXMD8Vp25UmBsibrgtIVo135WMEqd9mqMbNVdwK6huVEog8+GO9B8k6iJTAlcTUw gKUETX6UkGt/3L+VhfUa6hKxbV9AdJfwgk3JL6jk8kwhKvukQ7oJI0FjbY/RXhB9uw3V HQWw== X-Gm-Message-State: AOJu0Yzub6pLmgRvi99+Hn24Q1uEXsulkG3HrLhQikLKKuqTBpPAYgca f4vE4CKkWM6XevoOecXPMXf+tvwY/RO5ZAYQovi2tYV/frhsYm4GXtZwqhCPw8lbTS54vyyYNNx 4wxfJU8k= X-Gm-Gg: Acq92OEQJe+WfjwgHbXOIbFcAu7PCYx7hinKqtmEUgdxjEdWfEmVn1Gj1c+jehcwa/4 XOBMo1jJW6dioebuUzOPs4k4QTOITR44RVOeHCjlkaO+v14uwmAc0+Ek9gtQelaeVxCgc3tpTas ucFr8HGgtKi4gRyhliOL396vEhaJymsHChtX68u9YipKvCZ2StAhJGTpvYo6jxkjAygvJ62g/8P Hcu1izUZfSakE+CBgwEyD0lQXiWSmS1ZuYMVle4jaXPPIhpON8Wlu1DMOUo3ft40TnC5Oh/cydV x/GdOUsgDxdANNdsVzJObGYRzL5dMLTsmLHvwfxCA/C/77c+8k9e/wrOzOwh/ah6RX/Lsrrt9a7 Eup/RHrBz31+TBK44mf+vkNBXCf32+S0sLX9AiCwN5DDvi5HX4hWoBHAbNTrORZCdOZzeIG2rNl 63vwzytF8vgN231DFONeq17S2E0V9cJ0UhV3KewepuETDzIYu1CgFAoSru5Q== X-Received: by 2002:a05:600c:c3dc:10b0:490:4b89:5361 with SMTP id 5b1f17b1804b1-4904b895603mr303649885e9.7.1779984134904; Thu, 28 May 2026 09:02:14 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4909235d4e5sm67856075e9.2.2026.05.28.09.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 09:02:13 -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 v3 1/2] workqueue: Add warnings and fallback if system_{unbound}_wq is used Date: Thu, 28 May 2026 18:01:58 +0200 Message-ID: <20260528160159.471265-2-marco.crivellari@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260528160159.471265-1-marco.crivellari@suse.com> References: <20260528160159.471265-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. 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 14:35:52 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 1A56F3F929C for ; Thu, 28 May 2026 16:02:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779984139; cv=none; b=TtXR3Kn5jmc0OAmEHon/uSmLPrV7LLkRnqz1IirQV1/WIVAy/XeZgNP02CyUtUpoN1HSZ0CQbAeagjfmDq9c+D1Cl8vWLCmz/n3wD7EMALmB2HfXncOygi4N2zWQWvXvifHh+R0nylUs5lxkVRS5mmhoDXorGV06ttyK0XOR84M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779984139; c=relaxed/simple; bh=Vf6QFjKooD8v881/MsiobqAqrBI3+YjghV7iXl86eQs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hW+uBuTOYT/B6CAO1RtmkOcGRykHgywFZgc0n00viCsRbgVnbvJ5IStpU+rqmuc8GQL3N+A0TaQHIfeLAkWoI3j1uz7Ty3iHZTzMoTzISZOCqj8Mj/27WCE/QS/Qr4wUNh29wUO6DSFXLXJ18okKDw49KFENN8K0mAm69mcWF04= 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=bTejoQMt; arc=none smtp.client-ip=209.85.128.51 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="bTejoQMt" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4903997fcb5so73629595e9.2 for ; Thu, 28 May 2026 09:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1779984136; x=1780588936; 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=08m0Uh5qXblDRq6C3yjoDEQqMSWEvemjTeR5SWGCAng=; b=bTejoQMtyzqdQcgHLle07Ws20K/1+S0rwLyv/lPlxPuDIZ1VtHD0MJB2gBLyPpcVee LrQdQy5Rk+ZMNC7X60aLq4HRaeU7zlxr9PnJmquFlJZOOekrX6QRPN3qYmIoSMnp/B1t EakTU/RvT1yBzuRpyGAqQ4KyIhoMqfb115ZPs84d6Iv5HBVT/+R5uttmmIkRNOglNF38 sSxjYXMYA8ocUQhCROvLfk6F+RAgWmAJ5jxiIRGXK6z3o3bCy/pY/xkfDysZ8azFokEN f0odEbWOR8wAcoyYS09R5xfifJ18fk9QCygdXWRY56yK7msMCn8X2DbJ7iD7zbClwl3d iD3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779984136; x=1780588936; 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=08m0Uh5qXblDRq6C3yjoDEQqMSWEvemjTeR5SWGCAng=; b=ECCNn5fWAmTngXgDnX9L0Tl/7yCtuHpOtDEzJ4ULMaSJazKF4ZIU+cv/jAengulNFA JddxAxHFg9546aQ3QDaP62xCaKZumObjVblG8C9r98bjkx3EYz0X7HYcjeMmrqNvfKHG Crp6sfjLMp5Hms7d+XN7w4z5Q2ePH39hkhU3AxDckYyFwv0AhzhljTW3y77WCBWoKOgx F78nXtaStE11Zgc3GflAWG4gKQt0YVaFEz4l4HRrcMVWOaPgl2AzHskybf3COqN4AkVw Aw4nSk8WcNIWxlRUzKT+nR/ddF5cGc9iHd98CrQt+Y5t3pJFcX0H8sW8QuklCzprDcAS ObZw== X-Gm-Message-State: AOJu0YycjaA0LVs+w95KXBroS+JdZrUsdRr1e7kI0q2acLIR0Xnf3gd7 T4+Obzo+pnxLMxqdzTQpSJE/fmsdPzm4rij8BWDt8gDyzjblYl1zdKR2Q+wWqvP7bIu8v4KLIOA bTk1kPGs= X-Gm-Gg: Acq92OGi3L98P5V3TkeTnxu1skXsI0PlRjGGUHszHI7IOuXcBqTelv48iyVwgMJ8LvU 0CxHhXom4hB84EM5s6oK+IVeH/U4LWCUwcc27c/YWxBBzrn3Kvm1jgEN/DdeG9rtFyf0SeKHljb VGkjwOACcygvjcCvPDAwpM1vvlj1sT+UtRPZPJSYjEOw+KT/NtPTNseAle5sw93mfzKi3266Ezo NqdSVvvznlWsJ9LAVNfRfhyWWnPGo0dyRCUedYzZBCdVcxlejKkb89sTnnuqivdFbC5vRox5RCj oiZFpYL4JTpW1QpfA7j1d/7rkGhR4xwAGwSCI+siV8jfUosY1wwuS914YP2TEzGxNPG3+vSw5SP mzPnD35d8zy/DRam+fYVBv9szB62q2Okpn0GuvjCbdGpfhwlYgoWuxrSemMXGnQG0x4jxvAvc1T zGHehOKCpHjleyk2+2QO4N6PkO7LapNmuOpu8fVf+/JBLaRorXqTeCcr0aBA== X-Received: by 2002:a05:600d:8499:20b0:48a:5970:1fe1 with SMTP id 5b1f17b1804b1-4904248ad4cmr356364395e9.4.1779984136408; Thu, 28 May 2026 09:02:16 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4909235d4e5sm67856075e9.2.2026.05.28.09.02.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 09:02:15 -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 v3 2/2] workqueue: Add warnings and ensure one among WQ_PERCPU or WQ_UNBOUND is present Date: Thu, 28 May 2026 18:01:59 +0200 Message-ID: <20260528160159.471265-3-marco.crivellari@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260528160159.471265-1-marco.crivellari@suse.com> References: <20260528160159.471265-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 0b55f8009eed..3e52956ce661 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 (!(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