From nobody Sat Oct 3 03:45:26 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D139395AC7 for ; Wed, 5 Aug 2026 14:53:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941592; cv=none; b=UAM2AzP6q6CV1THholU2UJCTC4Mcxw11GymoVh68Gzz3KJ2F/wBWLTLepy4hIE/EztbyR2B97Qz2XpnSqXLvfhsAcgsZyyBwuOsApjUl5nxFv5VVylvnFY512BPoQ/w+InZEahAaaOopthg9lzZ7ad04w6Vf8LIQpg8NipCnPAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941592; c=relaxed/simple; bh=rdmdYMH2x++Ip0ojorw7l3QrxWNtPJvBUV4AjD3Yfr4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uLzduuAHRzj11s9AhV9JlnPJqnq8GSo7GHXpXyhPF5jGa/G9v2svwBjUR9PKe11XyKeL5bebYQL7gGHuM04Ku2sEsm3MIgX6exb9t8l/Glk00k6L4ZmZHvUDlN4oQAuw7CJ8Q8SUjZcY3ZroGQazI9whBJN/EoZ+PX78jg/UbUE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=l1noytC7; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="l1noytC7" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=YzoQJ6AmlrH3orHeyfqBwZHpTshYUKv4cOhOLhYMmhw=; b=l1noytC7ki97Z2vThpi/sX9PYF tHj+W4liMBKCNizgeucH+YnZa9yFZGeh7JQ6UQC5YORGXKM7A+Ac0eVUT42c5qf8MQx4Og3pO/48Z sT+v3AueBD4n+FgRXlQkbx9e040ysU1+Th0Nc4O4H9Mlp5k/v3RIzod5dwyt1ywb8FiRGB+CTlFg+ xRFTo36GeI4dCWIX9pMAPlXr6d872gnS63nYX5V6R6xujrwqVOcbb5NDo0Bn/ScKstPi5dervH5FJ hybTmduF1zsavdABtnVWyIvB5s7gDA0CihE9GFR6h9W3AaGqQyAHamS4qOY+o/DWElpc0HagyzjNZ 4th6kiIw==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wrczR-00DzfP-20; Wed, 05 Aug 2026 14:53:05 +0000 From: Breno Leitao Date: Wed, 05 Aug 2026 07:52:28 -0700 Subject: [PATCH v2 1/9] workqueue: factor out get_percpu_pool() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260805-wq-pool-refactor-v2-1-fd498d01d695@debian.org> References: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> In-Reply-To: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> To: Tejun Heo , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, marco.crivellari@suse.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=1943; i=leitao@debian.org; h=from:subject:message-id; bh=rdmdYMH2x++Ip0ojorw7l3QrxWNtPJvBUV4AjD3Yfr4=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqc05Ku9bZyp0j07mlgyfpfmu/IcD3LQtDiQ1Os v7AQlw4m+2JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCanNOSgAKCRA1o5Of/Hh3 bSURD/wIo27Qdm9L7x/0RQsTOCXd5S2QCVDQpYyakZSis/wYGUqGj8XgwgFMrxxdmszBpPFTV2g WlTTyHnwuFh5cmyIXrIexk7zfTMIvfouY/Sf7Uop6sYdtfxVc2XvM1T+pHci48IAmMV0aCjBBvp AbulH6DMLHzznRs/966Is5e41UaffJjyqrgKF8Of6kfD0bq8YFoR/D48/dUblZXSYcqQQi3Hm9h h/XuREH6fQ11xBm8GZcHlZ0bOI0ZsbfNwqSj5pzI43lvsKn3H2Zkf/6wev4+jtpYv+zE74o7jmS hEr63UC4Z7e5SBXZfinpzd9J5SC21kjvv2OvJQOT6+nKTKwZEr9w60R0shx/2pmA/qjjsjzMBSg JAnueg7chYnNnEYbITyAo1i8mJtXwePaKVSR7FJ4UCsGVEtG9ElL6oebfXXQ0rA6JCs7QkgxujZ A6pwHK96FjDa4EZ7ezpGZ9qR7DlGIVC2CncqSlRGQsyjlcT8wh86u1GwjfNZBkNQ4LnI+3wyEo2 26slaZGNpTkoiUNwWTpZE5hfpuAa0+67kTgiKkqQ/Hp+jn/hF4ZMbrmIHPCjUftU5+cp2/8LUHf cVpuLoFgtuKif+o/s0XQI1ZfXoZhmM+jO7cuOlFa93uWl1MmgMvr1rsIbjeREUIUbMiBMvN3enO cLsu+qKChHzfbNA== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao Move the static per-cpu worker_pool lookup in alloc_and_link_pwqs() into a helper, get_percpu_pool(), so the lookup can be shared by other pool-selection paths. No functional change. Signed-off-by: Breno Leitao --- kernel/workqueue.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 4ec3db31493d2..63a39bb3f5e47 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5350,6 +5350,20 @@ static void link_pwq(struct pool_workqueue *pwq) list_add_tail_rcu(&pwq->pwqs_node, &wq->pwqs); } =20 +/* Return the static per-cpu worker_pool that backs @wq on @cpu. */ +static struct worker_pool *get_percpu_pool(struct workqueue_struct *wq, in= t cpu) +{ + struct worker_pool __percpu *pools; + bool highpri =3D wq->flags & WQ_HIGHPRI; + + if (wq->flags & WQ_BH) + pools =3D bh_worker_pools; + else + pools =3D cpu_worker_pools; + + return &per_cpu_ptr(pools, cpu)[highpri]; +} + /* obtain a pool matching @attr and create a pwq associating the pool and = @wq */ static struct pool_workqueue *alloc_unbound_pwq(struct workqueue_struct *w= q, const struct workqueue_attrs *attrs) @@ -5664,19 +5678,9 @@ static int alloc_and_link_pwqs(struct workqueue_stru= ct *wq) goto enomem; =20 if (!(wq->flags & WQ_UNBOUND)) { - struct worker_pool __percpu *pools; - - if (wq->flags & WQ_BH) - pools =3D bh_worker_pools; - else - pools =3D cpu_worker_pools; - for_each_possible_cpu(cpu) { - struct pool_workqueue **pwq_p; - struct worker_pool *pool; - - pool =3D &(per_cpu_ptr(pools, cpu)[highpri]); - pwq_p =3D per_cpu_ptr(wq->cpu_pwq, cpu); + struct pool_workqueue **pwq_p =3D per_cpu_ptr(wq->cpu_pwq, cpu); + struct worker_pool *pool =3D get_percpu_pool(wq, cpu); =20 *pwq_p =3D kmem_cache_alloc_node(pwq_cache, GFP_KERNEL, pool->node); --=20 2.53.0-Meta From nobody Sat Oct 3 03:45:26 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B6DD395AD8 for ; Wed, 5 Aug 2026 14:53:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941596; cv=none; b=dG/u7ObjKkUa7srq8CxuSjoWj1hEHA6YXRfSw5/HPdv5FTbqjpCNwBRXdRKqACp6UB47lPofv0i7jaLpvnkwNLNT9J6VDnrlpoldtoMFIg4b7owVoUifuHuGBRAmazxw4MBfDU4O3cO9zFvosFDnYa6s3LdQWXTjPTNoo397hlg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941596; c=relaxed/simple; bh=xAi6kBvuYIEmt9A/cEOJxNoq7olclmWn2J2Xbsqx1Uk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OjvZ55YkGBCG8uHnYwEYtmymYHhQzZ1xx8KabNnpkriSyYelN9r6cG7AzZQI3nmuqMUxwmGLFSgFUWGKT59t4Avwnp9uj+Dv3NvlxPttn7PP4MdZjSqwFf6Got2EkHPIlnKfhkic8MfobtUXJKaMMkDy/R1OiU2UE2UiNHCy1Ug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=uic0qvZc; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="uic0qvZc" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=dsT+GcKDMTZBRR1yFtKozWTonjVk/c9llDhBHWOpwqU=; b=uic0qvZcfZA+PzrPVssDQQHiE6 9iwth+xjAxeL1gP7pj6SzVkPDnPO+/Fctn6MHRWcbq1wHNIvetg1U6TDYrY+K633ZVg7Dc0sB1ZDU rEkCRRLsfyGJQmUxm1X3APiG21RbxywHkzMmyWi6gpcqIJft/UcuUtdjYS9JAHWF+Y2bnXMebZfCt nTxFO9okWvecpYbfGRuDU623duK/sXu9sr4oFgIIZRTUkivGPrWjkwPwGGZ9EDK5NqcxbdifRwe7x ctXKUqg9XvSV5IhenERLajrIYnIMhLWpRyZU7hQ4Pf4MzzetmSfeIFIiIpmC8WhEwcyWoKKy6JHps 0ZyXG4Qg==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wrczV-00DzfY-0C; Wed, 05 Aug 2026 14:53:09 +0000 From: Breno Leitao Date: Wed, 05 Aug 2026 07:52:29 -0700 Subject: [PATCH v2 2/9] workqueue: factor out alloc_and_link_percpu_pwqs() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260805-wq-pool-refactor-v2-2-fd498d01d695@debian.org> References: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> In-Reply-To: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> To: Tejun Heo , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, marco.crivellari@suse.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=2147; i=leitao@debian.org; h=from:subject:message-id; bh=xAi6kBvuYIEmt9A/cEOJxNoq7olclmWn2J2Xbsqx1Uk=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqc05Kh2SVGB2zD2EwXH27JClBEaWbif5d2DE3l /HldOweCt+JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCanNOSgAKCRA1o5Of/Hh3 bfP6D/99w9EVNW+Gf3hQGdyZpaCSWshCqPBV6oArP4Atuqm/DiYpGc+Kr32ZDr09RGUzCRiwuWl zn0eOn9n7i4sJQShlgMR+EQuDfFxTdtzZF3Z6uhqnM8fou6HCwB5MH6BpO0bGqiyuROfamof6sV dZkkxb+1MsAbqw0YS+EP3l3aMSwN73I8yT1CHT2JWgt+wuhDEjwCK6HTqi+I4QNZdAnxcBnSWir thlrj1TLoXFy09vTCOzrm/MZ+gvqZuMvzIbYGfaZWDlLtwlT5SFtVWnYLgHg4ona0UCyccNsHwU C/bv47/nDi1TFT7CXNYDWObmFSeS7+I3NIwrh4kbtb+Fda+l2YCLY4E5WEHwF4Jf5Fmm5njnwSG shpd3azINv69R0YAn1lNyPDGOr9TJT+dlIa2TMOONFQK4q2o5Si1jwL78SjSg75vsBVCbVmUYNv ecfrv6ECwZ4iaVfYqaJX6Sp6cV9/Dpo3D0ffBViWQyRmE75IBI2pDu+mu0VVekJC5FcT3jwx1A0 edj51aIZcHQKER8bPfaNOXBy7FQzpQwUaa98Xa+Y6sQiTFjZ2OwOpBH5qkCKMQ2ybDeOBbJKz0X 9PJKzjbk9aX9R+IEwUflogt66Svesxe1wnp5qey+bwFm7D2Xf2Fv8WaeGnSjDNKwOERyRxf+LJK 4kKEgObi/OSBkQQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao Move the per-cpu pwq allocation loop out of alloc_and_link_pwqs() into a helper. The inner allocation-failure path now returns -ENOMEM and the caller jumps to the existing enomem cleanup, equivalent to the previous goto. No functional change. Signed-off-by: Breno Leitao --- kernel/workqueue.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 63a39bb3f5e47..b386a457c0381 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5666,6 +5666,28 @@ static void unbound_wq_update_pwq(struct workqueue_s= truct *wq, int cpu) put_pwq_unlocked(old_pwq); } =20 +static int alloc_and_link_percpu_pwqs(struct workqueue_struct *wq) +{ + int cpu; + + for_each_possible_cpu(cpu) { + struct pool_workqueue **pwq_p =3D per_cpu_ptr(wq->cpu_pwq, cpu); + struct worker_pool *pool =3D get_percpu_pool(wq, cpu); + + *pwq_p =3D kmem_cache_alloc_node(pwq_cache, GFP_KERNEL, pool->node); + if (!*pwq_p) + return -ENOMEM; + + init_pwq(*pwq_p, wq, pool); + + mutex_lock(&wq->mutex); + link_pwq(*pwq_p); + mutex_unlock(&wq->mutex); + } + + return 0; +} + static int alloc_and_link_pwqs(struct workqueue_struct *wq) { bool highpri =3D wq->flags & WQ_HIGHPRI; @@ -5678,25 +5700,8 @@ static int alloc_and_link_pwqs(struct workqueue_stru= ct *wq) goto enomem; =20 if (!(wq->flags & WQ_UNBOUND)) { - for_each_possible_cpu(cpu) { - struct pool_workqueue **pwq_p =3D per_cpu_ptr(wq->cpu_pwq, cpu); - struct worker_pool *pool =3D get_percpu_pool(wq, cpu); - - *pwq_p =3D kmem_cache_alloc_node(pwq_cache, GFP_KERNEL, - pool->node); - if (!*pwq_p) - goto enomem; - - init_pwq(*pwq_p, wq, pool); - - mutex_lock(&wq->mutex); - link_pwq(*pwq_p); - mutex_unlock(&wq->mutex); - } - return 0; - } - - if (wq->flags & __WQ_ORDERED) { + ret =3D alloc_and_link_percpu_pwqs(wq); + } else if (wq->flags & __WQ_ORDERED) { struct pool_workqueue *dfl_pwq; =20 ret =3D apply_workqueue_attrs_locked(wq, ordered_wq_attrs[highpri]); --=20 2.53.0-Meta From nobody Sat Oct 3 03:45:26 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9472A38F63D for ; Wed, 5 Aug 2026 14:53:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941598; cv=none; b=gvBv1qA+f564p262TJUvm193ft0hSsFcYkRSUrHshv2dWdyU/BwbeHa2NB7dRjIPotBf6U5rq0/ritE1+LBZTdhiiuzA2IVxOgA/6+q6De7c2sVPG6Wsqzn1HoqsMsbN/8mnbp1ufDdNqP7wFt2Y1bY0+joyvMj34rnkalSUzPE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941598; c=relaxed/simple; bh=iHyGjhvL/zsVhfksAQkvPcHhu0iHCwSfuJ/D9+uO+9M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WnAuv3dZstF/C7PZk+v1ejtbHa5MuMSURl/d44OSFohMlOcBfxhmtAIoApIeYIcg4um+Bv2NgjBIfEAuGGQ8fUDy2t9vHEh+resRJQ+wpQORBYvGqRrA9Z8gVy+60X+sMYzsmJ7jshrFrq3RWSjilr6NuCkE7cMeY/PcqnsFqsU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=A1OFTH+M; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="A1OFTH+M" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=qYTWoW8MTq8KDhRoHL+AjHM4pXANDxxOe0OUINdX0Lw=; b=A1OFTH+MhLqDFLQpLMdZv/So7R +yyJNB8G69Xt5QtwUad9eTiyrNIqsQ7gBXNeSP/CKmyGH041cSdJqtF8s8iWkw07qdJLR5Ans5o+n erlAWUmSA2bkVxfgqhjPN4e5qja1nkj6nk27loHszhGHjc8MmL5VEWZA6d0LNDnx6CZq7Crd5WcSh m4QxeXaFDPjHu244DkMZWc62OGZKaTKAvmfpiKSS57aTmYwdwMDOR5CLeeG1n80p4IV3jh7YodXYq prGz/q3Couhluz9cFI6nvDXBqXcFkIgBWI8PcTMi+0vw1hCiodHZ8y2JJQifSF+2NT/YT2cQcU0/s gw8Uq+nA==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wrczY-00Dzfn-13; Wed, 05 Aug 2026 14:53:12 +0000 From: Breno Leitao Date: Wed, 05 Aug 2026 07:52:30 -0700 Subject: [PATCH v2 3/9] workqueue: release pwq pools by pool type Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260805-wq-pool-refactor-v2-3-fd498d01d695@debian.org> References: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> In-Reply-To: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> To: Tejun Heo , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, marco.crivellari@suse.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=2198; i=leitao@debian.org; h=from:subject:message-id; bh=iHyGjhvL/zsVhfksAQkvPcHhu0iHCwSfuJ/D9+uO+9M=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqc05K7hr0aLGQXfrxJugEf98knb9QHCg6nf1Ii cbYRLFBAf2JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCanNOSgAKCRA1o5Of/Hh3 bWprD/wLM5Tkw3id/zxVKUkczC/UBMnachchsoBn1D5+hSC+lv0VytSnkWrES/JXRT36wriP05+ xJWfjozZBqx0UoxC1NGSrp+AUiwGq25MIwUTNkFIgHWMSOF1BbYn07WbVWaSpN487z2x27lewTt HC9gM8N9RhDCrv2xWADlQCq3hT4xUnKtz33bLBkMLu4vModLR9UXsqJb/X6Us/OHpzzGEze9QPp vrEAC0q9Z+xP/13IlbzdCcp+gYRPytzKpMd/7yNH7esYP62/t24PjbLk9R4+EUybX5riEGbNasR N9DmgXxv11GWtR5PYcDxl8/q57ZsH+6Z12QSj0bE/931XadhHyxjh5Do4gz4ISQgLB8mtpg4pcc PIjg212eG5Qlx4l6O2vegKNqxmZ4hP8at+iue71uTlqe3CuOnUcdTPCWaokNqagN9D4ATWXR0Un epV210dQ3lxKUWHe2X6+50druTv3VF9WpJxa0DL+9isQMIyPhJ4oGVoa3BLtHoTPRIfG4IPpayR z+B0CMSaAx1kt7K1orxNNVzYsq4HHk5FJb4xGcgt8VpYHBc9TySRmzu4KLsSVRBJvsZ1eUZo0ZT TuxO3zq3MbFSKKZtKI9MJVL7Byw8dPYd1kr4MhCFMNeFi3QtjFRmSR+AZty+O2mRCALAPMYmIe0 buuvGktv6OCL9Gw== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao Add is_percpu_pool() and test the pool directly for per cpu. Convert the other open-coded pool->cpu checks -- in put_unbound_pool(), pool_allowed_cpus() and the workqueue watchdog -- to the same helper. No functional change. Signed-off-by: Breno Leitao --- kernel/workqueue.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index b386a457c0381..b96090c85bcaa 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1604,6 +1604,12 @@ work_func_t wq_worker_last_func(struct task_struct *= task) return worker->last_func; } =20 +/* True if @pool is a static per-cpu pool rather than an unbound one. */ +static bool is_percpu_pool(struct worker_pool *pool) +{ + return pool->cpu >=3D 0; +} + /** * wq_node_nr_active - Determine wq_node_nr_active to use * @wq: workqueue of interest @@ -2753,7 +2759,7 @@ static struct worker *alloc_worker(int node) =20 static cpumask_t *pool_allowed_cpus(struct worker_pool *pool) { - if (pool->cpu < 0 && pool->attrs->affn_strict) + if (!is_percpu_pool(pool) && pool->attrs->affn_strict) return pool->attrs->__pod_cpumask; else return pool->attrs->cpumask; @@ -5121,7 +5127,7 @@ static void put_unbound_pool(struct worker_pool *pool) return; =20 /* sanity checks */ - if (WARN_ON(!(pool->cpu < 0)) || + if (WARN_ON(is_percpu_pool(pool)) || WARN_ON(!list_empty(&pool->worklist))) return; =20 @@ -5273,7 +5279,7 @@ static void pwq_release_workfn(struct kthread_work *w= ork) mutex_unlock(&wq->mutex); } =20 - if (wq->flags & WQ_UNBOUND) { + if (!is_percpu_pool(pool)) { mutex_lock(&wq_pool_mutex); put_unbound_pool(pool); mutex_unlock(&wq_pool_mutex); @@ -7949,7 +7955,7 @@ static void wq_watchdog_timer_fn(struct timer_list *u= nused) lockup_detected =3D true; stall_time =3D jiffies_to_msecs(now - pool_ts) / 1000; max_stall_time =3D max(max_stall_time, stall_time); - if (pool->cpu >=3D 0 && !(pool->flags & POOL_BH)) { + if (is_percpu_pool(pool) && !(pool->flags & POOL_BH)) { pool->cpu_stall =3D true; cpu_pool_stall =3D true; } --=20 2.53.0-Meta From nobody Sat Oct 3 03:45:26 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5542376A12 for ; Wed, 5 Aug 2026 14:53:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941601; cv=none; b=Dn6TX8D1w6zp2rDdtvifE9PNZb7bc+Nt+gGtLxYg34fURJ78PXEbJGoyklw4VYnSXoZGvwxNndN5cHFMdV2xc/WBOldcvFGEJvpkWwn2ezxd+Lb5RgdPvZdw5e2VXTRs6idWIEzTamsIO/6z+lQbT6K52oQKTQcgjzBskLqjANI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941601; c=relaxed/simple; bh=CWM4XPMimBVDvcLFphvESKoVCT3CFiV7ETMNpYfnfjY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KGKZwMFTugI+YOVBJbHbpp2OfZzfdv/4NUfIWYMW9850HwjfUKUD5wsPekNq6y4/NjAFqJCV+AMWrh8p28u/xidSSGZIP1BSSEPXSBApHk6ufcYdvPIexQ0lS5D8gSb+fWr0FrFwt2ROBk20d36DDD6FRW0/6UILGECyVAmQPFw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=omGInGA0; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="omGInGA0" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=vCb/gSvK9zHTsmz/4PR241Aw4yy6BI1t+7L5kb9YhXA=; b=omGInGA0+ie9EHjNBajXYnal2Y oruopdH1xsjshnbuoEtfH/LXGwmAFaTGdJ9Sp+bSXiBOoZKbcdXT3RgAMxjEwq4PRHwN3INP6+jd5 OFiclNh8C78hWBGr5kGrs2N4l3meGq328N7NXEGuroJswAfOfQpMifMvkKLA931ot+EYRAhpjbg6E CE0pleoRlok9ZnFf6uwJUbUGrHGE7sxKKgw75pGnIjh9ZgXKBxI81Zw9y4Bk1rmw7NycuhZkkvEir mwQMqTeYz274Rf7ALh3Q2TySjHSCsVuk+tPe18pnNr+kRhTduwe+F4Kq/VFLfqs2f3hRBbxhZRpCU aKWcLFvg==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wrczb-00Dzfv-1E; Wed, 05 Aug 2026 14:53:15 +0000 From: Breno Leitao Date: Wed, 05 Aug 2026 07:52:31 -0700 Subject: [PATCH v2 4/9] workqueue: account nr_active by the backing pool Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260805-wq-pool-refactor-v2-4-fd498d01d695@debian.org> References: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> In-Reply-To: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> To: Tejun Heo , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, marco.crivellari@suse.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=3446; i=leitao@debian.org; h=from:subject:message-id; bh=CWM4XPMimBVDvcLFphvESKoVCT3CFiV7ETMNpYfnfjY=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqc05K+m+sbMbMaPVBS92HwFewQtCupNXVko3+p hu/qM03Gb+JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCanNOSgAKCRA1o5Of/Hh3 bcybD/4gVI25qhIj7QduI9RcRSoJePsCw8bJqwh3RliizA2lZhUR+V834/3shtY06Jpi/i9kNm1 EmL4AQvsVe0nkDo5/qdmi6aYZ9m/bQnTCnmVE14hCS5+7MLrdzWzuO7/hJK+9Nt4a8isrCJjIFK s1TCLC8ePusvV627IzotRl9gbPPEjhh4WcXGWBImGo1C4Wsxl924B6/ZoJPNycirFmbFpP6Usqu MqPcHSuv/EvHGyTAvqMoLtjH3HVBDnx6LsJRYAETwThmwUO/5LEr0+35rnfpJjS88A3Db4z4Tp6 cJbY+g2NdHfaz20mIjGLfBwSGXECqeZ6kNmjPY/yDBqPKbEEpnpmYclwO2t84lmQHLHskbaYOqx w58Eeu8lnF1VyTgTBQjmK1OxqQW7sR6KuXJSLwgq/l6MyW2jnZiSWnDs3seYt65FB+lxIEE6lss TEA4VaAX6zBuf16MDoa5IiLOiAcZoDDPLb0FmjjgABOwgJo7UC3c7EMGWYYTU9NnC7657Q+NdVJ FZkYmEoxFT0xiX9MUnExfSOf+z4+C7p6TAC39OaOpWlFzFKmfBnHPhhVf0Ee91LdNLxf5giKTga hLC6tsjDBiQ/eEXMV2+cnhlKr6RHcKsgX/dpBvBodY79GEwXZvEXPplecP9JZzOjn14cpphMBnY 8df6jhmu07koYNw== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao pwq_tryinc_nr_active() and pwq_dec_nr_active() choose between the shared per-node nr_active and the plain per-pwq one by testing wq_node_nr_active() for NULL. Test the backing pool with is_percpu_pool() instead, so the accounting follows the pool that runs the work rather than the workqueue type. No functional change. Signed-off-by: Breno Leitao --- kernel/workqueue.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index b96090c85bcaa..7b20d459d6442 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1615,9 +1615,8 @@ static bool is_percpu_pool(struct worker_pool *pool) * @wq: workqueue of interest * @node: NUMA node, can be %NUMA_NO_NODE * - * Determine wq_node_nr_active to use for @wq on @node. Returns: - * - * - %NULL for per-cpu workqueues as they don't need to use shared nr_acti= ve. + * Determine wq_node_nr_active to use for @wq on @node. @wq must be unboun= d. + * Returns: * * - node_nr_active[nr_node_ids] if @node is %NUMA_NO_NODE. * @@ -1626,7 +1625,7 @@ static bool is_percpu_pool(struct worker_pool *pool) static struct wq_node_nr_active *wq_node_nr_active(struct workqueue_struct= *wq, int node) { - if (!(wq->flags & WQ_UNBOUND)) + if (WARN_ON_ONCE(!(wq->flags & WQ_UNBOUND))) return NULL; =20 if (node =3D=3D NUMA_NO_NODE) @@ -1782,13 +1781,16 @@ static bool pwq_tryinc_nr_active(struct pool_workqu= eue *pwq, bool fill) { struct workqueue_struct *wq =3D pwq->wq; struct worker_pool *pool =3D pwq->pool; - struct wq_node_nr_active *nna =3D wq_node_nr_active(wq, pool->node); + struct wq_node_nr_active *nna; bool obtained =3D false; =20 lockdep_assert_held(&pool->lock); =20 - if (!nna) { - /* BH or per-cpu workqueue, pwq->nr_active is sufficient */ + /* + * A concurrency-managed per-cpu pool accounts nr_active per pwq, so + * pwq->nr_active against wq->max_active is sufficient. + */ + if (is_percpu_pool(pool)) { obtained =3D pwq->nr_active < READ_ONCE(wq->max_active); goto out; } @@ -1796,6 +1798,8 @@ static bool pwq_tryinc_nr_active(struct pool_workqueu= e *pwq, bool fill) if (unlikely(pwq->plugged)) return false; =20 + nna =3D wq_node_nr_active(wq, pool->node); + /* * Unbound workqueue uses per-node shared nr_active $nna. If @pwq is * already waiting on $nna, pwq_dec_nr_active() will maintain the @@ -2013,7 +2017,7 @@ static void node_activate_pending_pwq(struct wq_node_= nr_active *nna, static void pwq_dec_nr_active(struct pool_workqueue *pwq) { struct worker_pool *pool =3D pwq->pool; - struct wq_node_nr_active *nna =3D wq_node_nr_active(pwq->wq, pool->node); + struct wq_node_nr_active *nna; =20 lockdep_assert_held(&pool->lock); =20 @@ -2024,14 +2028,16 @@ static void pwq_dec_nr_active(struct pool_workqueue= *pwq) pwq->nr_active--; =20 /* - * For a percpu workqueue, it's simple. Just need to kick the first + * A concurrency-managed per-cpu pool only needs to kick the first * inactive work item on @pwq itself. */ - if (!nna) { + if (is_percpu_pool(pool)) { pwq_activate_first_inactive(pwq, false); return; } =20 + nna =3D wq_node_nr_active(pwq->wq, pool->node); + /* * If @pwq is for an unbound workqueue, it's more complicated because * multiple pwqs and pools may be sharing the nr_active count. When a --=20 2.53.0-Meta From nobody Sat Oct 3 03:45:26 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A3BB3A2543 for ; Wed, 5 Aug 2026 14:53:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941604; cv=none; b=vEpIW5s5/NBNmKDby/jw0S9STTqwrRqwp3IxBh2iGoYitplITTwg4WJhf6pxIRvxTMVIuioQXU0mqL17dcmoRCzdr0CnuRQUEmQUM5WVd6uXzTEYqyV+AZzyvs4fRgANPD/HFQwP0hcDCyn+AlEfamOWfr4Txl20c2aOr/vBDC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941604; c=relaxed/simple; bh=9J2URBwmp8dqVyvr3sRKvsfL5EwqclaEfEVQ1DatMM0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KZHlisR8SOfUZnHfiz06zkbbfr7/J7RzA8zB+k4FWdyvykDxtnMU+Ry1vGgIww4qslhooG8rTv3d/OEQObtJUnWkTpoKC9pG0QA+FpSyivFKVY0cfCqMrXlndS1ye1wB3H9/FPG+TCKjR3sibIjJr7BK4H1ZCDUDXjRH4/UDpwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=U9FWUV1f; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="U9FWUV1f" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=Cow8wDWZXyX0G4TNL0vv+MEB5uitcjI4QxAISbkNgeU=; b=U9FWUV1fYFKrp+1ttFvQGIO0kY cT8gXVDuIntx8J1fE0MBq05jcXI/N5eOLFfYOk8SSY3UwbckGhl5M32uqOmHruq4F5xoniD9YdY12 2sbLy7Q4V0Fyv5PiDuDOJXmZ9bTXrMGwZ4CWt50Mss7x5Z40J0XoZHV3BmgiJvQsb+2769S5lOmYy JwToSR7R6A0D1oNB689uvCOQEuxPcbckITv6BE4PZXCOnRNfThklt6W741EZUVv0w3orVtMmYmnqo YuToOSwpo4QH9ZwSUp9JwSm4rR7n5la3C8LUcLjV4l0prFjf6Yr1f8wD85X8lOvxi4d+v24puNbmz HuEUMTqw==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wrcze-00Dzg8-24; Wed, 05 Aug 2026 14:53:18 +0000 From: Breno Leitao Date: Wed, 05 Aug 2026 07:52:32 -0700 Subject: [PATCH v2 5/9] workqueue: test WQ_UNBOUND explicitly in the hotplug loops Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260805-wq-pool-refactor-v2-5-fd498d01d695@debian.org> References: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> In-Reply-To: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> To: Tejun Heo , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, marco.crivellari@suse.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=1257; i=leitao@debian.org; h=from:subject:message-id; bh=9J2URBwmp8dqVyvr3sRKvsfL5EwqclaEfEVQ1DatMM0=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqc05KcEO6btVKgAEJfBL5tH1hFRHx+1Dp+Bah+ LazjkN0mB+JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCanNOSgAKCRA1o5Of/Hh3 bQNfD/wNhw9SYidNsyFj5XgEHw9oCATjEeAt+nVHY2DM27T3HCRiTY6VzCQZKHVIVEz1AU1vkwM jEZ6uT4iffSJCgq2stXrrg8FOUqeh4KCf9b5XAjvynDDw3uC+YHunARCB3eDmGHQ6IOMut8ps0K slf8D9arfI38e+Wth+ZEGIJVS3pbJ5P4Jah6YW172mi4lY4ieIMO0kcGbkkhG1a+q474qg+YZWB w6kHsXW3tn4MZxnWsR2UPV8tVYD0+D0ggt8mxviFh2Zp0wVdcxml7d3bnuLSe7Yh6gWzsBymQJQ ZU8OSHBPh4OTViSD58/+r7gSXZNJB8Fd4VouI0S1S3PkO58wZQF7LKN1YZrikFfZ0+F1jvBohNz BvIpFjWDdLXmCz3QPASrS8TAyIgoIdXVmvRJAgpu+JkWX0Qo1Ro8qKPHuIwUB4Db89D+akL49v4 X6oIGqtmHrbNEYk0y3jtGOa2tx/CT21tvc08+hN/UYakmpYrbajdfzFbloX3ONzRrzWvkpZgEFm yAAGaxPBRVNuAkj+8QMGQxrevLL4zfQD62RIc1Lo/muh2lCw/C/WxDcn1RRdv+a55zaDQnxgN7w LP9a/hFgHwG+GFAA/tE+5et2oB41JPls7qSKyWQuBmacXW/UvQ1/YiM0QN08P4VgBWRCE1t9S2b uencrF6AGbPWVZQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao workqueue_online_cpu() and workqueue_offline_cpu() decide whether a workqueue needs a pod affinity update by testing wq->unbound_attrs for NULL, which is only meaningful because the attrs are allocated for unbound workqueues alone. Test the flag instead, so the attrs can later be allocated for every workqueue. No functional change. Signed-off-by: Breno Leitao --- kernel/workqueue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 7b20d459d6442..b6458ee53852f 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -6945,7 +6945,7 @@ int workqueue_online_cpu(unsigned int cpu) list_for_each_entry(wq, &workqueues, list) { struct workqueue_attrs *attrs =3D wq->unbound_attrs; =20 - if (attrs) { + if (wq->flags & WQ_UNBOUND) { const struct wq_pod_type *pt =3D wqattrs_pod_type(attrs); int tcpu; =20 @@ -6980,7 +6980,7 @@ int workqueue_offline_cpu(unsigned int cpu) list_for_each_entry(wq, &workqueues, list) { struct workqueue_attrs *attrs =3D wq->unbound_attrs; =20 - if (attrs) { + if (wq->flags & WQ_UNBOUND) { const struct wq_pod_type *pt =3D wqattrs_pod_type(attrs); int tcpu; =20 --=20 2.53.0-Meta From nobody Sat Oct 3 03:45:26 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 213433A6F04 for ; Wed, 5 Aug 2026 14:53:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941607; cv=none; b=KQRN+BGgsWnyAIno6TFL/UQyofdd93Fuz3IAoMWIVqWW2cT4sb+hAJahNv1BcyHV8vab7LuaKpbBujmkpcUTqCf5sSwbiA5npo0rdHHMXH0vLz2qGpFtnujj4tfWCLyyI/zguRXHbd2ktHmINsXquxCK/TSXZvR8bFY9bQu5Dv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941607; c=relaxed/simple; bh=/Tk4GsnNCc+8xkF7b+iwB0KqaYbIYKyFlG3OYOQMPUw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ya9LUvVKLV1nfG3QxqZRcyHstIpehxR9NBlhO/9Z0rdg0HeJ8k36uuVPo9J2aMGrrvTRnPX4rP846HQqgT5YbSlxbkYnoR8p7Y549xdIXNJ3qO+LYtc9fsKkH4asotnIE0AdoO4tv/BlXE4QnNa4r+TwNcgyu/M19wA5hkgDXpg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=EoS/+09m; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="EoS/+09m" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=H4n42a97Bjf/jMVBIPhFScO3Fzdfr5SY0KRt8vBBajY=; b=EoS/+09mT6r/So7Psvh2vk+QcJ nb6qIR0RaVYzcgtzm3i3KIRtgJJs36cssA+NGS3rDAPb5YgK4b3Klj6pFCbDD/1tUpqQvr7aDI0+H XW/lHlZYFmkq1o5JGxp6nEfTUMAFSBko9K1BipLOVp2sfEVD8K8+wFKpeHahEkqtNIatfgR3mlu6u U52IYjI7fp5bJH+2/qEsNI/iIkoeqiHUdA5srt7Doyh5Z86KTcvqjYjauuNORah/yZ1jQZVReLc1p 33X7qDooN83NT8mtTewWzyuxuWX20mj3q/KhS72N08psKIOlgKkI8xGwiHJVNLb1uS6jcLcegFcq2 BFUOXonw==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wrczi-00DzgM-0C; Wed, 05 Aug 2026 14:53:22 +0000 From: Breno Leitao Date: Wed, 05 Aug 2026 07:52:33 -0700 Subject: [PATCH v2 6/9] workqueue: rename wq->unbound_attrs to wq->attrs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260805-wq-pool-refactor-v2-6-fd498d01d695@debian.org> References: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> In-Reply-To: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> To: Tejun Heo , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, marco.crivellari@suse.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=7918; i=leitao@debian.org; h=from:subject:message-id; bh=/Tk4GsnNCc+8xkF7b+iwB0KqaYbIYKyFlG3OYOQMPUw=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqc05KZXh9RYxbXWFiEIdRvhfwDgXHzE4rSV3VV WJdfKW8v7WJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCanNOSgAKCRA1o5Of/Hh3 bfxlD/4/ZWlriaaZA+REw6b3Tf2Iji8Wz320F+GHIhLj+D0KHELhp2XGKqA3VjxrOorG5NPqLGc B7uDy5A+ARhSw3CnK4ollxqaQWSGcwDCNdH4zrwvpNaFEdr2Y+ZpWh+c5Ek+4vF75OFBauB7mef dnxocf2lB2O3SvEjWKIFyZhXxm5JAw4lT2AbdAtRDZn7rZw2JfrX6EucSNDChcpuBANTFgTutIG WzmqFYyQT+TEBPfAk6mhfHMNfcf8S3img+c/eegaQET3xwRqlFTx79WZ+GEJsFdruKTuYE0NaTT 5Y4mi6IPh1ilSd7LB85qSIDLs9evsfEzZtN7qbgq5KFJruxh0j6CPN9M2pxxL72K61xqq7f8O0u MVpFft4FJn+irPk4py56NQLGvldpY00tvPjefp7LL6zle1vthKQPUR7myy1+XqP7ti6wirSoSuy ZIpSZODZ/ae2mJ4lQRdWnSuUxuU45lDNdSt0LyIJp7Wa8gimTYYUvXPS/trjMB3anYVGgIWXSss efQ8TfI+PEcc3BzaOMajHlMecCSGgQBnlvnfmhNheZmCn6lsTbRAQgMn5jgLecnNQ61NOLOwuDH RiIwQCCt6fytrizUdVetDjZmfDzIEPxg1HzDcNBFRI/EMVFx0hBi4A8lJirUrfwPvt0ChEdbKxZ vrDeW1RKv9fAEiA== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao The unbound prefix says which workqueues currently have the field rather than what it holds, and the next patch allocates it for every workqueue. Rename it first so that change stays a single line. tools/workqueue/wq_dump.py reads the field by name, so rename it there too. wq_sysfs_unbound_attrs[] keeps its name: it is the set of sysfs files that only unbound workqueues expose. No functional change. Signed-off-by: Breno Leitao --- kernel/workqueue.c | 38 +++++++++++++++++++------------------- tools/workqueue/wq_dump.py | 6 +++--- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index b6458ee53852f..fbe13c9be4c28 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -371,7 +371,7 @@ struct workqueue_struct { int saved_max_active; /* WQ: saved max_active */ int saved_min_active; /* WQ: saved min_active */ =20 - struct workqueue_attrs *unbound_attrs; /* PW: only for unbound wqs */ + struct workqueue_attrs *attrs; /* PW: workqueue attributes */ struct pool_workqueue __rcu *dfl_pwq; /* PW: only for unbound wqs */ =20 #ifdef CONFIG_SYSFS @@ -759,7 +759,7 @@ static struct pool_workqueue *unbound_pwq(struct workqu= eue_struct *wq, int cpu) * unbound_effective_cpumask - effective cpumask of an unbound workqueue * @wq: workqueue of interest * - * @wq->unbound_attrs->cpumask contains the cpumask requested by the user = which + * @wq->attrs->cpumask contains the cpumask requested by the user which * is masked with wq_unbound_cpumask to determine the effective cpumask. T= he * default pwq is always mapped to the pool with the current effective cpu= mask. */ @@ -5098,7 +5098,7 @@ static void rcu_free_wq(struct rcu_head *rcu) =20 wq_free_lockdep(wq); free_percpu(wq->cpu_pwq); - free_workqueue_attrs(wq->unbound_attrs); + free_workqueue_attrs(wq->attrs); kfree(wq); } =20 @@ -5548,7 +5548,7 @@ static void apply_wqattrs_commit(struct apply_wqattrs= _ctx *ctx) /* all pwqs have been created successfully, let's install'em */ mutex_lock(&ctx->wq->mutex); =20 - copy_workqueue_attrs(ctx->wq->unbound_attrs, ctx->attrs); + copy_workqueue_attrs(ctx->wq->attrs, ctx->attrs); =20 /* save the previous pwqs and install the new ones */ for_each_possible_cpu(cpu) @@ -5635,7 +5635,7 @@ static void unbound_wq_update_pwq(struct workqueue_st= ruct *wq, int cpu) =20 lockdep_assert_held(&wq_pool_mutex); =20 - if (!(wq->flags & WQ_UNBOUND) || wq->unbound_attrs->ordered) + if (!(wq->flags & WQ_UNBOUND) || wq->attrs->ordered) return; =20 /* @@ -5645,7 +5645,7 @@ static void unbound_wq_update_pwq(struct workqueue_st= ruct *wq, int cpu) */ target_attrs =3D unbound_wq_update_pwq_attrs_buf; =20 - copy_workqueue_attrs(target_attrs, wq->unbound_attrs); + copy_workqueue_attrs(target_attrs, wq->attrs); wqattrs_actualize_cpumask(target_attrs, wq_unbound_cpumask); =20 /* nothing to do if the target cpumask matches the current pwq */ @@ -5903,8 +5903,8 @@ static struct workqueue_struct *__alloc_workqueue(con= st char *fmt, return NULL; =20 if (flags & WQ_UNBOUND) { - wq->unbound_attrs =3D alloc_workqueue_attrs_noprof(); - if (!wq->unbound_attrs) + wq->attrs =3D alloc_workqueue_attrs_noprof(); + if (!wq->attrs) goto err_free_wq; } =20 @@ -5999,7 +5999,7 @@ static struct workqueue_struct *__alloc_workqueue(con= st char *fmt, free_node_nr_active(wq->node_nr_active); } err_free_wq: - free_workqueue_attrs(wq->unbound_attrs); + free_workqueue_attrs(wq->attrs); kfree(wq); return NULL; err_unlock_destroy: @@ -6943,7 +6943,7 @@ int workqueue_online_cpu(unsigned int cpu) =20 /* update pod affinity of unbound workqueues */ list_for_each_entry(wq, &workqueues, list) { - struct workqueue_attrs *attrs =3D wq->unbound_attrs; + struct workqueue_attrs *attrs =3D wq->attrs; =20 if (wq->flags & WQ_UNBOUND) { const struct wq_pod_type *pt =3D wqattrs_pod_type(attrs); @@ -6978,7 +6978,7 @@ int workqueue_offline_cpu(unsigned int cpu) cpumask_clear_cpu(cpu, wq_online_cpumask); =20 list_for_each_entry(wq, &workqueues, list) { - struct workqueue_attrs *attrs =3D wq->unbound_attrs; + struct workqueue_attrs *attrs =3D wq->attrs; =20 if (wq->flags & WQ_UNBOUND) { const struct wq_pod_type *pt =3D wqattrs_pod_type(attrs); @@ -7158,7 +7158,7 @@ static int workqueue_apply_unbound_cpumask(const cpum= ask_var_t unbound_cpumask) if (!(wq->flags & WQ_UNBOUND) || (wq->flags & __WQ_DESTROYING)) continue; =20 - ctx =3D apply_wqattrs_prepare(wq, wq->unbound_attrs, unbound_cpumask); + ctx =3D apply_wqattrs_prepare(wq, wq->attrs, unbound_cpumask); if (IS_ERR(ctx)) { ret =3D PTR_ERR(ctx); break; @@ -7376,7 +7376,7 @@ static ssize_t wq_nice_show(struct device *dev, struc= t device_attribute *attr, int written; =20 mutex_lock(&wq->mutex); - written =3D scnprintf(buf, PAGE_SIZE, "%d\n", wq->unbound_attrs->nice); + written =3D scnprintf(buf, PAGE_SIZE, "%d\n", wq->attrs->nice); mutex_unlock(&wq->mutex); =20 return written; @@ -7393,7 +7393,7 @@ static struct workqueue_attrs *wq_sysfs_prep_attrs(st= ruct workqueue_struct *wq) if (!attrs) return NULL; =20 - copy_workqueue_attrs(attrs, wq->unbound_attrs); + copy_workqueue_attrs(attrs, wq->attrs); return attrs; } =20 @@ -7430,7 +7430,7 @@ static ssize_t wq_cpumask_show(struct device *dev, =20 mutex_lock(&wq->mutex); written =3D scnprintf(buf, PAGE_SIZE, "%*pb\n", - cpumask_pr_args(wq->unbound_attrs->cpumask)); + cpumask_pr_args(wq->attrs->cpumask)); mutex_unlock(&wq->mutex); return written; } @@ -7466,13 +7466,13 @@ static ssize_t wq_affn_scope_show(struct device *de= v, int written; =20 mutex_lock(&wq->mutex); - if (wq->unbound_attrs->affn_scope =3D=3D WQ_AFFN_DFL) + if (wq->attrs->affn_scope =3D=3D WQ_AFFN_DFL) written =3D scnprintf(buf, PAGE_SIZE, "%s (%s)\n", wq_affn_names[WQ_AFFN_DFL], wq_affn_names[wq_affn_dfl]); else written =3D scnprintf(buf, PAGE_SIZE, "%s\n", - wq_affn_names[wq->unbound_attrs->affn_scope]); + wq_affn_names[wq->attrs->affn_scope]); mutex_unlock(&wq->mutex); =20 return written; @@ -7507,7 +7507,7 @@ static ssize_t wq_affinity_strict_show(struct device = *dev, struct workqueue_struct *wq =3D dev_to_wq(dev); =20 return scnprintf(buf, PAGE_SIZE, "%d\n", - wq->unbound_attrs->affn_strict); + wq->attrs->affn_strict); } =20 static ssize_t wq_affinity_strict_store(struct device *dev, @@ -7680,7 +7680,7 @@ int workqueue_sysfs_register(struct workqueue_struct = *wq) dev_set_name(&wq_dev->dev, "%s", wq->name); =20 /* - * unbound_attrs are created separately. Suppress uevent until + * attrs are created separately. Suppress uevent until * everything is ready. */ dev_set_uevent_suppress(&wq_dev->dev, true); diff --git a/tools/workqueue/wq_dump.py b/tools/workqueue/wq_dump.py index a0c72237531f9..e0a6936a2a37f 100644 --- a/tools/workqueue/wq_dump.py +++ b/tools/workqueue/wq_dump.py @@ -85,7 +85,7 @@ def wq_type_str(wq): if wq.flags & WQ_ORDERED: return f'{"ordered":{wq_type_len}}' else: - if wq.unbound_attrs.affn_strict: + if wq.attrs.affn_strict: return f'{"unbound,S":{wq_type_len}}' else: return f'{"unbound":{wq_type_len}}' @@ -205,8 +205,8 @@ for wq in list_for_each_entry('struct workqueue_struct'= , workqueues.address_of_( continue =20 print(f'{wq.name.string_().decode():{WQ_NAME_LEN}}', end=3D'') - if wq.unbound_attrs.value_() !=3D 0: - print(f' {cpumask_str(wq.unbound_attrs.cpumask):{ucpus_len}}', end= =3D'') + if wq.attrs.value_() !=3D 0: + print(f' {cpumask_str(wq.attrs.cpumask):{ucpus_len}}', end=3D'') else: print(f' {"":{ucpus_len}}', end=3D'') =20 --=20 2.53.0-Meta From nobody Sat Oct 3 03:45:26 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8862C3988FA for ; Wed, 5 Aug 2026 14:53:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941611; cv=none; b=CWPyM2Zawiwo3WX1Bnp3P2r7Az3IFuwMSUebKMn7d7ry67nq/1DxNJ1B0aZCj5pkiXAnzSK2H4yvsCrDwI4ohVF342ivyddKnKXeFscTShy1azV87rOIOCdmtX4fyCbph8lg2WpjznEfPS9EoJ2u4aBUp3YYdpD+aRyMSVllBvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941611; c=relaxed/simple; bh=+sKjORVDoYgAz6KAcrvpaFL8T/8exmvvz37tCKlIasA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=da1TpJ7noVkd7O2k+eZLbalc4C37uVOktmnukFOton6tOdD9tQn2P7pRNYMiqWEabadEt6sSKnnm8IMr0GSrg23HEDpBP2PW7mT1DkgQz2ouGqHkCAFah/0jPfDeCS+RIcQwTS7NEbugZYUvuBJiul4NLwSqnXN0H46rU0PAIZw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=PlX//H5j; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="PlX//H5j" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=BDEllrOPZwi7tD4pCorU9CsCABLFO/jicUEESODJH5o=; b=PlX//H5jAWf2mIYuTrUyMim9Hc MBxI2+WdJBf23onpOMtQtIZ4uT+MyGgzGi/z5iwWu9kdVS8ugqmuRqlEeVWBT8wTSq8jB9VRLi+WE jbMxDqYPkFdaSG53R3qWnuiIuNKcmqLIDJW54ErLJpaAS0jT5NEdQCPLsGDGDhFLJ0zldJXGzSHaf NvgcouBlyGzcz3PP4yS1c5GxF4uF7/+s5LgonOS6zHrb0VY9HQQw6XqI8AfltecnZW+Fb/uvLO9mS GYWzmILCQzYhykrfhha01K/VacDkXdkpDUWO2sEfUnjyvB/pdktWwxsw0RAPwVn/ik0hWkIV9KXd7 aqYNhbLQ==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wrczl-00DzgS-1Q; Wed, 05 Aug 2026 14:53:25 +0000 From: Breno Leitao Date: Wed, 05 Aug 2026 07:52:34 -0700 Subject: [PATCH v2 7/9] workqueue: allocate attrs for all workqueues Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260805-wq-pool-refactor-v2-7-fd498d01d695@debian.org> References: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> In-Reply-To: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> To: Tejun Heo , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, marco.crivellari@suse.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=1642; i=leitao@debian.org; h=from:subject:message-id; bh=+sKjORVDoYgAz6KAcrvpaFL8T/8exmvvz37tCKlIasA=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqc05KRfZ/7RkVz4ABZ3XPAUTemPCtN9eq6jEop AFtMD2AyVOJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCanNOSgAKCRA1o5Of/Hh3 bUpyEACQ8QrSksPDbGaZWQu0GZ0hAm6EyIzsKrFOHnnpz8ytHcBMbdJ56ZzHkyLhPWdTcnrSXOc BhgR1zg8os+J47EB3bHGNvHFWQgkaZTqOonVpm8BbIY2me/rcU6LcGapFyxHCIdPYPy28ooRaUu cBS3hI8add+ZZTY59Rq+4K35n+hgftExbKwf7dlUd0OSC5u28dJB7qmq9i5Wahe3ni67Kmubriv Kc0XfuluzyDcp9m7AeiS9ct1q397DExdP7flsOaxDkFvSP6OZs2OViBxp4YpXDEubEXns4dR9Rp tWs1QILAOcEPd2J5gEibkud5AEJOLxHkpzojaXY9PAjAhITlGlTFbMngsi0z/n9E4mGLayI0l6l 6aPE2DGgZYGKmssju4/xPA7PKzIGDQtymoAOuysEa9iDOD+tgkQvtmc9hgDTAwVCAUA9NlrX5FW pZanGG/CAG49vh/jg33DA59Rj3pY0c3gVTkwhCey09k9Uh3AFLinTMm/POinIl2BoWAWyPNjqSw cDlTbVcks8qW1ICpcqoP78xc7cpvVkFyqcJpzMSNhSZVqUHr6QrCtt1P6VcKzG/bnMIxHeE/STT RiqtB+RaPZObChDi2Zmgsm+oCA/kqyiL+vG93m4YhLIB+KnY0VMqRGkpoKb6icI8z40OzHVRery HgDoEhP3fPwk37g== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao The attrs are where the affinity scope lives, and a per-cpu workqueue will need one once per-cpu becomes a scope rather than a separate backend. Allocate them unconditionally. wq_dump.py used a non-NULL wq->attrs as its test for an unbound workqueue, which no longer holds; test WQ_UNBOUND there instead. Signed-off-by: Breno Leitao --- kernel/workqueue.c | 8 +++----- tools/workqueue/wq_dump.py | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index fbe13c9be4c28..e13f223e8502d 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5902,11 +5902,9 @@ static struct workqueue_struct *__alloc_workqueue(co= nst char *fmt, if (!wq) return NULL; =20 - if (flags & WQ_UNBOUND) { - wq->attrs =3D alloc_workqueue_attrs_noprof(); - if (!wq->attrs) - goto err_free_wq; - } + wq->attrs =3D alloc_workqueue_attrs_noprof(); + if (!wq->attrs) + goto err_free_wq; =20 name_len =3D vsnprintf(wq->name, sizeof(wq->name), fmt, args); =20 diff --git a/tools/workqueue/wq_dump.py b/tools/workqueue/wq_dump.py index e0a6936a2a37f..31afc24ef17bf 100644 --- a/tools/workqueue/wq_dump.py +++ b/tools/workqueue/wq_dump.py @@ -205,7 +205,7 @@ for wq in list_for_each_entry('struct workqueue_struct'= , workqueues.address_of_( continue =20 print(f'{wq.name.string_().decode():{WQ_NAME_LEN}}', end=3D'') - if wq.attrs.value_() !=3D 0: + if wq.flags & WQ_UNBOUND: print(f' {cpumask_str(wq.attrs.cpumask):{ucpus_len}}', end=3D'') else: print(f' {"":{ucpus_len}}', end=3D'') --=20 2.53.0-Meta From nobody Sat Oct 3 03:45:26 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 314202DECC2 for ; Wed, 5 Aug 2026 14:53:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941615; cv=none; b=DNeG7UJ/dROvps8ya82LgdU9U2ivfQSaRDxKhxE5YYx9LXhtwAx2FOtmCJ8rhyqGpl9GYFkzotSdFn0j50+h08s68OyZBzDSG9cFkl/ZfSfoC9pAJ5KeEsIoiJIWzXD2pmvK4a8PnRuVtGEHMkRFX89AQPRzcnHMAjieIF3DNw0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941615; c=relaxed/simple; bh=ElonWCw41fSfSEA2G1xKHfjSP3Gw7iZZMB7JpMGT7C8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=e1mZtFojoP4toGOyxQgunSDlij1X0EnE1y46xFHOwmev9wG62U25LGQKWulQ9FHPYkDbmPPXtkkndI5HYtG1gdyI7ZUPOzYme6tdbyTGAkQWxvCQUOhi6ib0s6v4W0jRMvMTMmanXV3P24Bv87A62ImYIA19wNRqQUJUzXqrPNE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=HYFSEIgR; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="HYFSEIgR" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=wZfXFxyrGKodCrUh/7mz4M/WB7XMhUvVnml8KjNCDYU=; b=HYFSEIgRZPJp6JFFudkKkgADVk 8BS0DtWUwB69XP/ucJW8xgQTN+/dO8F+Z+q6y/RMOgWDM3w8Zs55NRFn/JTeqJR6oR2Ai6NSjWnKz 9mOexrK2NJ5LvmYKNmMKqdjgWGuabwVdj6Hu+OOcQ2UmjJhRk2Fp/ycKd4Z/8tbKIAQor8NIiHzvb nhg7mibeYmtmLQaNNjkLhWTi3XYbQhTYorczLB5VSAauYX8RTWvBFuNANOOKcts081cBdBHZd0YKJ COTpP4aWw9ZUHBh+CrKXgoRLI1TOyM962Dt5+ySh4STtO02nFvCdKGLbgxn+BsTSBZj21TMG3h8fd 17bZObDQ==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wrczo-00Dzgc-2u; Wed, 05 Aug 2026 14:53:29 +0000 From: Breno Leitao Date: Wed, 05 Aug 2026 07:52:35 -0700 Subject: [PATCH v2 8/9] workqueue: rename alloc_unbound_pwq() to alloc_pwq() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260805-wq-pool-refactor-v2-8-fd498d01d695@debian.org> References: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> In-Reply-To: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> To: Tejun Heo , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, marco.crivellari@suse.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=2056; i=leitao@debian.org; h=from:subject:message-id; bh=ElonWCw41fSfSEA2G1xKHfjSP3Gw7iZZMB7JpMGT7C8=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqc05KBADhwDH07gv7OMym+kkR/h+u3B701z4C9 vIVg3IFlaiJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCanNOSgAKCRA1o5Of/Hh3 bXvBD/43x1la5QOID6cHU0s20gBvRo0fYuhDQVCmkkAIXoEiCf4Oy+d71BsR/xbHie+PBKDjTPC uA68z0iiilJu//PxMfkYQ867ZYOpzBfl5UljvBF1bj3/+YyxgXXxQEg3Vs2PFPaJCCVdzz2H2WG bI8CviF/35Mn3DyQ6d2cgezENuRn9v1ffgNCKozcWmQEE9P1iiozDcqLPCstPSGTFrknVmv1BUL EyJWmecajTrzcR3PwSDo+aRPk51GeU8pu0EncHattiwUHpUJ0BonrAoSovkkSZWeZUkPmtxGXI7 pTjz0zggw4VYZ07WuWAlB9VI5urfVy0EPaGsMY43rJzoYk8UMJC+MrhzjA2IqmWX95TNpQKm4Rg OYBn1b84IvUfqjVG9mcWufW/n+DKiteuarlmIEQnFdJDckEgPvvgYdcAzHVnkbC1hk9N3tNpYyD dezijhnUF7dVQhh1oYVTzLNnRADZJ5lWzK1uZZHwnODP6lxpjyNsA2fc0Fc4ABuW/SNyvrkyML3 P+5zF5VHUPyLKbvo639ZV2fsksyC8t7eILfjAf/R8LsYOMhUBsih5KgYyXqw8BirnThTC5bcC+s bOFoKUrhFhZSrKHMpqUN4Crm6D3jEKgdW35jm3rPhz581RBYbZzXEz9AY7QOLSVzMJtp/bjbPmM /5U3ZmvsjuHmb5Q== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao This allocates a pwq and binds it to the pool @attrs asks for. Which pool that is becomes a property of the attrs (once per-cpu becomes an affinity scope). Remove the 'unbound" from the function name, given it will be bigger than unbound. No functional change. Signed-off-by: Breno Leitao --- kernel/workqueue.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index e13f223e8502d..65ac75431c3be 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5377,7 +5377,7 @@ static struct worker_pool *get_percpu_pool(struct wor= kqueue_struct *wq, int cpu) } =20 /* obtain a pool matching @attr and create a pwq associating the pool and = @wq */ -static struct pool_workqueue *alloc_unbound_pwq(struct workqueue_struct *w= q, +static struct pool_workqueue *alloc_pwq(struct workqueue_struct *wq, const struct workqueue_attrs *attrs) { struct worker_pool *pool; @@ -5500,7 +5500,7 @@ apply_wqattrs_prepare(struct workqueue_struct *wq, copy_workqueue_attrs(new_attrs, attrs); wqattrs_actualize_cpumask(new_attrs, unbound_cpumask); cpumask_copy(new_attrs->__pod_cpumask, new_attrs->cpumask); - ctx->dfl_pwq =3D alloc_unbound_pwq(wq, new_attrs); + ctx->dfl_pwq =3D alloc_pwq(wq, new_attrs); if (!ctx->dfl_pwq) goto out_free; =20 @@ -5510,7 +5510,7 @@ apply_wqattrs_prepare(struct workqueue_struct *wq, ctx->pwq_tbl[cpu] =3D ctx->dfl_pwq; } else { wq_calc_pod_cpumask(new_attrs, cpu); - ctx->pwq_tbl[cpu] =3D alloc_unbound_pwq(wq, new_attrs); + ctx->pwq_tbl[cpu] =3D alloc_pwq(wq, new_attrs); if (!ctx->pwq_tbl[cpu]) goto out_free; } @@ -5654,7 +5654,7 @@ static void unbound_wq_update_pwq(struct workqueue_st= ruct *wq, int cpu) return; =20 /* create a new pwq */ - pwq =3D alloc_unbound_pwq(wq, target_attrs); + pwq =3D alloc_pwq(wq, target_attrs); if (!pwq) { pr_warn("workqueue: allocation failed while updating CPU pod affinity of= \"%s\"\n", wq->name); --=20 2.53.0-Meta From nobody Sat Oct 3 03:45:26 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7098F3AAF7C for ; Wed, 5 Aug 2026 14:53:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941618; cv=none; b=gP52TRlJQo7CigeJNMuIGYalJ8S/1+AN4FMY9YZ9AcdUTKYkakNd4RBnNyc9fuANOVM8qOZVCdsFNK57uQbDpGfQ3xfyjEaP6l7MRqPTjVPZzt4NAZO6RRL7sqdu5tYvpA+0536JZTEn60fl1Ced8Ado4+9K/162LVnrAj5R6UQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785941618; c=relaxed/simple; bh=b5aBzCWxC9cJyoivct1GDte/xiq8CSpam7qDzxD7KWE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GQ7IQQF5QoW6L6Z7uqDyWO5M2QaM6hQJ7qnNiyMzxweBjmGl5lZxmSFMVHCgUpbxk0DygWwYrAwiRn+oprfuBXc09D5S4nWFAx4K3HDjS+3qVGtVmpmeRUyuwC+JuqQb0kDGpl4mf3/fb5B4Yy7wrgZix5z9hzKi8HWn1cOhCk4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=fCDOMJij; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="fCDOMJij" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=7UrIU/h1GgJWY2kLb9c/7GGiJt1J8Jouio4c+MLnlJg=; b=fCDOMJijiBiOXq1A1N8lQ+L5HZ 4jJMfr63tdERbNBwUkyJrMqkMOyYX6GaotDuThbC7lr4XBe0ZveG75cBn/YJp3ETBvk2H29HjXzEO iOVMPR9ad13s0D0nzSOsakwmNX6hOs2lwnuQNbgj3O+CZYi0EkGCSlXQl7oaHwtBgrWS2YZ72efsX 7OdH1tTrXFJkptFg8CVf/feUAUd0GnLsWvBOEeJdrbRU8Q7XmfOUx/BBNTU/Ak/yCUdWBkFdzVx8Z uPsDJPVsjgmFY2UnzPovZTXenQlp8LaoU+CJ/wQBEBD1bYDyWGcxt9JE0fWm6rHULihOdd8nD07Um Rfdb0a2A==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wrczs-00Dzgk-0p; Wed, 05 Aug 2026 14:53:32 +0000 From: Breno Leitao Date: Wed, 05 Aug 2026 07:52:36 -0700 Subject: [PATCH v2 9/9] workqueue: skip the node_nr_active update for non-unbound workqueues Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260805-wq-pool-refactor-v2-9-fd498d01d695@debian.org> References: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> In-Reply-To: <20260805-wq-pool-refactor-v2-0-fd498d01d695@debian.org> To: Tejun Heo , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, marco.crivellari@suse.com, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=1047; i=leitao@debian.org; h=from:subject:message-id; bh=b5aBzCWxC9cJyoivct1GDte/xiq8CSpam7qDzxD7KWE=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqc05KFe/4KVHgq33Qy2UYXGgv5vPpJ+Y8HYpky uSUSRc9R3eJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCanNOSgAKCRA1o5Of/Hh3 bXPFEACjFbLNBq5gAswtqQvS7T1xvwRlwSDR+5C7uZSnW0duELtTF4D8279WK/qZpZhXIgeg2cV tefGn1KxTd7eOrY2yGXWrPmn9C86NdUrxPMi6XEMsWjwvn96JadTOUjXpoiV7SGIdsjtZrx4LED fH8HTm1ydsi2GEf92/BWhDJF+vp4ci+oRwdxTc+THJ9ewW5sGJXOZtFK/vow01N1yGpm2MTPy88 u6lAFfBI0bIYZFl2q+a5t516TZcMGtnzJXocPF5TfZCPCJ52vIfvZ+Pdt/cjHEMsRALgR+JYIP8 GDrj7Lg/s2sw4hltqmASBSSGRuzd8lVEQs987UY2kWq9Zfx9wIBpb+AQMGHutk45poBtvdGFWDz VGN+Prvj7utMbo4xCVqDwFXMT0iGgatEltFtMnQII2PTXiSoULw8ZcNkDVcxPKD+jyBBrEq3/sh nSQvA/9oDNF6Eqv+n3gHRfvbXgeLNrX1fIc5Mo7INr6N0AWMDuuftf/+d4yKj+4aecyCPbRpyW5 bGOurUV4X6yqyWUAjqWyrWK1KEqJVkgtHfgowkYrFnrNRb/oSlIrCvxwtGkJziEvZiT5cRq8e4T 1xrEOorTbuc0BVdeAiV/p0jgRZk/Mry0GfJpkGbSxanUmcK/PSt3AUgWRM8l17Mg3QC6vnme0FH yWlHL7GxA3UxN2w== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao apply_wqattrs_commit() updates node_nr_active->max unconditionally. wq->node_nr_active[] is only allocated for unbound workqueues, so guard the call before per-cpu workqueues start using this path. No functional change: only unbound workqueues reach apply_wqattrs_*() today. Signed-off-by: Breno Leitao --- kernel/workqueue.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 65ac75431c3be..8fd6af72ffd8d 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5556,8 +5556,9 @@ static void apply_wqattrs_commit(struct apply_wqattrs= _ctx *ctx) ctx->pwq_tbl[cpu]); ctx->dfl_pwq =3D install_unbound_pwq(ctx->wq, -1, ctx->dfl_pwq); =20 - /* update node_nr_active->max */ - wq_update_node_max_active(ctx->wq, -1); + /* update node_nr_active->max, which only unbound workqueues have */ + if (ctx->wq->flags & WQ_UNBOUND) + wq_update_node_max_active(ctx->wq, -1); =20 mutex_unlock(&ctx->wq->mutex); } --=20 2.53.0-Meta