From mboxrd@z Thu Jan 1 00:00:00 1970 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: 8bit 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(const char *fmt, /* see the comment above the definition of WQ_POWER_EFFICIENT */ if ((flags & WQ_POWER_EFFICIENT) && wq_power_efficient) - flags |= WQ_UNBOUND; + flags = (flags & ~WQ_PERCPU) | WQ_UNBOUND; /* allocate wq and format name */ if (flags & WQ_UNBOUND) @@ -5850,6 +5850,23 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt, pr_warn_once("workqueue: name exceeds WQ_NAME_LEN. Truncating to: %s\n", wq->name); + /* + * 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_UNBOUND. " + "Setting WQ_PERCPU.\n", wq->name); + flags |= 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 &= (~WQ_PERCPU); + } + if (flags & WQ_BH) { /* * BH workqueues always share a single execution context per CPU -- 2.54.0