[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5940cd15-b207-416a-b4e4-b5953f4cbf47@amd.com>
Date: Mon, 25 Aug 2025 16:17:52 +0530
From: K Prateek Nayak <kprateek.nayak@....com>
To: Peter Zijlstra <peterz@...radead.org>
CC: Ingo Molnar <mingo@...hat.com>, Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>, Valentin Schneider
<vschneid@...hat.com>, Leon Romanovsky <leon@...nel.org>,
<linux-kernel@...r.kernel.org>, Steve Wahl <steve.wahl@....com>, Borislav
Petkov <bp@...en8.de>, Dietmar Eggemann <dietmar.eggemann@....com>, Steven
Rostedt <rostedt@...dmis.org>, Ben Segall <bsegall@...gle.com>, Mel Gorman
<mgorman@...e.de>, <srikar@...ux.vnet.ibm.com>, <hca@...ux.ibm.com>
Subject: Re: [PATCH v5] sched/fair: Use sched_domain_span() for
topology_span_sane()
Hello Peter,
On 8/25/2025 2:49 PM, Peter Zijlstra wrote:
> We should either set ->mask to NULL for NUMA thingies to make sure we
> don't end up using it again, or bite the bullet and fix up the mask
> function declaration.
>
> Something a little like so?
Both the QEMU VM from the above commit message and my 3rd Generation
EPYC are happy with the changes. One concern:
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 977e133bb8a4..8164ffabcd31 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -1732,22 +1724,42 @@ sd_init(struct sched_domain_topology_level *tl,
> return sd;
> }
>
> +static const struct cpumask *tl_smt_mask(struct sched_domain_topology_level *tl, int cpu)
> +{
> + return cpu_smt_mask(cpu);
> +}
> +
> +static const struct cpumask *tl_cls_mask(struct sched_domain_topology_level *tl, int cpu)
> +{
> + return q(cpu);
> +}
> +
> +static const struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpu)
> +{
> + return cpu_coregroup_mask(cpu);
> +}
> +
The above helpers may need guarding behind CONFIG_SCHED_{SMT,CLUSTER,MC}
if I'm not mistaken. Possibility for some unification and cleanup with:
(Only build and boot tested on x86 on top of tip/master + your diff)
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 0b5897fff687..a0eeb6e39304 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -1054,16 +1054,6 @@ static bool has_coregroup_support(void)
return coregroup_enabled;
}
-static const struct cpumask *cpu_mc_mask(struct sched_domain_topology_level *tl, int cpu)
-{
- return cpu_coregroup_mask(cpu);
-}
-
-static const struct cpumask *cpu_pkg_mask(struct sched_domain_topology_level *tl, int cpu)
-{
- return cpu_node_mask(cpu);
-}
-
static int __init init_big_cores(void)
{
int cpu;
@@ -1718,10 +1708,10 @@ static void __init build_sched_topology(void)
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);
}
- powerpc_topology[i++] = SDTL_INIT(cpu_pkg_mask, powerpc_shared_proc_flags, PKG);
+ powerpc_topology[i++] = SDTL_INIT(tl_pkg_mask, powerpc_shared_proc_flags, PKG);
/* There must be one trailing NULL entry left. */
BUG_ON(i >= ARRAY_SIZE(powerpc_topology) - 1);
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index df036ab83920..68d22cf3c604 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -530,17 +530,12 @@ static const struct cpumask *cpu_drawer_mask(struct sched_domain_topology_level
return &cpu_topology[cpu].drawer_mask;
}
-static const struct cpumask *cpu_pkg_mask(struct sched_domain_topology_level *tl, int cpu)
-{
- return cpu_node_mask(cpu);
-}
-
static struct sched_domain_topology_level s390_topology[] = {
SDTL_INIT(cpu_thread_mask, cpu_smt_flags, SMT),
SDTL_INIT(cpu_coregroup_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),
+ SDTL_INIT(tl_pkg_mask, NULL, PKG),
{ NULL, },
};
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 31a3b57314ef..eb289abece23 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -471,26 +471,6 @@ static int x86_cluster_flags(void)
}
#endif
-static const struct cpumask *tl_smt_mask(struct sched_domain_topology_level *tl, int cpu)
-{
- return cpu_smt_mask(cpu);
-}
-
-static const struct cpumask *tl_cls_mask(struct sched_domain_topology_level *tl, int cpu)
-{
- return cpu_clustergroup_mask(cpu);
-}
-
-static const struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpu)
-{
- return cpu_coregroup_mask(cpu);
-}
-
-static const struct cpumask *tl_pkg_mask(struct sched_domain_topology_level *tl, int cpu)
-{
- return cpu_node_mask(cpu);
-}
-
/*
* Set if a package/die has multiple NUMA nodes inside.
* AMD Magny-Cours, Intel Cluster-on-Die, and Intel
diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h
index f0a53b0e67f5..c7457ccf05c4 100644
--- a/include/linux/sched/topology.h
+++ b/include/linux/sched/topology.h
@@ -30,11 +30,19 @@ struct sd_flag_debug {
};
extern const struct sd_flag_debug sd_flag_debug[];
+struct sched_domain_topology_level;
+
#ifdef CONFIG_SCHED_SMT
static inline int cpu_smt_flags(void)
{
return SD_SHARE_CPUCAPACITY | SD_SHARE_LLC;
}
+
+static const __maybe_unused
+struct cpumask *tl_smt_mask(struct sched_domain_topology_level *tl, int cpu)
+{
+ return cpu_smt_mask(cpu);
+}
#endif
#ifdef CONFIG_SCHED_CLUSTER
@@ -42,6 +50,12 @@ static inline int cpu_cluster_flags(void)
{
return SD_CLUSTER | SD_SHARE_LLC;
}
+
+static const __maybe_unused
+struct cpumask *tl_cls_mask(struct sched_domain_topology_level *tl, int cpu)
+{
+ return cpu_clustergroup_mask(cpu);
+}
#endif
#ifdef CONFIG_SCHED_MC
@@ -49,8 +63,20 @@ static inline int cpu_core_flags(void)
{
return SD_SHARE_LLC;
}
+
+static const __maybe_unused
+struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpu)
+{
+ return cpu_coregroup_mask(cpu);
+}
#endif
+static const __maybe_unused
+struct cpumask *tl_pkg_mask(struct sched_domain_topology_level *tl, int cpu)
+{
+ return cpu_node_mask(cpu);
+}
+
#ifdef CONFIG_NUMA
static inline int cpu_numa_flags(void)
{
@@ -172,8 +198,6 @@ bool cpus_equal_capacity(int this_cpu, int that_cpu);
bool cpus_share_cache(int this_cpu, int that_cpu);
bool cpus_share_resources(int this_cpu, int that_cpu);
-struct sched_domain_topology_level;
-
typedef const struct cpumask *(*sched_domain_mask_f)(struct sched_domain_topology_level *tl, int cpu);
typedef int (*sched_domain_flags_f)(void);
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 8164ffabcd31..18889bd97e22 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -1724,26 +1724,6 @@ sd_init(struct sched_domain_topology_level *tl,
return sd;
}
-static const struct cpumask *tl_smt_mask(struct sched_domain_topology_level *tl, int cpu)
-{
- return cpu_smt_mask(cpu);
-}
-
-static const struct cpumask *tl_cls_mask(struct sched_domain_topology_level *tl, int cpu)
-{
- return cpu_clustergroup_mask(cpu);
-}
-
-static const struct cpumask *tl_mc_mask(struct sched_domain_topology_level *tl, int cpu)
-{
- return cpu_coregroup_mask(cpu);
-}
-
-static const struct cpumask *tl_pkg_mask(struct sched_domain_topology_level *tl, int cpu)
-{
- return cpu_node_mask(cpu);
-}
-
/*
* Topology list, bottom-up.
*/
--
Thoughts?
--
Thanks and Regards,
Prateek
Powered by blists - more mailing lists