From nobody Tue Oct 7 21:05:32 2025 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (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 36D933207; Sun, 6 Jul 2025 03:08:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751771316; cv=pass; b=jHheDfP4LlqH0UyN4+KvWOKRB9DErCluBu+up803Huzek3N+wkU4FqfbK0Udbsy4KN9y/HwwGeOPsJjDQPfPC2JXJYKZjgK/c+chjlqHnTHe6Hawn5DCSgwq9GIcSG1nbdViCoCLpXiHqgGk5opK3mFwLfwlkE4zIwZ7oVcVZ/E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751771316; c=relaxed/simple; bh=J6DPmMM4CoEw2rEmRprBuicLduxbutp6nC+XHSkbI0g=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ski2e6bn7gpogU56O8Qds+zZPz7bAzcgixQ3s1q0VPJ2nij70xGA79ulEFOOoXwOwBKeHzaJBy90mSzGRsmCALFFnL1NGdjxXvNYmT6Tsv7g2FoMWH9blz7ZCTDkqaQOKr4qpE4rsSj5q/Fm9mVvHET5gfaX5RZclKZ87Y+RqRQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty; spf=pass smtp.mailfrom=linux.beauty; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b=n/85JIut; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.beauty Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b="n/85JIut" ARC-Seal: i=1; a=rsa-sha256; t=1751771224; cv=none; d=zohomail.com; s=zohoarc; b=BANOU2jht3RDtVqHFtPKzQFFX64aZ9pNNhCxDSPZ5o4rFU3pY8BB9ufK6On5Ro7fYeO5yUfmYRP2kJ7Q7pYdXa85MLJCtmgCyytA2rnEMGwQuzJxOfuCPX8WyXa383o2V5BxMEGz4EvWL8VRqdQbyrufidet65E3MLt/uxt3Njc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751771224; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=jePSSp++5Batv5PK3k9r42c2ScL6/PQrLL8WfPRMBYI=; b=HtMuRgmCMpd0TDfSFbGbgHeQEzXnZTlNfJU3Q/AGKRSSEv/dpCDQE1AXqEaulX9dzvhEi7uPm8FkKSdeqEtBKxILLNi0ot7OK8z5Sjqs+u/2JIYPZHPnqMICM4Ve0rBx9i5IzBF8Js3DTe+/vpA27WfkyOzmTIfn3WqGnlp/eCc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=linux.beauty; spf=pass smtp.mailfrom=me@linux.beauty; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1751771224; s=zmail; d=linux.beauty; i=me@linux.beauty; h=From:From:To:To:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To:Cc; bh=jePSSp++5Batv5PK3k9r42c2ScL6/PQrLL8WfPRMBYI=; b=n/85JIutx8NKp8cgQQQcnme0fbNI1Md8Bo347hSfTgCCepfJwTHYrMoXbChrSoAL Jw533PBuKIhVmTsAQ+EntIH+85wGK7WQWwtVpgq71Sv75bSQAIKYgWZ5mjOci6vwFQl xJr7g9fZSvZx7KQKUI6AZ8JQwym7AHl5Rz89i6O4= Received: by mx.zohomail.com with SMTPS id 1751771221451549.3655482599792; Sat, 5 Jul 2025 20:07:01 -0700 (PDT) From: Li Chen To: Li Chen ," Thomas Gleixner "," Ingo Molnar "," Borislav Petkov "," Dave Hansen ",," H . Peter Anvin "," Rafael J . Wysocki "," Peter Zijlstra "," Sohil Mehta "," Brian Gerst "," Patryk Wlazlyn " , linux-kernel@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Bibo Mao , Li Chen , Huacai Chen , Tobias Huschle , Mete Durlu , Joel Granados , Guo Weikang , "Rafael J. Wysocki" , Sohil Mehta , K Prateek Nayak , Brian Gerst , Patryk Wlazlyn , Swapnil Sapkal , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org Subject: [PATCH v4 1/4] smpboot: introduce SDTL() helper to tidy sched topology setup Date: Sun, 6 Jul 2025 11:06:29 +0800 Message-ID: <20250706030636.397197-2-me@linux.beauty> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250706030636.397197-1-me@linux.beauty> References: <20250706030636.397197-1-me@linux.beauty> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" From: Li Chen Define a small SDTL(maskfn, flagsfn, name) macro and use it to build the sched_domain_topology_level. Purely a cleanup; behaviour is unchanged. Signed-off-by: Li Chen Suggested-by: Thomas Gleixner Tested-by: K Prateek Nayak --- arch/powerpc/kernel/smp.c | 34 +++++++++++++--------------------- arch/s390/kernel/topology.c | 10 +++++----- arch/x86/kernel/smpboot.c | 21 ++++++--------------- include/linux/sched/topology.h | 6 +++--- kernel/sched/topology.c | 16 ++++++---------- 5 files changed, 33 insertions(+), 54 deletions(-) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 5ac7084eebc0b..b05995e272134 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -1700,28 +1700,20 @@ static void __init build_sched_topology(void) #ifdef CONFIG_SCHED_SMT if (has_big_cores) { pr_info("Big cores detected but using small core scheduling\n"); - powerpc_topology[i++] =3D (struct sched_domain_topology_level){ - smallcore_smt_mask, powerpc_smt_flags, SD_INIT_NAME(SMT) - }; - } else { - powerpc_topology[i++] =3D (struct sched_domain_topology_level){ - cpu_smt_mask, powerpc_smt_flags, SD_INIT_NAME(SMT) - }; - } + powerpc_topology[i++] =3D + SDTL(smallcore_smt_mask, powerpc_smt_flags, SMT); + } else + powerpc_topology[i++] =3D SDTL(cpu_smt_mask, powerpc_smt_flags, SMT); #endif - if (shared_caches) { - powerpc_topology[i++] =3D (struct sched_domain_topology_level){ - shared_cache_mask, powerpc_shared_cache_flags, SD_INIT_NAME(CACHE) - }; - } - if (has_coregroup_support()) { - powerpc_topology[i++] =3D (struct sched_domain_topology_level){ - cpu_mc_mask, powerpc_shared_proc_flags, SD_INIT_NAME(MC) - }; - } - powerpc_topology[i++] =3D (struct sched_domain_topology_level){ - cpu_cpu_mask, powerpc_shared_proc_flags, SD_INIT_NAME(PKG) - }; + if (shared_caches) + powerpc_topology[i++] =3D + SDTL(shared_cache_mask, powerpc_shared_cache_flags, CACHE); + + if (has_coregroup_support()) + powerpc_topology[i++] =3D + SDTL(cpu_mc_mask, powerpc_shared_proc_flags, MC); + + powerpc_topology[i++] =3D SDTL(cpu_cpu_mask, powerpc_shared_proc_flags, P= KG); =20 /* There must be one trailing NULL entry left. */ BUG_ON(i >=3D ARRAY_SIZE(powerpc_topology) - 1); diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c index 3df048e190b11..ccf5dcc56f86d 100644 --- a/arch/s390/kernel/topology.c +++ b/arch/s390/kernel/topology.c @@ -531,11 +531,11 @@ static const struct cpumask *cpu_drawer_mask(int cpu) } =20 static struct sched_domain_topology_level s390_topology[] =3D { - { cpu_thread_mask, cpu_smt_flags, SD_INIT_NAME(SMT) }, - { cpu_coregroup_mask, cpu_core_flags, SD_INIT_NAME(MC) }, - { cpu_book_mask, SD_INIT_NAME(BOOK) }, - { cpu_drawer_mask, SD_INIT_NAME(DRAWER) }, - { cpu_cpu_mask, SD_INIT_NAME(PKG) }, + SDTL(cpu_thread_mask, cpu_smt_flags, SMT), + SDTL(cpu_coregroup_mask, cpu_core_flags, MC), + SDTL(cpu_book_mask, NULL, BOOK), + SDTL(cpu_drawer_mask, NULL, DRAWER), + SDTL(cpu_cpu_mask, NULL, PKG), { NULL, }, }; =20 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 58ede3fa6a75b..55f09946c791b 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -485,35 +485,26 @@ static void __init build_sched_topology(void) int i =3D 0; =20 #ifdef CONFIG_SCHED_SMT - x86_topology[i++] =3D (struct sched_domain_topology_level){ - cpu_smt_mask, cpu_smt_flags, SD_INIT_NAME(SMT) - }; + x86_topology[i++] =3D SDTL(cpu_smt_mask, cpu_smt_flags, SMT); #endif #ifdef CONFIG_SCHED_CLUSTER - x86_topology[i++] =3D (struct sched_domain_topology_level){ - cpu_clustergroup_mask, x86_cluster_flags, SD_INIT_NAME(CLS) - }; + x86_topology[i++] =3D SDTL(cpu_clustergroup_mask, x86_cluster_flags, CLS); #endif #ifdef CONFIG_SCHED_MC - x86_topology[i++] =3D (struct sched_domain_topology_level){ - cpu_coregroup_mask, x86_core_flags, SD_INIT_NAME(MC) - }; + x86_topology[i++] =3D SDTL(cpu_coregroup_mask, x86_core_flags, MC); #endif /* * When there is NUMA topology inside the package skip the PKG domain * since the NUMA domains will auto-magically create the right spanning * domains based on the SLIT. */ - if (!x86_has_numa_in_package) { - x86_topology[i++] =3D (struct sched_domain_topology_level){ - cpu_cpu_mask, x86_sched_itmt_flags, SD_INIT_NAME(PKG) - }; - } + if (!x86_has_numa_in_package) + x86_topology[i++] =3D SDTL(cpu_cpu_mask, x86_sched_itmt_flags, PKG); =20 /* * There must be one trailing NULL entry left. */ - BUG_ON(i >=3D ARRAY_SIZE(x86_topology)-1); + BUG_ON(i >=3D ARRAY_SIZE(x86_topology) - 1); =20 set_sched_topology(x86_topology); } diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 198bb5cc1774b..0b53e372c445c 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -197,9 +197,9 @@ struct sched_domain_topology_level { extern void __init set_sched_topology(struct sched_domain_topology_level *= tl); extern void sched_update_asym_prefer_cpu(int cpu, int old_prio, int new_pr= io); =20 - -# define SD_INIT_NAME(type) .name =3D #type - +#define SDTL(maskfn, flagsfn, dname) \ + ((struct sched_domain_topology_level) \ + { .mask =3D maskfn, .sd_flags =3D flagsfn, .name =3D #dname, .numa_le= vel =3D 0 }) #else /* CONFIG_SMP */ =20 struct sched_domain_attr; diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index b958fe48e0205..e6ec65ae4b75d 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -1739,17 +1739,17 @@ sd_init(struct sched_domain_topology_level *tl, */ static struct sched_domain_topology_level default_topology[] =3D { #ifdef CONFIG_SCHED_SMT - { cpu_smt_mask, cpu_smt_flags, SD_INIT_NAME(SMT) }, + SDTL(cpu_smt_mask, cpu_smt_flags, SMT), #endif =20 #ifdef CONFIG_SCHED_CLUSTER - { cpu_clustergroup_mask, cpu_cluster_flags, SD_INIT_NAME(CLS) }, + SDTL(cpu_clustergroup_mask, cpu_cluster_flags, CLS), #endif =20 #ifdef CONFIG_SCHED_MC - { cpu_coregroup_mask, cpu_core_flags, SD_INIT_NAME(MC) }, + SDTL(cpu_coregroup_mask, cpu_core_flags, MC), #endif - { cpu_cpu_mask, SD_INIT_NAME(PKG) }, + SDTL(cpu_cpu_mask, NULL, PKG), { NULL, }, }; =20 @@ -2010,11 +2010,7 @@ void sched_init_numa(int offline_node) /* * Add the NUMA identity distance, aka single NODE. */ - tl[i++] =3D (struct sched_domain_topology_level){ - .mask =3D sd_numa_mask, - .numa_level =3D 0, - SD_INIT_NAME(NODE) - }; + tl[i++] =3D SDTL(sd_numa_mask, NULL, NODE); =20 /* * .. and append 'j' levels of NUMA goodness. @@ -2025,7 +2021,7 @@ void sched_init_numa(int offline_node) .sd_flags =3D cpu_numa_flags, .flags =3D SDTL_OVERLAP, .numa_level =3D j, - SD_INIT_NAME(NUMA) + .name =3D "NUMA", }; } =20 --=20 2.49.0 From nobody Tue Oct 7 21:05:32 2025 Received: from sender4-op-o12.zoho.com (sender4-op-o12.zoho.com [136.143.188.12]) (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 DB9BB433CB for ; Sun, 6 Jul 2025 03:09:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.12 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751771370; cv=pass; b=D5PWeEEWJXx9fxC9oFRJx+SGUwcubIcv0fV1XcPoPCAdoJmUrazy5XNgEbV4ReS0FVVSIXool8yAM42KoN1kPA+u1+vHaoLQ2VyxbH65MKMKx+ZFKOlUXA8ewygT3/ZARgYrXrBwUMEpa+xJqLu+Ur5VdBN0JhkX3gDg+k8Ymbc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751771370; c=relaxed/simple; bh=sbFNafsvtu51o0eyrDKYUMuKkz3CUQWuPdMJ5NZeXz0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bOOziOIfe09ws+Zt52Zn4MKjO6EKv09apHK6ls45OaPWfXj6KmWjZF+l9GkPzKTtEwXSjoOIb7KHEYVyPaioouuqFnYUWnH9SVxyJXejK1fJU+HrYlfisAxn5Tlf/Q7hVaF9mY6X2kS+jO5piZsaqZnFcnxbzSnySYFyCjBPKbU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty; spf=pass smtp.mailfrom=linux.beauty; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b=PNJY/okX; arc=pass smtp.client-ip=136.143.188.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.beauty Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b="PNJY/okX" ARC-Seal: i=1; a=rsa-sha256; t=1751771230; cv=none; d=zohomail.com; s=zohoarc; b=IPJVpQuRKPUZOmHoPff6Y7TvZL/UypJ/eGE4WhwtYtWhT4TqGrQZZvoDU5NMZlEUS0POpnop/0mBC5Pk9cFrM6hizpQ3MSGPaw2WtA2vTRK7O59RXHWb43g0bUFR32MjHWNahryIiOD0SugHkYeNEJnHNUvqZcb3raPBOF1DsYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751771230; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=0QQA5XnseLrrWZ70NBGqrl483WRemympfW7X8ohQiWY=; b=WmGUyd57mMcyUO1JQoLKC/ejX9EI6loKAUH6r6kNsn4rxGcT6LMhVIMSDm1vH0pYRRW7KJfh8GWL8ZIkuDOhu9DA/i/MCwT4WqPkxiZfuZDS6POUMCkcMu+qg/df8rSM1J/ct9YoD2NscFeLWaK9h41ROWIalzzUNd2nu9gAcis= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=linux.beauty; spf=pass smtp.mailfrom=me@linux.beauty; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1751771230; s=zmail; d=linux.beauty; i=me@linux.beauty; h=From:From:To:To:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To:Cc; bh=0QQA5XnseLrrWZ70NBGqrl483WRemympfW7X8ohQiWY=; b=PNJY/okXJWU4RzXgoq4FN60Vior2b20Kvt3W04x9zssAbfIDPQxgyjgzakxZj3jZ LwZxQ6APmB8Ci+pECFU4IAGBgQ77UaTNmsf+8wNNScTNqxYn05xzAmiNaPHuw51KMG6 gKy/Gym8rEN3h2F7HYNY3Gah23BV7JUULP1DsfPY= Received: by mx.zohomail.com with SMTPS id 1751771228772345.1992660681566; Sat, 5 Jul 2025 20:07:08 -0700 (PDT) From: Li Chen To: Li Chen ," Thomas Gleixner "," Ingo Molnar "," Borislav Petkov "," Dave Hansen ",," H . Peter Anvin "," Rafael J . Wysocki "," Peter Zijlstra "," Sohil Mehta "," Brian Gerst "," Patryk Wlazlyn " , linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Rafael J. Wysocki" , Li Chen , Brian Gerst , Patryk Wlazlyn , K Prateek Nayak Subject: [PATCH v4 2/4] x86/smpboot: remove redundant CONFIG_SCHED_SMT Date: Sun, 6 Jul 2025 11:06:30 +0800 Message-ID: <20250706030636.397197-3-me@linux.beauty> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250706030636.397197-1-me@linux.beauty> References: <20250706030636.397197-1-me@linux.beauty> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" From: Li Chen CONFIG_SCHED_SMT is default y if SMP is enabled, so let's simply drop CONFIG_SCHED_SMT. Signed-off-by: Li Chen Suggested-by: Thomas Gleixner --- arch/x86/kernel/smpboot.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 55f09946c791b..6e36306632792 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -484,9 +484,7 @@ static void __init build_sched_topology(void) { int i =3D 0; =20 -#ifdef CONFIG_SCHED_SMT x86_topology[i++] =3D SDTL(cpu_smt_mask, cpu_smt_flags, SMT); -#endif #ifdef CONFIG_SCHED_CLUSTER x86_topology[i++] =3D SDTL(cpu_clustergroup_mask, x86_cluster_flags, CLS); #endif --=20 2.49.0 From nobody Tue Oct 7 21:05:32 2025 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (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 9547E187FE8 for ; Sun, 6 Jul 2025 03:09:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751771396; cv=pass; b=k9YkdddMNPPSfVZnyCs/wBUZfPJ9D/jPfnlqq3Uuhv7g2UKNWrBtfC+H7jYIYZxElfLbXs7TBpWCWe4eVGJgEJNMvjo0B6JQdpJrCFW9nVmm5h+1Jv4EfhCmnDxM1Z2xvfh43QDTGMyFD4Bf2dapf64OCC7+qN2SrPrtAqqMtGg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751771396; c=relaxed/simple; bh=SxZhF0dMdwr/dGfsgaktlQLXk40KKBRB25obt3i6LI0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hl3dm3ZoO3bEsOrjF+oxBriE+zHOIvPh/iMs90F2Aw7hhADfhwgziIaXna6jyJ3hgu3ceiklrL99LiZc3Xmct69gEj9DxX2mKNw/WpmyCax5vAH64UL5jTBHP87eaH+HDj0LlmbVPlaOlzA6xGzzlgTRag8BvaD/TQpo9s7Aw64= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty; spf=pass smtp.mailfrom=linux.beauty; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b=m2/EDRWS; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.beauty Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b="m2/EDRWS" ARC-Seal: i=1; a=rsa-sha256; t=1751771236; cv=none; d=zohomail.com; s=zohoarc; b=kDnup86oQDwej5zb4wajH4G639HusUhNd1xjBGYz26IwoKO0/YksFyq7KAZoLWLDXZBe7z//Mbn5PLD36NXXJVfkTbxhrSr459djLUf9+QBr84TAdtTR5DfPwA/np2TiahSkKZXbSSdAD4T4VDs/0ztQZckMPsGX4pQjRYtZIVU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751771236; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=65qbjQ7gfEeyq7t0PjihRrjU0QOq/DRjgNgU6j2clgU=; b=GI9BBr7ONN444UPp4HJoABftGSxv3DdgtT2Z1NjJXfFBo86v90aDJk+9cO93Ppxt61mH2DxSbZwJqKkX30G61NQD1HiQSF0cuLNg3zpCgF1BlZytcx465/YDvZ07MwF5SfgmqvuuJpYzwBcATuTGVN552kCtjD5zJkG9d/SyIQk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=linux.beauty; spf=pass smtp.mailfrom=me@linux.beauty; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1751771236; s=zmail; d=linux.beauty; i=me@linux.beauty; h=From:From:To:To:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To:Cc; bh=65qbjQ7gfEeyq7t0PjihRrjU0QOq/DRjgNgU6j2clgU=; b=m2/EDRWSdfrHSSmL12zAbjqdbi3toJv3LpI3P+CLTGJ7XLTlp3Gf8dS0xAI9Uh6Z Ilwy9vuZNoPBy2lKbkdpz79hBoC5P67fg4ze9MJQx5OVh95i6CvbmkYGXophOWPZXL7 1fKE4hvGJ8YmgWvPmKBTm6vvDFwWoLHzM8mjlZDo= Received: by mx.zohomail.com with SMTPS id 1751771235080189.54884702925767; Sat, 5 Jul 2025 20:07:15 -0700 (PDT) From: Li Chen To: Li Chen ," Thomas Gleixner "," Ingo Molnar "," Borislav Petkov "," Dave Hansen ",," H . Peter Anvin "," Rafael J . Wysocki "," Peter Zijlstra "," Sohil Mehta "," Brian Gerst "," Patryk Wlazlyn " , linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Rafael J. Wysocki" , Li Chen , K Prateek Nayak , Patryk Wlazlyn Subject: [PATCH v4 3/4] x86/smpboot: moves x86_topology to static initialize and truncate Date: Sun, 6 Jul 2025 11:06:31 +0800 Message-ID: <20250706030636.397197-4-me@linux.beauty> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250706030636.397197-1-me@linux.beauty> References: <20250706030636.397197-1-me@linux.beauty> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" From: Li Chen The #ifdeffery and the initializers in build_sched_topology() are just disgusting. Statically initialize the domain levels in the topology array and let build_sched_topology() invalidate the package domain level when NUMA in package is available. Suggested-by: Thomas Gleixner Signed-off-by: Li Chen --- arch/x86/kernel/smpboot.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 6e36306632792..cd70e5322462a 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -478,32 +478,30 @@ static int x86_cluster_flags(void) */ static bool x86_has_numa_in_package; =20 -static struct sched_domain_topology_level x86_topology[6]; - -static void __init build_sched_topology(void) -{ - int i =3D 0; - - x86_topology[i++] =3D SDTL(cpu_smt_mask, cpu_smt_flags, SMT); +static struct sched_domain_topology_level x86_topology[] =3D { + SDTL(cpu_smt_mask, cpu_smt_flags, SMT), #ifdef CONFIG_SCHED_CLUSTER - x86_topology[i++] =3D SDTL(cpu_clustergroup_mask, x86_cluster_flags, CLS); + SDTL(cpu_clustergroup_mask, x86_cluster_flags, CLS), #endif #ifdef CONFIG_SCHED_MC - x86_topology[i++] =3D SDTL(cpu_coregroup_mask, x86_core_flags, MC); + SDTL(cpu_coregroup_mask, x86_core_flags, MC), #endif - /* - * When there is NUMA topology inside the package skip the PKG domain - * since the NUMA domains will auto-magically create the right spanning - * domains based on the SLIT. - */ - if (!x86_has_numa_in_package) - x86_topology[i++] =3D SDTL(cpu_cpu_mask, x86_sched_itmt_flags, PKG); + SDTL(cpu_cpu_mask, x86_sched_itmt_flags, PKG), + { NULL }, +}; =20 +static void __init build_sched_topology(void) +{ /* - * There must be one trailing NULL entry left. + * When there is NUMA topology inside the package invalidate the + * PKG domain since the NUMA domains will auto-magically create the + * right spanning domains based on the SLIT. */ - BUG_ON(i >=3D ARRAY_SIZE(x86_topology) - 1); + if (x86_has_numa_in_package) { + unsigned int pkgdom =3D ARRAY_SIZE(x86_topology) - 2; =20 + memset(&x86_topology[pkgdom], 0, sizeof(x86_topology[pkgdom])); + } set_sched_topology(x86_topology); } =20 --=20 2.49.0 From nobody Tue Oct 7 21:05:32 2025 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (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 ABEB8433CB for ; Sun, 6 Jul 2025 03:10:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751771418; cv=pass; b=Q1Q4ulzsJOPSe07LjOzC2SHJrzDadeg2SzaQMHs97PZoDbShwGkoW64pTL0+Gvoge0zfIt4YSsk2OY9cIfz1/Diawi8VNcTIY+44rVNBNu0MdLNXtc4xdHi48sYV66wjaX/cKibnONjStLVIfGH8rA4aKKOSDc5JigXJbxZTeZg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751771418; c=relaxed/simple; bh=53OJ8PDmEs0+UoDAaqw1ewYlM+htiRJKt/mW5JxdAb0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A+HyUAD/ShVpv8YshcpurgDzd2AxSVJpVJ1s/HT4R0wgE0ayvk4UT5pjBLsO3XkdVi5NbHDevLMDDYRDV4YFJQW/chyoc5pWg4YQJwhvpbmOfaMemvhS+WpyHYj5jRK3pXQIZt9lsiDWbr77R/i084KAbedtCF/mnzHYB+wtCUw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty; spf=pass smtp.mailfrom=linux.beauty; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b=dYkXmUnv; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.beauty Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b="dYkXmUnv" ARC-Seal: i=1; a=rsa-sha256; t=1751771244; cv=none; d=zohomail.com; s=zohoarc; b=RtQjnCzLpHF4J64srZJYAIhUI7H4s1CmZskbEFwxopma0KByx8LmRZXPlAFDayW3G9OE8n+PPcqWwIR6x7/9pPLzAI9AJqOs4g//quIVoG1rPRas9PZF6IX9OUZS3FKxu2WkQp6nsD2LfVhdN8expirarIux9MgfYOOxZB+XAxk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751771244; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=msXyCNreV6tVt057JD4kKViyA0dJw9Qv20/D9GHOf6o=; b=Bp6Wg4Auh2B/+NrVrJtpou8kk+2uT3mM0901cZztDB9TVMPVB36U2qpuqwNP0pEHEvCA1piHKJqQN9ZD8fu99qJnbkXJV+ZArwqKzNMdzhNwPVKkFmskuGBZWZ3+1yqv1gSNWSjqLH4lUX0fKT5w/FLflGx90xlLM8BDdaHnhIs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=linux.beauty; spf=pass smtp.mailfrom=me@linux.beauty; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1751771244; s=zmail; d=linux.beauty; i=me@linux.beauty; h=From:From:To:To:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To:Cc; bh=msXyCNreV6tVt057JD4kKViyA0dJw9Qv20/D9GHOf6o=; b=dYkXmUnv+1Rj4sABBaEklUEC5VwUN7Ag5RbGPlcO2yVnjRCtWN7FxsX2r5xRwyh7 WYbOWC7PSvuGfR2QvwaWQpF39uaFCL1g57YT+XBemv561g2U9oUTpVS8DEidW2n0QV4 uAuXi4EPYhBZDmA07+0CaqRe45CthXA1sqjIHeO8= Received: by mx.zohomail.com with SMTPS id 175177124224214.037844208890306; Sat, 5 Jul 2025 20:07:22 -0700 (PDT) From: Li Chen To: Li Chen ," Thomas Gleixner "," Ingo Molnar "," Borislav Petkov "," Dave Hansen ",," H . Peter Anvin "," Rafael J . Wysocki "," Peter Zijlstra "," Sohil Mehta "," Brian Gerst "," Patryk Wlazlyn " , linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Rafael J. Wysocki" , Li Chen , Sohil Mehta , Patryk Wlazlyn , K Prateek Nayak Subject: [PATCH v4 4/4] x86/smpboot: avoid SMT domain attach/destroy if SMT is not enabled Date: Sun, 6 Jul 2025 11:06:32 +0800 Message-ID: <20250706030636.397197-5-me@linux.beauty> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250706030636.397197-1-me@linux.beauty> References: <20250706030636.397197-1-me@linux.beauty> 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 X-ZohoMailClient: External From: Li Chen Currently, the SMT domain is added into sched_domain_topology by default. If cpu_attach_domain() finds that the CPU SMT domain=E2=80=99s cpumask_weig= ht is just 1, it will destroy it. On a large machine, such as one with 512 cores, this results in 512 redundant domain attach/destroy operations. Avoid these unnecessary operations by simply checking cpu_smt_num_threads and skip SMT domain if the SMT domain is not enabled. Signed-off-by: K Prateek Nayak Tested-by: K Prateek Nayak Signed-off-by: Li Chen --- arch/x86/kernel/smpboot.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index cd70e5322462a..8c1960a455bfb 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -492,6 +492,8 @@ static struct sched_domain_topology_level x86_topology[= ] =3D { =20 static void __init build_sched_topology(void) { + struct sched_domain_topology_level *topology =3D x86_topology; + /* * When there is NUMA topology inside the package invalidate the * PKG domain since the NUMA domains will auto-magically create the @@ -502,7 +504,15 @@ static void __init build_sched_topology(void) =20 memset(&x86_topology[pkgdom], 0, sizeof(x86_topology[pkgdom])); } - set_sched_topology(x86_topology); + + /* + * Drop the SMT domains if there is only one thread per-core + * since it'll get degenerated by the scheduler anyways. + */ + if (cpu_smt_num_threads <=3D 1) + ++topology; + + set_sched_topology(topology); } =20 void set_cpu_sibling_map(int cpu) --=20 2.49.0