[PATCH v7 6/8] sched/topology: Unify tl_cls_mask() across core and x86

K Prateek Nayak posted 8 patches 1 month, 1 week ago
[PATCH v7 6/8] sched/topology: Unify tl_cls_mask() across core and x86
Posted by K Prateek Nayak 1 month, 1 week ago
Unify the tl_cls_mask() used by both the scheduler core and x86.
No functional changes intended.

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

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 03ff6270966a..81a40d777d65 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -470,10 +470,6 @@ static int x86_cluster_flags(void)
 {
 	return cpu_cluster_flags() | x86_sched_itmt_flags();
 }
-static const struct cpumask *tl_cls_mask(struct sched_domain_topology_level *tl, int cpu)
-{
-	return cpu_clustergroup_mask(cpu);
-}
 #endif
 
 #ifdef CONFIG_SCHED_MC
diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h
index d75fbb7d9667..e54501cc8e47 100644
--- a/include/linux/sched/topology.h
+++ b/include/linux/sched/topology.h
@@ -50,7 +50,13 @@ static inline int cpu_cluster_flags(void)
 {
 	return SD_CLUSTER | SD_SHARE_LLC;
 }
-#endif
+
+static const __maybe_unused
+struct cpumask *tl_cls_mask(struct sched_domain_topology_level *tl, int cpu)
+{
+	return cpu_clustergroup_mask(cpu);
+}
+#endif /* CONFIG_SCHED_CLUSTER */
 
 #ifdef CONFIG_SCHED_MC
 static inline int cpu_core_flags(void)
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 92165fe56a2d..4530cbad41e1 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_CLUSTER
-static const struct cpumask *tl_cls_mask(struct sched_domain_topology_level *tl, int cpu)
-{
-	return cpu_clustergroup_mask(cpu);
-}
-#endif
-
 #ifdef CONFIG_SCHED_MC
 static const struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpu)
 {
-- 
2.34.1
Re: [PATCH v7 6/8] sched/topology: Unify tl_cls_mask() across core and x86
Posted by Christophe Leroy 1 month, 1 week ago

Le 26/08/2025 à 06:13, K Prateek Nayak a écrit :
> Unify the tl_cls_mask() used by both the scheduler core and x86.
> No functional changes intended.
> 
> Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
> ---
>   arch/x86/kernel/smpboot.c      | 4 ----
>   include/linux/sched/topology.h | 8 +++++++-
>   kernel/sched/topology.c        | 7 -------
>   3 files changed, 7 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
> index 03ff6270966a..81a40d777d65 100644
> --- a/arch/x86/kernel/smpboot.c
> +++ b/arch/x86/kernel/smpboot.c
> @@ -470,10 +470,6 @@ static int x86_cluster_flags(void)
>   {
>   	return cpu_cluster_flags() | x86_sched_itmt_flags();
>   }
> -static const struct cpumask *tl_cls_mask(struct sched_domain_topology_level *tl, int cpu)
> -{
> -	return cpu_clustergroup_mask(cpu);
> -}
>   #endif
>   
>   #ifdef CONFIG_SCHED_MC
> diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h
> index d75fbb7d9667..e54501cc8e47 100644
> --- a/include/linux/sched/topology.h
> +++ b/include/linux/sched/topology.h
> @@ -50,7 +50,13 @@ static inline int cpu_cluster_flags(void)
>   {
>   	return SD_CLUSTER | SD_SHARE_LLC;
>   }
> -#endif
> +
> +static const __maybe_unused

Same as previous patch, don't hide dust under the carpet, if you need 
__maybe_unused it means there is a problem in the construct.

> +struct cpumask *tl_cls_mask(struct sched_domain_topology_level *tl, int cpu)
> +{
> +	return cpu_clustergroup_mask(cpu);
> +}
> +#endif /* CONFIG_SCHED_CLUSTER */
>   
>   #ifdef CONFIG_SCHED_MC
>   static inline int cpu_core_flags(void)
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 92165fe56a2d..4530cbad41e1 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_CLUSTER
> -static const struct cpumask *tl_cls_mask(struct sched_domain_topology_level *tl, int cpu)
> -{
> -	return cpu_clustergroup_mask(cpu);
> -}
> -#endif
> -
>   #ifdef CONFIG_SCHED_MC
>   static const struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpu)
>   {