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 1E68340096D for ; Fri, 31 Jul 2026 11:58:03 +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=1785499085; cv=none; b=nD5fjFU1xhyeHqa0DiQyEWq7rOLMPR4x8dHDiSUKJAq23YQ5otot3kdgbf0s0YuMUaXtEROHociSfg2i0qDNc8vNirmCh/nhfZMhi1FK8ZdjxHng8+iDX7zP2oKRF37ry9tyWfzkyICCvJXSh0FPXuhsuzOesM4VaZwNvspuv9A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785499085; c=relaxed/simple; bh=MiSspJt4lK7ECfV9N5IdfjY1SR2arU1yv9QRgEhDKNI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YPsb8MVhryuQdCCqzMEGPtoYkhRt4roEFukHzIn/jHnTJi2HmuGQ5HKCaGVOqiu31bZduGtLxsEteXnaPxmiPMtC9IVM4BnhgSFj81eatPF/o4sqhZXgrJHRZOta4uii1j7Hei+qCWFRzGk+qOpBmY4UVvLR8g403kAIVoXfl3s= 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=iBylOi/H; 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="iBylOi/H" 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=JrsPKIc8zNiNIdgz+OCZbFIxCbavGxYPyFlXhgD3gXc=; b=iBylOi/HtwqPCPkNhsMcaih8JD XdDrBueDlKBvqzmv2J+hMG5otH6q7lGnBOJCKz2sN1KlwTCiwaxQVnzZA/g+scRFkmcNnIFDDpgSr PKAHNnALKGNGtmvYtkRi2s8WSiS52yf5lXgKuPN9aBKROkuf2OA9XPvuR+d5/5VgkE0Mnr/otGcgZ OgqTPS/b5LNV4DOQKijYdNwWsuZILRTgfbUqno0Bm1BCC+UeVfJNe3LJJZRC0byFoMsHsOgK+9IAi dyUF6EXl9ygDgNGqv0/xi0JpsrPxHDqT0ZphWvbBBesPY10Ogh4rf+AVSgYHqSR25QcJ7lk5CG4nR txLU3hQQ==; 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 1wplsH-009zct-2X; Fri, 31 Jul 2026 11:58:02 +0000 From: Breno Leitao Date: Fri, 31 Jul 2026 04:57:35 -0700 Subject: [PATCH 3/6] 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: <20260731-wq-pool-refactor-v1-3-8eaf71cdab5f@debian.org> References: <20260731-wq-pool-refactor-v1-0-8eaf71cdab5f@debian.org> In-Reply-To: <20260731-wq-pool-refactor-v1-0-8eaf71cdab5f@debian.org> To: Tejun Heo , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, Breno Leitao , kernel-team@meta.com, marco.crivellari@suse.com X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=2663; i=leitao@debian.org; h=from:subject:message-id; bh=MiSspJt4lK7ECfV9N5IdfjY1SR2arU1yv9QRgEhDKNI=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqbI28K5oDicQy+nDwEkHvbZhhOIwJkJ0E1SVhH oDZDuAj/HCJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCamyNvAAKCRA1o5Of/Hh3 bciVD/0Q1e6CUslgKniSzpyOgnxkFiTb5C7ts7yxO2J+cYZ4gpb9SB7DgrQ7nWHuW9SOrMZeP6n qwgBqYnHMgzeSMGVGSxwKVOvGEWONHLYkw1bhu43e74ymlQy5V4Lr1iRaIwXIumWBTpUGsrjYsw 2wAy7kjrx52SVewKWEwyTsJzYpaA+mPycXOP668czJ7J3qkECPr+flyPRSeDTihCXYSj/+QMwkn 8NWy5MQffDiCLb4giEFSL2XYYWfLyDWk3a8aBVI1GmGyoRP8IGM3pln1OsT49gzY8/mJRLU9Nsf NbNwICKLue6ZX40L0ES7bnJqXN7arFg8KQGgHqWX91E0ypfIpcDQaEDdlF5Fb9dgvUR3usGMLXz JyAvHygw3ftj3PrhQzYoMbJbZgYyNtFnHE0AlHZyzFhXQoa+fr+yK6HXsFxR84DK5fhOwZs4v1K E3NzNE4yzr3lF7R7U/DBUYPwcb1KMHLkx2rJT6uwY0wpwSAXdwtu6F6MBJ5KRLZDHN4wtcAD6gI HsYvpOCsN+C11Ieqz0kiMsIAn4FH0giCKuXThL5GE0mGkaWK+a09KAOg02hWb+2FABTPomppOSw jBOCi3ZCk5oYleQeEL8RYM8xINxb87RGdFZsJOJCGOZ6lL11aLFkmJhaAaOXCAgV3LgBKYWQ7up j38dfFNeJ++MChA== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao pwq_release_workfn() calls put_unbound_pool() based on the WQ_UNBOUND flag. That works today because an unbound workqueue only ever points at unbound pools, but the flag is the wrong thing to test: what matters is whether the pool is a refcounted unbound pool or a permanent per-cpu one. Add is_pool_cpu_specific() and key the release on it instead of the flag. This is equivalent for every existing workqueue and stays correct if an unbound pwq is ever backed by a per-cpu pool. Convert the other open-coded pool->cpu type 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..513193be00a7d 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 tied to a specific CPU, rather than an unbound pool. */ +static bool is_pool_cpu_specific(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_pool_cpu_specific(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_pool_cpu_specific(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_pool_cpu_specific(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_pool_cpu_specific(pool) && !(pool->flags & POOL_BH)) { pool->cpu_stall = true; cpu_pool_stall = true; } -- 2.53.0-Meta