[PATCH v7 7/8] sched/topology: Unify tl_mc_mask() across core and all arch

K Prateek Nayak posted 8 patches 1 month, 1 week ago
[PATCH v7 7/8] sched/topology: Unify tl_mc_mask() across core and all arch
Posted by K Prateek Nayak 1 month, 1 week ago
Unify the tl_mc_mask() wrapper around cpu_coregroup_mask() used by core,
x86, powerpc, and s390.

No functional changes intended.

Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
---
 arch/powerpc/kernel/smp.c      | 7 +------
 arch/s390/kernel/topology.c    | 7 +------
 arch/x86/kernel/smpboot.c      | 7 -------
 include/linux/sched/topology.h | 8 +++++++-
 kernel/sched/topology.c        | 7 -------
 5 files changed, 9 insertions(+), 27 deletions(-)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index c58ddf84fe63..40719679385b 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -1062,11 +1062,6 @@ const struct cpumask *cpu_coregroup_mask(int cpu)
 
 	return cpu_node_mask(cpu);
 }
-
-static const struct cpumask *cpu_mc_mask(struct sched_domain_topology_level *tl, int cpu)
-{
-	return cpu_corgrp_mask(cpu);
-}
 #endif
 
 static const struct cpumask *cpu_pkg_mask(struct sched_domain_topology_level *tl, int cpu)
@@ -1729,7 +1724,7 @@ static void __init build_sched_topology(void)
 #ifdef CONFIG_SCHED_MC
 	if (has_coregroup_support()) {
 		powerpc_topology[i++] =
-			SDTL_INIT(cpu_mc_mask, powerpc_shared_proc_flags, MC);
+			SDTL_INIT(tl_mc_mask, powerpc_shared_proc_flags, MC);
 	}
 #endif
 
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index c88eda847309..8dbf32f362e1 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -514,11 +514,6 @@ const struct cpumask *cpu_coregroup_mask(int cpu)
 	return &cpu_topology[cpu].core_mask;
 }
 
-static const struct cpumask *cpu_mc_mask(struct sched_domain_topology_level *tl, int cpu)
-{
-	return &cpu_topology[cpu].core_mask;
-}
-
 static const struct cpumask *cpu_book_mask(struct sched_domain_topology_level *tl, int cpu)
 {
 	return &cpu_topology[cpu].book_mask;
@@ -536,7 +531,7 @@ static const struct cpumask *cpu_pkg_mask(struct sched_domain_topology_level *tl
 
 static struct sched_domain_topology_level s390_topology[] = {
 	SDTL_INIT(tl_smt_mask, cpu_smt_flags, SMT),
-	SDTL_INIT(cpu_mc_mask, cpu_core_flags, MC),
+	SDTL_INIT(tl_mc_mask, cpu_core_flags, MC),
 	SDTL_INIT(cpu_book_mask, NULL, BOOK),
 	SDTL_INIT(cpu_drawer_mask, NULL, DRAWER),
 	SDTL_INIT(cpu_pkg_mask, NULL, PKG),
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 81a40d777d65..bfbcac9a73d1 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -472,13 +472,6 @@ static int x86_cluster_flags(void)
 }
 #endif
 
-#ifdef CONFIG_SCHED_MC
-static const struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpu)
-{
-	return cpu_coregroup_mask(cpu);
-}
-#endif
-
 static const struct cpumask *tl_pkg_mask(struct sched_domain_topology_level *tl, int cpu)
 {
 	return cpu_node_mask(cpu);
diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h
index e54501cc8e47..075d1f063668 100644
--- a/include/linux/sched/topology.h
+++ b/include/linux/sched/topology.h
@@ -63,7 +63,13 @@ static inline int cpu_core_flags(void)
 {
 	return SD_SHARE_LLC;
 }
-#endif
+
+static const __maybe_unused
+struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpu)
+{
+	return cpu_coregroup_mask(cpu);
+}
+#endif /* CONFIG_SCHED_MC */
 
 #ifdef CONFIG_NUMA
 static inline int cpu_numa_flags(void)
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 4530cbad41e1..77d14430c5e1 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -1724,13 +1724,6 @@ sd_init(struct sched_domain_topology_level *tl,
 	return sd;
 }
 
-#ifdef CONFIG_SCHED_MC
-static const struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpu)
-{
-	return cpu_coregroup_mask(cpu);
-}
-#endif
-
 static const struct cpumask *tl_pkg_mask(struct sched_domain_topology_level *tl, int cpu)
 {
 	return cpu_node_mask(cpu);
-- 
2.34.1
Re: [PATCH v7 7/8] sched/topology: Unify tl_mc_mask() across core and all arch
Posted by Christophe Leroy 1 month, 1 week ago

Le 26/08/2025 à 06:13, K Prateek Nayak a écrit :
> Unify the tl_mc_mask() wrapper around cpu_coregroup_mask() used by core,
> x86, powerpc, and s390.
> 
> No functional changes intended.
> 
> Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
> ---
>   arch/powerpc/kernel/smp.c      | 7 +------
>   arch/s390/kernel/topology.c    | 7 +------
>   arch/x86/kernel/smpboot.c      | 7 -------
>   include/linux/sched/topology.h | 8 +++++++-
>   kernel/sched/topology.c        | 7 -------
>   5 files changed, 9 insertions(+), 27 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> index c58ddf84fe63..40719679385b 100644
> --- a/arch/powerpc/kernel/smp.c
> +++ b/arch/powerpc/kernel/smp.c
> @@ -1062,11 +1062,6 @@ const struct cpumask *cpu_coregroup_mask(int cpu)
>   
>   	return cpu_node_mask(cpu);
>   }
> -
> -static const struct cpumask *cpu_mc_mask(struct sched_domain_topology_level *tl, int cpu)
> -{
> -	return cpu_corgrp_mask(cpu);
> -}
>   #endif
>   
>   static const struct cpumask *cpu_pkg_mask(struct sched_domain_topology_level *tl, int cpu)
> @@ -1729,7 +1724,7 @@ static void __init build_sched_topology(void)
>   #ifdef CONFIG_SCHED_MC
>   	if (has_coregroup_support()) {
>   		powerpc_topology[i++] =
> -			SDTL_INIT(cpu_mc_mask, powerpc_shared_proc_flags, MC);
> +			SDTL_INIT(tl_mc_mask, powerpc_shared_proc_flags, MC);
>   	}
>   #endif
>   
> diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
> index c88eda847309..8dbf32f362e1 100644
> --- a/arch/s390/kernel/topology.c
> +++ b/arch/s390/kernel/topology.c
> @@ -514,11 +514,6 @@ const struct cpumask *cpu_coregroup_mask(int cpu)
>   	return &cpu_topology[cpu].core_mask;
>   }
>   
> -static const struct cpumask *cpu_mc_mask(struct sched_domain_topology_level *tl, int cpu)
> -{
> -	return &cpu_topology[cpu].core_mask;
> -}
> -
>   static const struct cpumask *cpu_book_mask(struct sched_domain_topology_level *tl, int cpu)
>   {
>   	return &cpu_topology[cpu].book_mask;
> @@ -536,7 +531,7 @@ static const struct cpumask *cpu_pkg_mask(struct sched_domain_topology_level *tl
>   
>   static struct sched_domain_topology_level s390_topology[] = {
>   	SDTL_INIT(tl_smt_mask, cpu_smt_flags, SMT),
> -	SDTL_INIT(cpu_mc_mask, cpu_core_flags, MC),
> +	SDTL_INIT(tl_mc_mask, cpu_core_flags, MC),
>   	SDTL_INIT(cpu_book_mask, NULL, BOOK),
>   	SDTL_INIT(cpu_drawer_mask, NULL, DRAWER),
>   	SDTL_INIT(cpu_pkg_mask, NULL, PKG),
> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
> index 81a40d777d65..bfbcac9a73d1 100644
> --- a/arch/x86/kernel/smpboot.c
> +++ b/arch/x86/kernel/smpboot.c
> @@ -472,13 +472,6 @@ static int x86_cluster_flags(void)
>   }
>   #endif
>   
> -#ifdef CONFIG_SCHED_MC
> -static const struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpu)
> -{
> -	return cpu_coregroup_mask(cpu);
> -}
> -#endif
> -
>   static const struct cpumask *tl_pkg_mask(struct sched_domain_topology_level *tl, int cpu)
>   {
>   	return cpu_node_mask(cpu);
> diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h
> index e54501cc8e47..075d1f063668 100644
> --- a/include/linux/sched/topology.h
> +++ b/include/linux/sched/topology.h
> @@ -63,7 +63,13 @@ static inline int cpu_core_flags(void)
>   {
>   	return SD_SHARE_LLC;
>   }
> -#endif
> +
> +static const __maybe_unused

Same as the two previous patches, __maybe_unused shouldn't be required.

> +struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpu)
> +{
> +	return cpu_coregroup_mask(cpu);
> +}
> +#endif /* CONFIG_SCHED_MC */
>   
>   #ifdef CONFIG_NUMA
>   static inline int cpu_numa_flags(void)
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 4530cbad41e1..77d14430c5e1 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -1724,13 +1724,6 @@ sd_init(struct sched_domain_topology_level *tl,
>   	return sd;
>   }
>   
> -#ifdef CONFIG_SCHED_MC
> -static const struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpu)
> -{
> -	return cpu_coregroup_mask(cpu);
> -}
> -#endif
> -
>   static const struct cpumask *tl_pkg_mask(struct sched_domain_topology_level *tl, int cpu)
>   {
>   	return cpu_node_mask(cpu);