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=1796382122; b=MQeh9N3nftHyQCESjbAubQj3bmdOBfnBymuGFgmBXpBBbNJkbOytp7MoA5SIpfMtUPnr bNQE41kr5aC6W7JZvuvn3bL0P8gtLRuHuTubptCeQY6YVqeOg8PbHdEUATXeisJVwrB9e LshxPgfEBrzSl9ZYp3QzNP0rw8P6fGz49O3lL6Q7NfDUo0A4TZrVgM2vQWLOTk/UTn4xv F1emrJwUVBhqE+9kkmGVeRo0EBL70tRjCf6YTeCMSq4dV5M0eutMGBS8MhMW+AH3eFeGN EezGUJKGs8hFcpa44IYIjY3WkHtN2Bp8j8mbJSkuCoTYkKY0iYOoEiQmC553CXN5gWg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382122; 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=ugkANrk9Z+VV/Mv/s9lvBivpoTkCboAYwa7kPUqgLH4=; b=GHJvEwqd2UdeWawHjp+J6Q6nqrCxZucsC8U01Cy9n1g7TvYbA2e9MRWiydovXxp1MaiX 8Zz2yb/NB7dZ+t43ZmCu7855VL3xXqBXkrSHyrTrK60qNWgP3P3Auhfcw+XS02AM+SFEC owg/ia0ympPYPfrtQ68fRVF8eJicrKaOLf7H4KwLk7ESRqtGyNXKW7A3CgiImIhpQRUQ1 QpayzXblyL0hGufErLxlgCp1Bk4vjU0hJv19GH+DQhgDQULQ5Ay/NPj6e32l5dILiaziQ JgjK+Yh8EPr+uhG0tG4O8rujoZgbBEiz/QQZEJ0uqs6deeaifDjuv4pfwKrmaHVrwGg== 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=bYnLAi0g; 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 A1961606A338; Fri, 4 Dec 2026 11:02:02 +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=bYnLAi0g Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CB541F00897; Fri, 4 Dec 2026 11:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382122; bh=ugkANrk9Z+VV/Mv/s9lvBivpoTkCboAYwa7kPUqgLH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bYnLAi0glEQvyZr7RGDhHJEr2LP+5Lf/F6N9XT56Qz/dw2VXSo2WPBMBtknkTmIAl XZ4CmeN9tYinPnsxXThLfdbosEs+xrUdlUDSGBbJEAM/u+4ijN/nbNh/suztJZgNem nQg2lmvkujK7SyUvPIld5Q8TZTlYHbIyf45IeDwk= 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 6.18 277/703] workqueue: Skip redundant unbound updates during CPU bringup Date: Fri, 4 Dec 2026 19:02:56 +0900 Message-ID: <20261204100635.144678074@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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 6.18-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 8c74f199cd707..e9fbc9c04e67a 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -6823,6 +6823,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->unbound_attrs; @@ -6840,6 +6848,7 @@ int workqueue_online_cpu(unsigned int cpu) } } +out_unlock: mutex_unlock(&wq_pool_mutex); return 0; } -- 2.53.0