From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380374; b=lnW/A6WFX3GcQLYr4rQmMAvCsP5XSckyiDbqK0Tw1zLdDeJH/ye2pJHb/7vN54+d3CbZ i92N7R1hwrBTJojFzwgUDKOpU1k9+dpKiQEKnqHvJ3m706vv6GGRmV6nD+bM81UMcddUh zjdO9oY4IyyG3DM6FCFndk4ZKo2ZfE6TuJAGBI5BZ/P5T0+BbXcQBLEpqwhZOuBhqW3LS mlgnxfpB/AkeWJ8HSHyRu/pMUvmuGXx19mU+uDVEVl9fryUadkjRdZEn39JdGzdhijLyJ VrfNjOdfRo1X03BVSEImPoYHzkf5frq7iliv0qwdpAdyzum1sQJytVILcnNx/OHYWbA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380374; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=OrOZAOz7TCLkqRovrHOUTdI0yFny9aL0ETScJ4d/NOc=; b=dIokfTiMJ6lj4tEywMo3AlTQJVgFinXnp4ya6dIwCntYybKOAKjE72Av47V0tCpgmInu ekyIWfYKoAhJ+rCp1cNAa4HVCfHxtDVeTAGOs2N0upgFMdbZ+6MP4Wc2Z3Ct/8nxdLJCg ofQKQytAGrnRg9+VQZGRG61MKEjmhsCi3+QlTR/mai8M5GJY+Bf24Gu33RW0LjOrQ21Qj Dy43dEJshFCdW20FetYRdC8KUatnhgZjouWAHv3ccBQN+fEjXhjp9sa1stJ8BHtL9+tAx jqgOP19o8l1QRWU3EKo/edwPbZpfAgvdwrDHOxu9A+8G/QvD3uAQTxHadc3RLV85WEA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Kf007gKj; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC37D606A322; Fri, 4 Dec 2026 10:32:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Kf007gKj Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09A441F00931; Fri, 4 Dec 2026 10:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380374; bh=OrOZAOz7TCLkqRovrHOUTdI0yFny9aL0ETScJ4d/NOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Kf007gKj2O3Q2gsu3jA6H2PFdfpOfgfNtsHfVHFulmYDZJtWtldv150SI4pUYbj/H O/4CFAR26gIoSC3icuMmuoBjNnq/q4KjNBKzH5dElJxDpYDBs17Q5+3H/kAJmHOAw2 xn0NQIfme16yYu2RwJcwwqX9Y9CIxQBv5Q/IH/tE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Saurabh Sengar , Tejun Heo , Sasha Levin Subject: [PATCH 7.3 245/742] workqueue: Skip redundant unbound updates during CPU bringup Date: Fri, 4 Dec 2026 19:01:49 +0900 Message-ID: <20261204100641.574784214@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Saurabh Sengar [ Upstream commit edf1066ba69c89c42c3007e4230c7b9cb13405a8 ] Before workqueue_init_topology(), all CPUs share the SYSTEM pod, which contains every possible CPU. The effective cpumask and the per-pod cpumask of an unbound workqueue are therefore identical, regardless of which CPUs are online. During this stage, workqueue_online_cpu() walks every possible CPU for every unbound workqueue each time a secondary CPU comes online. The pwq mappings cannot change yet, so this repeats redundant work that scales quadratically with CPU count. On a 640-vCPU Hyper-V VM, each of the 639 secondary CPU-online callbacks walks all 640 possible CPUs for each of the 8 unbound workqueues, giving 3,271,680 unbound_wq_update_pwq() calls that took about 975 ms in total. Skip these updates until workqueue_init_topology(). The pwq mappings already match the effective cpumask, and wq_update_node_max_active() does nothing before topology initialization. workqueue_init_topology() will apply the topology-specific mappings and node limits once ready. Keep worker rebinding and restoration of unbound worker affinity before the guard. CPU hotplug after topology initialization is unchanged. On the same VM running a v7.3 kernel, smp_init() took 1054 ms with this change, compared to 2008 ms without it, a 47.5% reduction. Before After Reduction smp_init() 2008 ms 1054 ms 47.5% Fixes: 84193c07105c ("workqueue: Generalize unbound CPU pods") Signed-off-by: Saurabh Sengar Signed-off-by: Tejun Heo Signed-off-by: Sasha Levin --- kernel/workqueue.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index c1cb328bce3c7..e545a34857f45 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -6978,6 +6978,14 @@ int workqueue_online_cpu(unsigned int cpu) mutex_unlock(&wq_pool_attach_mutex); } + /* + * Before topology initialization, the SYSTEM pod covers all possible + * CPUs, so CPU onlining does not require updating pwq mappings. + * wq_update_node_max_active() also returns early at this stage. + */ + if (!wq_topo_initialized) + goto out_unlock; + /* update pod affinity of unbound workqueues */ list_for_each_entry(wq, &workqueues, list) { struct workqueue_attrs *attrs = wq->attrs; @@ -6995,6 +7003,7 @@ int workqueue_online_cpu(unsigned int cpu) } } +out_unlock: mutex_unlock(&wq_pool_mutex); return 0; } -- 2.53.0