sched: topology: add input parameter for sched_domain_flags_f()
PATCH 1/1 sched: topology: add input parameter for sched_domain_flags_f()
From: Wang Qing <[email protected]>
sched_domain_flags_f() are statically set now, but actually, we can get a lot of necessary information based on the cpu_map. e.g. we can know whether its cache is shared.
Allows custom extension without affecting current.
--- arch/powerpc/kernel/smp.c | 4 ++-- arch/x86/kernel/smpboot.c | 8 ++++---- include/linux/sched/topology.h | 10 +++++----- kernel/sched/topology.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-)
arch/powerpc/kernel/smp.c +2 -2
@@ -1000,7 +1000,7 @@ static bool shared_caches;#ifdef CONFIG_SCHED_SMT /* cpumask of CPUs with asymmetric SMT dependency */ -static int powerpc_smt_flags (void ) +static int powerpc_smt_flags (const struct cpumask *cpu_map) {int flags =SD_SHARE_CPUCAPACITY |SD_SHARE_PKG_RESOURCES ;
@@ -1018,7 +1018,7 @@ static int powerpc_smt_flags(void)* since the migrated task remains cache hot. We want to take advantage of this * at the scheduler level so an extra topology level is required. */ -static int powerpc_shared_cache_flags (void ) +static int powerpc_shared_cache_flags (const struct cpumask *cpu_map) {return SD_SHARE_PKG_RESOURCES ; }
arch/x86/kernel/smpboot.c +4 -4
@@ -535,25 +535,25 @@ static bool match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)#if defined(CONFIG_SCHED_SMT ) || defined(CONFIG_SCHED_CLUSTER ) || defined(CONFIG_SCHED_MC ) -static inline int x86_sched_itmt_flags (void ) +static inline int x86_sched_itmt_flags (const struct cpumask *cpu_map) {return sysctl_sched_itmt_enabled ?SD_ASYM_PACKING :0 ; }#ifdef CONFIG_SCHED_MC -static int x86_core_flags (void ) +static int x86_core_flags (const struct cpumask *cpu_map) {return cpu_core_flags () |x86_sched_itmt_flags (); }#endif #ifdef CONFIG_SCHED_SMT -static int x86_smt_flags (void ) +static int x86_smt_flags (const struct cpumask *cpu_map) {return cpu_smt_flags () |x86_sched_itmt_flags (); }#endif #ifdef CONFIG_SCHED_CLUSTER -static int x86_cluster_flags (void ) +static int x86_cluster_flags (const struct cpumask *cpu_map) {return cpu_cluster_flags () |x86_sched_itmt_flags (); }
include/linux/sched/topology.h +5 -5
@@ -36,28 +36,28 @@ extern const struct sd_flag_debug sd_flag_debug[];#endif #ifdef CONFIG_SCHED_SMT -static inline int cpu_smt_flags (void ) +static inline int cpu_smt_flags (const struct cpumask *cpu_map) {return SD_SHARE_CPUCAPACITY |SD_SHARE_PKG_RESOURCES ; }#endif #ifdef CONFIG_SCHED_CLUSTER -static inline int cpu_cluster_flags (void ) +static inline int cpu_cluster_flags (const struct cpumask *cpu_map) {return SD_SHARE_PKG_RESOURCES ; }#endif #ifdef CONFIG_SCHED_MC -static inline int cpu_core_flags (void ) +static inline int cpu_core_flags (const struct cpumask *cpu_map) {return SD_SHARE_PKG_RESOURCES ; }#endif #ifdef CONFIG_NUMA -static inline int cpu_numa_flags (void ) +static inline int cpu_numa_flags (const struct cpumask *cpu_map) {return SD_NUMA ; }
@@ -180,7 +180,7 @@ void free_sched_domains(cpumask_var_t doms[], unsigned int ndoms);bool cpus_share_cache (int this_cpu,int that_cpu);typedef const struct cpumask *(*sched_domain_mask_f )(int cpu); -typedef int (*sched_domain_flags_f )(void ); +typedef int (*sched_domain_flags_f )(const struct cpumask *cpu_map);#define SDTL_OVERLAP 0x01
kernel/sched/topology.c +1 -1
@@ -1556,7 +1556,7 @@ sd_init(struct sched_domain_topology_level *tl, sd_weight =cpumask_weight (tl->mask (cpu));if (tl->sd_flags) - sd_flags = (*tl->sd_flags)(); + sd_flags = (*tl->sd_flags)(tl->mask (cpu));if (WARN_ONCE (sd_flags & ~TOPOLOGY_SD_FLAGS ,"wrong sd_flags in topology description\n" )) sd_flags &=TOPOLOGY_SD_FLAGS ;
Signature · 1 line
2.7.4
Quoted 8 lines · Qing Wang
From: Wang Qing <[email protected]>
sched_domain_flags_f()are statically set now, but actually, we can get a lot of necessary information based on thecpu_map. e.g. we can know whether its cache is shared.Allows custom extension without affecting current.
can you elaborate on how passing a cpumask pointer will help us to know if cache is shared or not? With this patch, we are just passing the cpumask, but dont seem to be using it in any of the cases.
or did I miss anything?
Quoted 127 lines
Signed-off-by Wang Qing <[email protected]>--- arch/powerpc/kernel/smp.c | 4 ++-- arch/x86/kernel/smpboot.c | 8 ++++---- include/linux/sched/topology.h | 10 +++++----- kernel/sched/topology.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-)arch/powerpc/kernel/smp.c +2
-2@@ -1000,7 +1000,7 @@ static bool shared_caches;#ifdef CONFIG_SCHED_SMT /* cpumask of CPUs with asymmetric SMT dependency */ -static int powerpc_smt_flags (void ) +static int powerpc_smt_flags (const struct cpumask *cpu_map) {int flags =SD_SHARE_CPUCAPACITY |SD_SHARE_PKG_RESOURCES ;@@ -1018,7 +1018,7 @@ static int powerpc_smt_flags(void)* since the migrated task remains cache hot. We want to take advantage of this * at the scheduler level so an extra topology level is required. */ -static int powerpc_shared_cache_flags (void ) +static int powerpc_shared_cache_flags (const struct cpumask *cpu_map) {return SD_SHARE_PKG_RESOURCES ; }arch/x86/kernel/smpboot.c +4
-4@@ -535,25 +535,25 @@ static bool match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)#if defined(CONFIG_SCHED_SMT ) || defined(CONFIG_SCHED_CLUSTER ) || defined(CONFIG_SCHED_MC ) -static inline int x86_sched_itmt_flags (void ) +static inline int x86_sched_itmt_flags (const struct cpumask *cpu_map) {return sysctl_sched_itmt_enabled ?SD_ASYM_PACKING :0 ; }#ifdef CONFIG_SCHED_MC -static int x86_core_flags (void ) +static int x86_core_flags (const struct cpumask *cpu_map) {return cpu_core_flags () |x86_sched_itmt_flags (); }#endif #ifdef CONFIG_SCHED_SMT -static int x86_smt_flags (void ) +static int x86_smt_flags (const struct cpumask *cpu_map) {return cpu_smt_flags () |x86_sched_itmt_flags (); }#endif #ifdef CONFIG_SCHED_CLUSTER -static int x86_cluster_flags (void ) +static int x86_cluster_flags (const struct cpumask *cpu_map) {return cpu_cluster_flags () |x86_sched_itmt_flags (); }include/linux/sched/topology.h +5
-5@@ -36,28 +36,28 @@ extern const struct sd_flag_debug sd_flag_debug[];#endif #ifdef CONFIG_SCHED_SMT -static inline int cpu_smt_flags (void ) +static inline int cpu_smt_flags (const struct cpumask *cpu_map) {return SD_SHARE_CPUCAPACITY |SD_SHARE_PKG_RESOURCES ; }#endif #ifdef CONFIG_SCHED_CLUSTER -static inline int cpu_cluster_flags (void ) +static inline int cpu_cluster_flags (const struct cpumask *cpu_map) {return SD_SHARE_PKG_RESOURCES ; }#endif #ifdef CONFIG_SCHED_MC -static inline int cpu_core_flags (void ) +static inline int cpu_core_flags (const struct cpumask *cpu_map) {return SD_SHARE_PKG_RESOURCES ; }#endif #ifdef CONFIG_NUMA -static inline int cpu_numa_flags (void ) +static inline int cpu_numa_flags (const struct cpumask *cpu_map) {return SD_NUMA ; }@@ -180,7 +180,7 @@ void free_sched_domains(cpumask_var_t doms[], unsigned int ndoms);bool cpus_share_cache (int this_cpu,int that_cpu);typedef const struct cpumask *(*sched_domain_mask_f )(int cpu); -typedef int (*sched_domain_flags_f )(void ); +typedef int (*sched_domain_flags_f )(const struct cpumask *cpu_map);#define SDTL_OVERLAP 0x01kernel/sched/topology.c +1
-1@@ -1556,7 +1556,7 @@ sd_init(struct sched_domain_topology_level *tl, sd_weight =cpumask_weight (tl->mask (cpu));if (tl->sd_flags) - sd_flags = (*tl->sd_flags)(); + sd_flags = (*tl->sd_flags)(tl->mask (cpu));if (WARN_ONCE (sd_flags & ~TOPOLOGY_SD_FLAGS ,"wrong sd_flags in topology description\n" )) sd_flags &=TOPOLOGY_SD_FLAGS ;Signature · 1 line
2.7.4
Quoted 7 lines · Qing Wang
From: Wang Qing <[email protected]>
sched_domain_flags_f()are statically set now, but actually, we can get a lot of necessary information based on thecpu_map. e.g. we can know whether its cache is shared.Allows custom extension without affecting current.
This all still makes absolutely no sense. The architecture builds these masks, the architecture is in charge of which flags function is called on which mask.
Passing the mask back in means it lost the plot somewhere and doens't know wth it's doing anymore.
NAK
PATCH 1/1 sched: topology: add input parameter for sched_domain_flags_f()
Quoted 7 lines
Quoted 7 lines
From: Wang Qing <[email protected]>
sched_domain_flags_f()are statically set now, but actually, we can get a lot of necessary information based on thecpu_map. e.g. we can know whether its cache is shared.
Quoted 8 lines
Quoted 1 line
Allows custom extension without affecting current.
This all still makes absolutely no sense. The architecture builds these masks, the architecture is in charge of which flags function is called on which mask.
Passing the mask back in means it lost the plot somewhere and doens't know wth it's doing anymore.
It is not passing the mask back, sched_domain_flags_f() doesn't use cpumask at all, it always return fixed values. sd_topology_level select different sd_flag() to config, it's too primitive.
If an architecture can describe its cache topology clearly in every level, the sd only need sched_domain_flags_f(cpumask) to get its ShPR flag.
Thanks,
Wang
Quoted 2 lines
NAK