From mboxrd@z Thu Jan 1 00:00:00 1970 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: 7bit 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; } +/* 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 >= 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) 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; /* sanity checks */ - if (WARN_ON(!(pool->cpu < 0)) || + if (WARN_ON(is_percpu_pool(pool)) || WARN_ON(!list_empty(&pool->worklist))) return; @@ -5273,7 +5279,7 @@ static void pwq_release_workfn(struct kthread_work *work) mutex_unlock(&wq->mutex); } - 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 *unused) lockup_detected = true; stall_time = jiffies_to_msecs(now - pool_ts) / 1000; max_stall_time = max(max_stall_time, stall_time); - if (pool->cpu >= 0 && !(pool->flags & POOL_BH)) { + if (is_percpu_pool(pool) && !(pool->flags & POOL_BH)) { pool->cpu_stall = true; cpu_pool_stall = true; } -- 2.53.0-Meta