From nobody Sat Sep 26 07:15:40 2026 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.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 EA9454E56D0 for ; Thu, 3 Sep 2026 16:54:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788454456; cv=none; b=NnbaexufMvNT+gFm25c/fJMWmBacnylx4SMJad9utDTpJYKcNCLH4lnJRd3BR58zIswe4EIbCuHBFAErOByEe7nzso0O27iiqzW011gFnzXSuV1ZtGp895ai/3kJcV/fIYKZD345btrx+QP/Ql1gUtXlExFlYMejCPUxWKyYgWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788454456; c=relaxed/simple; bh=Og/aP01ymRggO+nQAHN57TRNgksDR8YQBwlii5mFZPg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LYDgNTKcfTBz5Hf7xYtgmO8bcTE7IdNoTb5dIryly6c2hZb4lAYRQh/oFhTO8Zu+XIFHahnykTAk6kjZDj4Sq86iQI+oAY7JyqilomZeDeEQzp9FiujVHwDMpnicSJ6zflwdpVHI9SOSnj9nQRQcomdmDNFhpUXdtPrkWCunhMY= 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=LYb8NcUN; arc=none smtp.client-ip=209.85.221.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="LYb8NcUN" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-482dd6ee390so88491f8f.3 for ; Thu, 03 Sep 2026 09:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1788454453; x=1789059253; 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:content-type; bh=yYmOvM27Czvl6pkooLClbWW9XztVFTVuY4FT6K+XRcc=; b=LYb8NcUNpUn65xfKHEdb1w1UFmtg+o2lMzQsa2yc8QmYGoVJW36ysxLosBFIgqnKbd kh2K/op/HNZJKxanSjNxXBa/EdiOoUGQQqAVam51LMrbWFIESm4/kk2NEO76sWDYCJEh wHKQUwxrKaeOUWM3Hma/kFQCnM3rLvlpW0f7aX0cB5D/j70e+DgV/4eP/OOvdbdzqxef ZXbVWv0fHx24cX43a8PiGbF+itJ5v6poUoGwcnBKue/uTjqvi1RVOG9A7tfxIVPus9I6 8WVR+If1ASOrVf2Scr62ZFhL8rf2XOZOiekqPr+ykQ2BXaNKcc/t8iBQoBescoqsQ8Cd 9U3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788454453; x=1789059253; 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:content-type; bh=yYmOvM27Czvl6pkooLClbWW9XztVFTVuY4FT6K+XRcc=; b=Tej63otb+FEkm46tGk8ALAE/U3Meq3PwTCxPgHwP30Gu6pTHTw4uJelHBIH6qgug4Q 7ERR8GTa996V/hC0wZ3T6MlllfOhliBEhp9igTCECnw8z16lNom/QZR80s6vwjESDGSd WF2WOEub5SabqriehWldqdBQdNUH5ZP3/c8STsE6rLeYZM5sUk/XwAv6ypOM3PVh8ej3 OkXlTHm6UKRV/LXRPIP7qi0OSbz3/g4/1rUCUk8ZWUY4FcvlUFJR0EQ4f1P8i8bsp+nT muMlpfsfaXb7YFWTzopKGDWTw4yWHeRnv4ndKN4LDmuDRm1uDh4XWensyuZYuDkgEYQ/ qCsQ== X-Gm-Message-State: AFuF++nRYDUdB6+uYQwqrUT4/O/4OheikQFXwCrzRqa5/KBxNwMzSrbD DW2CRk/9rGC6uoC5iA2vphDUYtk3wwJoMhjJn9Rp05c+0CBZCnVKyZYQjWbEH3EWJaJjVWottCd 5hJNcxvU= X-Gm-Gg: AYBFou18LqgCgkg/EaNSfvgZfHOdTFuXIkkRFZhL/irDNIzuwyb64iiSJT1SYsUxNUY ULtN/MT4q91H6K/fZQsKPcN+oOyQtrsvBxBfNAd16CqAw8WRAEf3Pa8z1aFoy4eEzpM4zqcczS7 ALQmJWYlLLNHYQr4dVxLU5ZoiKUkvcpgibQEzhK8yAMmMi7K6PIOJf271r+fwKhp0OLRUKhCA0S TNKIFnBwCmlurDQho+0uqHPl4pfYou++EiK4Sp+EqtIdG+6sUbeNIF7M40nFqvYTisgEokxuUyx 39Bof90bhuItdFVxpTiPCgUmS4Ct9BmUAAWFYhlYP+QmvGfrM6kuFSDdeaW7qTEhij72iqkkF06 yX39O9/eBuiHbpB8ZV6tVMPcnN8iDXiJ94P2f36oi5M18OB8frsdqFBNnaqkT+9Zrf7OK4TaoyC 9yiq89V3gWHuvIE8i8i7Rnx04DxyORrkCBN3i1h4QJ5LqtSldQrOZWc4lyIRIJ67rqAMrp4wT3n 2GqOHIL3AY= X-Received: by 2002:a5d:5f88:0:b0:484:f26c:ba9a with SMTP id ffacd0b85a97d-48587087b9fmr749853f8f.16.1788454453105; Thu, 03 Sep 2026 09:54:13 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448eea5b4sm15311657f8f.27.2026.09.03.09.54.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 09:54:12 -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 v2 1/2] workqueue: Make alloc_workqueue() unbound by default Date: Thu, 3 Sep 2026 18:52:50 +0200 Message-ID: <20260903165251.481362-2-marco.crivellari@suse.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260903165251.481362-1-marco.crivellari@suse.com> References: <20260903165251.481362-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 alloc_workqueue() ensure that one among WQ_PERCPU or WQ_UNBOUND is present. Now every user has one among these two flags. In order to achive the future goal of removing WQ_UNBOUND from the code, start changing the default behavior making alloc_workqueue() act this way: - if WQ_PERCPU and WQ_UNBOUND are present: remove WQ_PERCPU (as before) - if neither are present: add WQ_UNBOUND The WARN_ONCE() when neither flags are present has been removed and it has been replaced by pr_warn_once(): from now on, every alloc_users() without WQ_PERCPU will be considered unbound. The pr_warn_once() will be removed along with WQ_UNBOUND in the future. Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/ Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari --- kernel/workqueue.c | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 1ae3732a2c51..c1e5f2c6c8dd 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5895,6 +5895,8 @@ static struct workqueue_struct *__alloc_workqueue(con= st char *fmt, struct workqueue_struct *wq; size_t wq_size; int name_len; + bool wq_unbound_by_default =3D false; + bool wq_dropped_percpu =3D false; =20 if (flags & WQ_BH) { if (WARN_ON_ONCE(flags & ~__WQ_BH_ALLOWS)) @@ -5903,6 +5905,24 @@ static struct workqueue_struct *__alloc_workqueue(co= nst char *fmt, return NULL; } =20 + /* + * Every caller that doesn't explicitly specify WQ_PERCPU will be + * unbound (WQ_UNBOUND) by default. + * + * If both flags are present at the same time, WQ_PERCPU will be + * removed. + * + * This must happen before wq_size is computed below, since that + * depends on the finalized WQ_UNBOUND flag. + */ + if (unlikely(!(flags & (WQ_UNBOUND | WQ_PERCPU)))) { + flags |=3D WQ_UNBOUND; + wq_unbound_by_default =3D true; + } else if (unlikely((flags & WQ_PERCPU) && (flags & WQ_UNBOUND))) { + flags &=3D ~WQ_PERCPU; + wq_dropped_percpu =3D true; + } + /* see the comment above the definition of WQ_POWER_EFFICIENT */ if ((flags & WQ_POWER_EFFICIENT) && wq_power_efficient) flags =3D (flags & ~WQ_PERCPU) | WQ_UNBOUND; @@ -5927,22 +5947,13 @@ static struct workqueue_struct *__alloc_workqueue(c= onst 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 (unlikely(wq_unbound_by_default)) + pr_warn_once("workqueue: %s is using neither WQ_PERCPU or WQ_UNBOUND. " + "Setting WQ_UNBOUND.\n", wq->name); + + WARN_ONCE(wq_dropped_percpu, + "workqueue: %s uses both WQ_PERCPU and WQ_UNBOUND. " + "Dropped WQ_PERCPU, keeping WQ_UNBOUND.\n", wq->name); =20 if (flags & WQ_BH) { /* --=20 2.55.0 From nobody Sat Sep 26 07:15:40 2026 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 E9A284F4725 for ; Thu, 3 Sep 2026 16:54:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788454457; cv=none; b=HwisMEovpIqqZqUZ1qAUcYavVih6lrQcbZzkyUVpA9bpKHFAn2dJ6VwJL2WdiA4AIBrgKNpMwLPGB2SPCFZiuVtrWpExwKUAqVp15OlppT3clrjaaRSpkslUxw4COs83srPwRJl1krJgRIghvRLVW/LOUhI+kBux7bqghNHXFlE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788454457; c=relaxed/simple; bh=DGn209hkaWMFOjkQ83re+KwEpJGKoTo3ez+Bt3Mu1Zc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r+WN6Fhw5CoZzJs6LRMIvucXLE6c1AzCbdxaTLTUQoXHBEtw/k/PkE4y418BLFsRFvoxx7aW8aEIfp7axljZeIyMH/1lV4PjKZweSw65n40LC+9ObHqJWDEdlyUQQkG1xHQfl2A3w4Vx6GMgc4Gdhudh6oIYOKw6zn130lWoVUk= 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=Wzg7ITqu; arc=none smtp.client-ip=209.85.221.44 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="Wzg7ITqu" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-482e067e908so87152f8f.2 for ; Thu, 03 Sep 2026 09:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1788454454; x=1789059254; 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:content-type; bh=z6Qo+0/1udSWJ0STlhhWyqGdrWWVT73HGXaXcBOH950=; b=Wzg7ITqutyKr1H/0Fn21bJswQHFxNmjXiu16iqLlg1vJxiZVKq2SV6jCJHhieWerpA EjfWpcq6uF5LFrQO8rEZO513482NxCuagdYij5K5+ei+aKhA/AqEUuiKWUdM7MAK8SMu VId/rbSYu+tPMDpx1LP99evBmqF80BE5xxz+wfLECHSuBLXyRL3j0Bz7otZuA2vQ1BHY d+/hfi8ykDBgf4fypYqqobnIUdesj0+vshPKFTN3awpELvqQXccIsrxzy62y1O6zOhWN 5Ql0N3xN5YXATAg+nocpQ9pvTdNUcIJB/AR3l3jPCGOJN4+kn4TM1kV8CP98TVP/kAqT gY9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788454454; x=1789059254; 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:content-type; bh=z6Qo+0/1udSWJ0STlhhWyqGdrWWVT73HGXaXcBOH950=; b=DT/ew0kH5jrNw1nq04MK6bXOQyiCdpJegXlqWULGqgdiWKCBlRoJ9xIv6zgvs2aXms x9ezjHXFAZU13TyMus3octDBxzjx9DTeH637DoAD46dItKdXPL7VxWD1xFOuKO/z0AsD ugnxhifFBi8CI4MYKi4u+q5LdDJcAko4J31dvjGizK8ExMp2eoYvm7GDa9L/ollIZjmy dbehR6N8Dg6u94mp13X/BMEKXEU1/AhWbpgYvDDfkg8QKEObqSud5Qu+4z6IzY/Rk/zy WuMTMXWgVKQG+TcJprYCMUrT6IorvxNp6lFVDT88CXHMCoM7wl32aYyeggQl9EhPDIFn P5hw== X-Gm-Message-State: AFuF++mnDpKYP4DXTvnlaqRdw3zP8kxaINmgQHCDLFt0EyRa9p3qeOxH DWBAlRnDUk7SYuUV8hhOtLGi0FDdW4i5bYsFawv/EZ2VHcZipuS5oLpiz3H3GhRwZ4nA0gqMW3E aIAIhubI= X-Gm-Gg: AYBFou2b6hePeG4QnGHb03uspkdRuWjf1qnb0CvlfRMnoA4TEZI3zzovj+jZ2QIZNlh hRWEgnKbOqDlNjbeI5SwMW74Mope+mUEGinv+lGccXxplVZqFVjjjnHkj/KhAeul+Fka+tBEAK1 f3jJutLAcJ8JXVyDOV55wVnGiwPh8Gw4Bjd2eachdJ4IuqoIu4xYvDnUO9VIASHfQ+CB6pQGpMC eZ/ChMi69Q7UTdyhqUP0j6J7SrlKSmNZGyS9B8k7EViovWM6pTK4x3FkTIxmRE2/z8D1CFIOM2E Wi0R4sZpztWXG4j8O7nH4uilEfMgeh/xpCkihjlUVoQPU/10Q2GqKV49sNuYLhlt3CB4OUaUSXF LNy5AuevZoPegW8YC2wX/SC/ulngOncQDJfjzfCdxEDF7ke3+5qbUIdlSOh9SatyAuRssaRwKdC lzvTZnEbDbmj3GJUxVe379rhY//A2qrRR9fF2tmREsXKgA0/NbphZGmtImol9yo3hM3w/CAU+qj 5FfA6ryzqU= X-Received: by 2002:a05:6000:420f:b0:484:f26c:b9f3 with SMTP id ffacd0b85a97d-485872ebd4emr452855f8f.28.1788454453908; Thu, 03 Sep 2026 09:54:13 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448eea5b4sm15311657f8f.27.2026.09.03.09.54.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 09:54: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 v2 2/2] doc: Update WQ_UNBOUND documentation Date: Thu, 3 Sep 2026 18:52:51 +0200 Message-ID: <20260903165251.481362-3-marco.crivellari@suse.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260903165251.481362-1-marco.crivellari@suse.com> References: <20260903165251.481362-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" When WQ_PERCPU is not present the default behavior is now WQ_UNBOUND, so update the documentation, reflecting this change. Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/ Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari --- Documentation/core-api/workqueue.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/core-api/workqueue.rst b/Documentation/core-api/= workqueue.rst index bb770f556568..3ca636e065ef 100644 --- a/Documentation/core-api/workqueue.rst +++ b/Documentation/core-api/workqueue.rst @@ -206,6 +206,8 @@ resources, scheduled and executed. * Long running CPU intensive workloads which can be better managed by the system scheduler. =20 + Workqueue without ``WQ_PERCPU`` are unbound by default. + ``WQ_FREEZABLE`` A freezable wq participates in the freeze phase of the system suspend operations. Work items on the wq are drained and no --=20 2.55.0