From mboxrd@z Thu Jan 1 00:00:00 1970 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: 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 e17617e205b1..d28eb5923a1c 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5890,7 +5890,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) @@ -5914,6 +5914,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