sched/fair: add SD_CLUSTER in comments
PATCH v3 1/4 sched/fair: add SD_CLUSTER in comments
From: Alex Shi <[email protected]>
The description of SD_CLUSTER is missing. Add it.
To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>
--- kernel/sched/topology.c | 1 + 1 file changed, 1 insertion(+)
kernel/sched/topology.c +1 -0
@@ -1554,6 +1554,7 @@ static struct cpumask ***sched_domains_numa_masks;* function: * * SD_SHARE_CPUCAPACITY - describes SMT topologies +* SD_CLUSTER - describes CPU Cluster topologies * SD_SHARE_PKG_RESOURCES - describes shared caches * SD_NUMA - describes NUMA topologies *
Signature · 1 line
2.43.0
PATCH v3 2/4 sched/fair: remove unused parameters
From: Alex Shi <[email protected]>
sds isn't used in function sched_asym(), so remove it to cleanup code.
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>
--- kernel/sched/fair.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/sched/fair.c +2 -4
@@ -9750,7 +9750,6 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu)/** * sched_asym - Check if the destination CPU can do asym_packing load balance * @env: The load balancing environment -* @sds: Load-balancing data with statistics of the local group * @sgs: Load-balancing statistics of the candidate busiest group * @group: The candidate busiest group *
@@ -9769,8 +9768,7 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu)* otherwise. */ static inline bool -sched_asym (struct lb_env *env,struct sd_lb_stats *sds,struct sg_lb_stats *sgs, -struct sched_group *group) +sched_asym (struct lb_env *env,struct sg_lb_stats *sgs,struct sched_group *group) {/* Ensure that the whole local core is idle, if applicable. */ if (!sched_use_asym_prio (env->sd, env->dst_cpu))
@@ -9941,7 +9939,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,/* Check if dst CPU is idle and preferred to this group */ if (!local_group && env->sd->flags &SD_ASYM_PACKING && env->idle !=CPU_NOT_IDLE && sgs->sum_h_nr_running && -sched_asym (env, sds, sgs, group)) { +sched_asym (env, sgs, group)) { sgs->group_asym_packing =1 ; }
Signature · 1 line
2.43.0
PATCH v3 3/4 sched/fair: packing func sched_use_asym_prio()/sched_asym_prefer()
In reply to [email protected]From: Alex Shi <[email protected]>
Consolidate the functions sched_use_asym_prio() and sched_asym_prefer() into one. and rename sched_asym() as sched_group_asym(). This makes the code easier to read. No functional changes.
To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>
--- kernel/sched/fair.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
kernel/sched/fair.c +18 -17
@@ -9747,8 +9747,15 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu)return sd->flags &SD_SHARE_CPUCAPACITY ||is_core_idle (cpu); } +static inline bool sched_asym (struct sched_domain *sd,int dst_cpu,int src_cpu) +{ +/* Check if asym balance applicable, then check priorities.*/ +return sched_use_asym_prio (sd, dst_cpu) && +sched_asym_prefer (dst_cpu, src_cpu); +} +/** -* sched_asym - Check if the destination CPU can do asym_packing load balance +* sched_group_asym - Check if the destination CPU can do asym_packing balance * @env: The load balancing environment * @sgs: Load-balancing statistics of the candidate busiest group * @group: The candidate busiest group
@@ -9768,22 +9775,18 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu)* otherwise. */ static inline bool -sched_asym (struct lb_env *env,struct sg_lb_stats *sgs,struct sched_group *group) +sched_group_asym (struct lb_env *env,struct sg_lb_stats *sgs,struct sched_group *group) { -/* Ensure that the whole local core is idle, if applicable. */ -if (!sched_use_asym_prio (env->sd, env->dst_cpu)) -return false; -/* -* CPU priorities does not make sense for SMT cores with more than one +* CPU priorities do not make sense for SMT cores with more than one * busy sibling. */ -if (group->flags &SD_SHARE_CPUCAPACITY ) { -if (sgs->group_weight - sgs->idle_cpus !=1 ) -return false; - } -return sched_asym_prefer (env->dst_cpu, group->asym_prefer_cpu); +if ((group->flags &SD_SHARE_CPUCAPACITY ) && + (sgs->group_weight - sgs->idle_cpus !=1 )) +return false; + +return sched_asym (env->sd, env->dst_cpu, group->asym_prefer_cpu); }/* One group has more than one SMT CPU while the other group does not */
@@ -9939,7 +9942,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,/* Check if dst CPU is idle and preferred to this group */ if (!local_group && env->sd->flags &SD_ASYM_PACKING && env->idle !=CPU_NOT_IDLE && sgs->sum_h_nr_running && -sched_asym (env, sgs, group)) { +sched_group_asym (env, sgs, group)) { sgs->group_asym_packing =1 ; }
@@ -11038,8 +11041,7 @@ static struct rq *find_busiest_queue(struct lb_env *env,* SMT cores with more than one busy sibling. */ if ((env->sd->flags &SD_ASYM_PACKING ) && -sched_use_asym_prio (env->sd, i) && -sched_asym_prefer (i, env->dst_cpu) && +sched_asym (env->sd, i, env->dst_cpu) && nr_running ==1 )continue ;
@@ -11909,8 +11911,7 @@ static void nohz_balancer_kick(struct rq *rq)* preferred CPU must be idle. */ for_each_cpu_and (i,sched_domain_span (sd), nohz.idle_cpus_mask) { -if (sched_use_asym_prio (sd, i) && -sched_asym_prefer (i, cpu)) { +if (sched_asym (sd, i, cpu)) { flags =NOHZ_STATS_KICK |NOHZ_BALANCE_KICK ; goto unlock; }
Signature · 1 line
2.43.0
PATCH v3 4/4 sched/fair: Check the SD_ASYM_PACKING flag in sched_use_asym_prio()
In reply to [email protected]From: Alex Shi <[email protected]>
sched_use_asym_prio() checks whether CPU priorities should be used. It makes sense to check for the SD_ASYM_PACKING() inside the function. Since both sched_asym() and sched_group_asym() use sched_use_asym_prio(), remove the now superfluous checks for the flag in various places"
To: Ricardo Neri <[email protected]>
To: Ben Segall <[email protected]>
To: Steven Rostedt <[email protected]>
To: Dietmar Eggemann <[email protected]>
To: Valentin Schneider <[email protected]>
To: Daniel Bristot de Oliveira <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>
--- kernel/sched/fair.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
kernel/sched/fair.c +7 -8
@@ -9741,6 +9741,9 @@ group_type group_classify(unsigned int imbalance_pct,*/ static bool sched_use_asym_prio (struct sched_domain *sd,int cpu) { +if (!(sd->flags &SD_ASYM_PACKING )) +return false; +if (!sched_smt_active ())return true;
@@ -9940,11 +9943,9 @@ static inline void update_sg_lb_stats(struct lb_env *env, sgs->group_weight = group->group_weight;/* Check if dst CPU is idle and preferred to this group */ -if (!local_group && env->sd->flags &SD_ASYM_PACKING && - env->idle !=CPU_NOT_IDLE && sgs->sum_h_nr_running && -sched_group_asym (env, sgs, group)) { +if (!local_group && env->idle !=CPU_NOT_IDLE && sgs->sum_h_nr_running && +sched_group_asym (env, sgs, group)) sgs->group_asym_packing =1 ; - }/* Check for loaded SMT group to be balanced to dst CPU */ if (!local_group &&smt_balance (env, sgs, group))
@@ -11040,9 +11041,7 @@ static struct rq *find_busiest_queue(struct lb_env *env,* If balancing between cores, let lower priority CPUs help * SMT cores with more than one busy sibling. */ -if ((env->sd->flags &SD_ASYM_PACKING ) && -sched_asym (env->sd, i, env->dst_cpu) && - nr_running ==1 ) +if (sched_asym (env->sd, i, env->dst_cpu) && nr_running ==1 )continue ;switch (env->migration_type) {
@@ -11138,7 +11137,7 @@ asym_active_balance(struct lb_env *env)* the lower priority @env::dst_cpu help it. Do not follow * CPU priority. */ -return env->idle !=CPU_NOT_IDLE && (env->sd->flags &SD_ASYM_PACKING ) && +return env->idle !=CPU_NOT_IDLE &&sched_use_asym_prio (env->sd, env->dst_cpu) && (sched_asym_prefer (env->dst_cpu, env->src_cpu) || !sched_use_asym_prio (env->sd, env->src_cpu));
Signature · 1 line
2.43.0
Re: [PATCH v3 2/4] sched/fair: remove unused parameters
In reply to [email protected]Quoted 6 lines · On 01/02/24 19:54, [email protected] wrote:
From: Alex Shi <[email protected]>
sds isn't used in function
sched_asym(), so remove it to cleanup code.Signed-off-by Alex Shi <[email protected]>Reviewed-by Ricardo Neri <[email protected]>
AFAICT this is unsused as of:
c9ca07886aaa ("sched/fair: Do not even the number of busy CPUs via asym_packing")
Quoted 42 lines
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>--- kernel/sched/fair.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)kernel/sched/fair.c +2
-5@@ -9750,7 +9750,6 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu)/** * sched_asym - Check if the destination CPU can do asym_packing load balance * @env: The load balancing environment -* @sds: Load-balancing data with statistics of the local group * @sgs: Load-balancing statistics of the candidate busiest group * @group: The candidate busiest group * @@ -9769,8 +9768,7 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu)* otherwise. */ static inline bool -sched_asym (struct lb_env *env,struct sd_lb_stats *sds,struct sg_lb_stats *sgs, -struct sched_group *group) +sched_asym (struct lb_env *env,struct sg_lb_stats *sgs,struct sched_group *group) {/* Ensure that the whole local core is idle, if applicable. */ if (!sched_use_asym_prio (env->sd, env->dst_cpu))@@ -9941,7 +9939,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,/* Check if dst CPU is idle and preferred to this group */ if (!local_group && env->sd->flags &SD_ASYM_PACKING && env->idle !=CPU_NOT_IDLE && sgs->sum_h_nr_running && -sched_asym (env, sds, sgs, group)) { +sched_asym (env, sgs, group)) { sgs->group_asym_packing =1 ; } --2.43.0
Valentin Schneider
reviewerSubject nit: the prefix should be sched/topology
Quoted 20 lines · On 01/02/24 19:54, [email protected] wrote:
From: Alex Shi <[email protected]>
The description of
SD_CLUSTERis missing. Add it.Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>--- kernel/sched/topology.c | 1 + 1 file changed, 1 insertion(+)kernel/sched/topology.c +0
-0
kernel/sched/topology.c static struct cpumask ***sched_domains_numa_masks; · line 1557
Quoted 4 lines
kernel/sched/topology.c +1
-0@@ -1554,6 +1554,7 @@ static struct cpumask ***sched_domains_numa_masks;* function: * * SD_SHARE_CPUCAPACITY - describes SMT topologies +* SD_CLUSTER - describes CPU Cluster topologies
So I know this is the naming we've gone for the "Cluster" naming, but this comment isn't really explaining anything.
include/linux/sched/sd_flags.h has a bit more info already:
* Domain members share CPU cluster (LLC tags or L2 cache)
I had to go through a bit of git history to remember what the CLUSTER thing was about, how about this:
* SD_CLUSTER - describes shared shared caches, cache tags or busses
* SD_SHARE_PKG_RESOURCES - describes shared LLC cache
And looking at this it would make sense to:
rename SD_CLUSTER into SD_SHARE_PKG_RESOURCES
rename SD_SHARE_PKG_RESOURCES into SD_SHARE_LLC
but that's another topic...
Quoted 5 lines
kernel/sched/topology.c +0
-1* SD_SHARE_PKG_RESOURCES - describes shared caches * SD_NUMA - describes NUMA topologies * -- 2.43.0
Re: [PATCH v3 3/4] sched/fair: packing func sched_use_asym_prio()/sched_asym_prefer()
In reply to [email protected]Hi Ricardo,
Since your good suggestions took in this and the next patch, do you mind to give Reviewed-by for both of them?
Thanks
Alex
Quoted 96 lines · On 2/1/24 7:54 PM, [email protected] wrote:
From: Alex Shi <[email protected]>
Consolidate the functions
sched_use_asym_prio()andsched_asym_prefer()into one. and renamesched_asym()assched_group_asym(). This makes the code easier to read. No functional changes.Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>--- kernel/sched/fair.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)kernel/sched/fair.c +18
-17@@ -9747,8 +9747,15 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu)return sd->flags &SD_SHARE_CPUCAPACITY ||is_core_idle (cpu); } +static inline bool sched_asym (struct sched_domain *sd,int dst_cpu,int src_cpu) +{ +/* Check if asym balance applicable, then check priorities.*/ +return sched_use_asym_prio (sd, dst_cpu) && +sched_asym_prefer (dst_cpu, src_cpu); +} +/** -* sched_asym - Check if the destination CPU can do asym_packing load balance +* sched_group_asym - Check if the destination CPU can do asym_packing balance * @env: The load balancing environment * @sgs: Load-balancing statistics of the candidate busiest group * @group: The candidate busiest group @@ -9768,22 +9775,18 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu)* otherwise. */ static inline bool -sched_asym (struct lb_env *env,struct sg_lb_stats *sgs,struct sched_group *group) +sched_group_asym (struct lb_env *env,struct sg_lb_stats *sgs,struct sched_group *group) { -/* Ensure that the whole local core is idle, if applicable. */ -if (!sched_use_asym_prio (env->sd, env->dst_cpu)) -return false; -/* -* CPU priorities does not make sense for SMT cores with more than one +* CPU priorities do not make sense for SMT cores with more than one * busy sibling. */ -if (group->flags &SD_SHARE_CPUCAPACITY ) { -if (sgs->group_weight - sgs->idle_cpus !=1 ) -return false; - } -return sched_asym_prefer (env->dst_cpu, group->asym_prefer_cpu); +if ((group->flags &SD_SHARE_CPUCAPACITY ) && + (sgs->group_weight - sgs->idle_cpus !=1 )) +return false; + +return sched_asym (env->sd, env->dst_cpu, group->asym_prefer_cpu); }/* One group has more than one SMT CPU while the other group does not */ @@ -9939,7 +9942,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,/* Check if dst CPU is idle and preferred to this group */ if (!local_group && env->sd->flags &SD_ASYM_PACKING && env->idle !=CPU_NOT_IDLE && sgs->sum_h_nr_running && -sched_asym (env, sgs, group)) { +sched_group_asym (env, sgs, group)) { sgs->group_asym_packing =1 ; }@@ -11038,8 +11041,7 @@ static struct rq *find_busiest_queue(struct lb_env *env,* SMT cores with more than one busy sibling. */ if ((env->sd->flags &SD_ASYM_PACKING ) && -sched_use_asym_prio (env->sd, i) && -sched_asym_prefer (i, env->dst_cpu) && +sched_asym (env->sd, i, env->dst_cpu) && nr_running ==1 )continue ;@@ -11909,8 +11911,7 @@ static void nohz_balancer_kick(struct rq *rq)* preferred CPU must be idle. */ for_each_cpu_and (i,sched_domain_span (sd), nohz.idle_cpus_mask) { -if (sched_use_asym_prio (sd, i) && -sched_asym_prefer (i, cpu)) { +if (sched_asym (sd, i, cpu)) { flags =NOHZ_STATS_KICK |NOHZ_BALANCE_KICK ; goto unlock; }
Quoted 32 lines · Valentin Schneider
Subject nit: the prefix should be sched/topology
Quoted 20 lines · On 01/02/24 19:54, [email protected] wrote:
From: Alex Shi <[email protected]>
The description of
SD_CLUSTERis missing. Add it.Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>--- kernel/sched/topology.c | 1 + 1 file changed, 1 insertion(+)kernel/sched/topology.c +0
-0kernel/sched/topology.c static struct cpumask ***sched_domains_numa_masks; · line 1557
Quoted 4 lines
kernel/sched/topology.c +1
-0@@ -1554,6 +1554,7 @@ static struct cpumask ***sched_domains_numa_masks;* function: * * SD_SHARE_CPUCAPACITY - describes SMT topologies +* SD_CLUSTER - describes CPU Cluster topologies So I know this is the naming we've gone for the "Cluster" naming, but this comment isn't really explaining anything.
Quoted 7 lines
include/linux/sched/sd_flags.hhas a bit more info already:
* Domain members share CPU cluster (LLC tags or L2 cache)I had to go through a bit of git history to remember what the CLUSTER thing was about, how about this:
*
SD_CLUSTER- describes shared shared caches, cache tags or busses
Double "shared", so could we use:
* SD_CLUSTER - describes shared caches, cache tags or busses?
Quoted 6 lines
*
SD_SHARE_PKG_RESOURCES- describes shared LLC cacheAnd looking at this it would make sense to:
renameSD_CLUSTERintoSD_SHARE_PKG_RESOURCES
renameSD_SHARE_PKG_RESOURCESintoSD_SHARE_LLC
but that's another topic...
Uh, naming is a hard things. :)
Thanks
Alex
Quoted 7 lines
Quoted 6 lines
kernel/sched/topology.c +0
-1* SD_SHARE_PKG_RESOURCES - describes shared caches * SD_NUMA - describes NUMA topologies * -- 2.43.0
Re: [PATCH v3 2/4] sched/fair: remove unused parameters
In reply to Valentin SchneiderQuoted 10 lines · Valentin Schneider
Quoted 6 lines · On 01/02/24 19:54, [email protected] wrote:
From: Alex Shi <[email protected]>
sds isn't used in function
sched_asym(), so remove it to cleanup code.Signed-off-by Alex Shi <[email protected]>Reviewed-by Ricardo Neri <[email protected]>AFAICT this is unsused as of:
c9ca07886aaa("sched/fair: Do not even the number of busy CPUs viaasym_packing")
Maybe a Fixes: c9ca07886aaa ("sched/fair: Do not even the number of busy CPUs via asym_packing") is in order?
Re: [PATCH v3 3/4] sched/fair: packing func sched_use_asym_prio()/sched_asym_prefer()
In reply to [email protected]Quoted 1 line · On Thu, Feb 01, 2024 at 07:54:46PM +0800, [email protected] wrote:
From: Alex Shi <[email protected]>
subject:
sched/fair: packing func sched_use_asym_prio()/sched_asym_prefer()
Do not use gerund mood in the subject. Better to say:
sched/fair: Rework sched_use_asym_prio() and sched_asym_prefer()
Quoted 4 lines
Consolidate the functions
sched_use_asym_prio()andsched_asym_prefer()into one. and renamesched_asym()assched_group_asym(). This makes the code easier to read. No functional changes.
Maybe giving more reasons?
sched_use_asym_prio() sched_asym_prefer() are used together in various places. Consolidate them into a single function sched_asym().
The existing sched_group_asym() is only used when collecting statistics of a scheduling group. Rename it as sched_group_asym().
Quoted 16 lines
Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>--- kernel/sched/fair.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)kernel/sched/fair.c +0
-0
kernel/sched/fair.c static bool sched_use_asym_prio(struct sched_domain *sd, int cpu) · line 9752
Quoted 6 lines
kernel/sched/fair.c +3
-0@@ -9747,8 +9747,15 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu)return sd->flags &SD_SHARE_CPUCAPACITY ||is_core_idle (cpu); } +static inline bool sched_asym (struct sched_domain *sd,int dst_cpu,int src_cpu) +{ +/* Check if asym balance applicable, then check priorities.*/
Perhaps the comment can be made more descriptive:
/* * First check if @dst_cpu can do asym_packing load balance. Only do it * if it has higher priority than @src_cpu. */
Quoted 22 lines
kernel/sched/fair.c +6
-6+return sched_use_asym_prio (sd, dst_cpu) && +sched_asym_prefer (dst_cpu, src_cpu); +} +/** -* sched_asym - Check if the destination CPU can do asym_packing load balance +* sched_group_asym - Check if the destination CPU can do asym_packing balance * @env: The load balancing environment * @sgs: Load-balancing statistics of the candidate busiest group * @group: The candidate busiest group @@ -9768,22 +9775,18 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu)* otherwise. */ static inline bool -sched_asym (struct lb_env *env,struct sg_lb_stats *sgs,struct sched_group *group) +sched_group_asym (struct lb_env *env,struct sg_lb_stats *sgs,struct sched_group *group) { -/* Ensure that the whole local core is idle, if applicable. */ -if (!sched_use_asym_prio (env->sd, env->dst_cpu)) -return false; -/*
kernel/sched/fair.c static bool sched_use_asym_prio(struct sched_domain *sd, int cpu) · line 9786
Quoted 10 lines
kernel/sched/fair.c +1
-6-* CPU priorities does not make sense for SMT cores with more than one +* CPU priorities do not make sense for SMT cores with more than one * busy sibling. */ -if (group->flags &SD_SHARE_CPUCAPACITY ) { -if (sgs->group_weight - sgs->idle_cpus !=1 ) -return false; - } -return sched_asym_prefer (env->dst_cpu, group->asym_prefer_cpu);
After applying this patch there is a blank line between the comment and the return statement. Can you remove it?
Quoted 40 lines
kernel/sched/fair.c +8
-5+if ((group->flags &SD_SHARE_CPUCAPACITY ) && + (sgs->group_weight - sgs->idle_cpus !=1 )) +return false; + +return sched_asym (env->sd, env->dst_cpu, group->asym_prefer_cpu); }/* One group has more than one SMT CPU while the other group does not */ @@ -9939,7 +9942,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,/* Check if dst CPU is idle and preferred to this group */ if (!local_group && env->sd->flags &SD_ASYM_PACKING && env->idle !=CPU_NOT_IDLE && sgs->sum_h_nr_running && -sched_asym (env, sgs, group)) { +sched_group_asym (env, sgs, group)) { sgs->group_asym_packing =1 ; }@@ -11038,8 +11041,7 @@ static struct rq *find_busiest_queue(struct lb_env *env,* SMT cores with more than one busy sibling. */ if ((env->sd->flags &SD_ASYM_PACKING ) && -sched_use_asym_prio (env->sd, i) && -sched_asym_prefer (i, env->dst_cpu) && +sched_asym (env->sd, i, env->dst_cpu) && nr_running ==1 )continue ;@@ -11909,8 +11911,7 @@ static void nohz_balancer_kick(struct rq *rq)* preferred CPU must be idle. */ for_each_cpu_and (i,sched_domain_span (sd), nohz.idle_cpus_mask) { -if (sched_use_asym_prio (sd, i) && -sched_asym_prefer (i, cpu)) { +if (sched_asym (sd, i, cpu)) { flags =NOHZ_STATS_KICK |NOHZ_BALANCE_KICK ; goto unlock; }Signature · 1 line
2.43.0
Re: [PATCH v3 4/4] sched/fair: Check the SD_ASYM_PACKING flag in sched_use_asym_prio()
In reply to [email protected]Quoted 6 lines · On Thu, Feb 01, 2024 at 07:54:47PM +0800, [email protected] wrote:
From: Alex Shi <[email protected]>
sched_use_asym_prio()checks whether CPU priorities should be used. It makes sense to check for theSD_ASYM_PACKING()inside the function. Since bothsched_asym()andsched_group_asym()usesched_use_asym_prio(), remove the now superfluous checks for the flag in various places"
s/places"/places./
Quoted 31 lines
Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Ben Segall <[email protected]>
To: Steven Rostedt <[email protected]>
To: Dietmar Eggemann <[email protected]>
To: Valentin Schneider <[email protected]>
To: Daniel Bristot de Oliveira <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>--- kernel/sched/fair.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)kernel/sched/fair.c +3
-0@@ -9741,6 +9741,9 @@ group_type group_classify(unsigned int imbalance_pct,*/ static bool sched_use_asym_prio (struct sched_domain *sd,int cpu) { +if (!(sd->flags &SD_ASYM_PACKING )) +return false; +if (!sched_smt_active ())return true;
kernel/sched/fair.c static inline void update_sg_lb_stats(struct lb_env *env, · line 9947
Quoted 8 lines
kernel/sched/fair.c +2
-3@@ -9940,11 +9943,9 @@ static inline void update_sg_lb_stats(struct lb_env *env, sgs->group_weight = group->group_weight;/* Check if dst CPU is idle and preferred to this group */ -if (!local_group && env->sd->flags &SD_ASYM_PACKING && - env->idle !=CPU_NOT_IDLE && sgs->sum_h_nr_running && -sched_group_asym (env, sgs, group)) { +if (!local_group && env->idle !=CPU_NOT_IDLE && sgs->sum_h_nr_running && +sched_group_asym (env, sgs, group))
You should align sched_group_asym() to !local_group.
Quoted 17 lines
kernel/sched/fair.c +1
-4sgs->group_asym_packing =1 ; - }/* Check for loaded SMT group to be balanced to dst CPU */ if (!local_group &&smt_balance (env, sgs, group))@@ -11040,9 +11041,7 @@ static struct rq *find_busiest_queue(struct lb_env *env,* If balancing between cores, let lower priority CPUs help * SMT cores with more than one busy sibling. */ -if ((env->sd->flags &SD_ASYM_PACKING ) && -sched_asym (env->sd, i, env->dst_cpu) && - nr_running ==1 ) +if (sched_asym (env->sd, i, env->dst_cpu) && nr_running ==1 )continue ;switch (env->migration_type) {
kernel/sched/fair.c asym_active_balance(struct lb_env *env) · line 11142
Quoted 7 lines
kernel/sched/fair.c +1
-1@@ -11138,7 +11137,7 @@ asym_active_balance(struct lb_env *env)* the lower priority @env::dst_cpu help it. Do not follow * CPU priority. */ -return env->idle !=CPU_NOT_IDLE && (env->sd->flags &SD_ASYM_PACKING ) && +return env->idle !=CPU_NOT_IDLE && sched_use_asym_prio(env->sd, env->dst_cpu) && (sched_asym_prefer(env->dst_cpu, env->src_cpu) ||
Perhaps you can rearrange the spaghetti of conditions to make better use of the full 80-column line.
Quoted 32 lines · Valentin Schneider
Subject nit: the prefix should be sched/topology
Quoted 20 lines · On 01/02/24 19:54, [email protected] wrote:
From: Alex Shi <[email protected]>
The description of
SD_CLUSTERis missing. Add it.Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>--- kernel/sched/topology.c | 1 + 1 file changed, 1 insertion(+)kernel/sched/topology.c +0
-0kernel/sched/topology.c static struct cpumask ***sched_domains_numa_masks; · line 1557
Quoted 4 lines
kernel/sched/topology.c +1
-0@@ -1554,6 +1554,7 @@ static struct cpumask ***sched_domains_numa_masks;* function: * * SD_SHARE_CPUCAPACITY - describes SMT topologies +* SD_CLUSTER - describes CPU Cluster topologies So I know this is the naming we've gone for the "Cluster" naming, but this comment isn't really explaining anything.
Quoted 2 lines
include/linux/sched/sd_flags.hhas a bit more info already:
* Domain members share CPU cluster (LLC tags or L2 cache)
I also thought of this, but I didn't want to suggest to repeat in topolog.c what is described in sd_flags.h.
Maybe it is better to remove the descriptions of all flags here and instead direct the reader to sd_flags.h?
Quoted 5 lines
I had to go through a bit of git history to remember what the CLUSTER thing was about, how about this:
*
SD_CLUSTER- describes shared shared caches, cache tags or busses
AFAIK, this describes a subset of CPUs in the package that share a resource, likely L2 cache.
Quoted 4 lines
*
SD_SHARE_PKG_RESOURCES- describes shared LLC cacheAnd looking at this it would make sense to:
renameSD_CLUSTERintoSD_SHARE_PKG_RESOURCES
but not all CPUs in the package share the resource
Quoted 3 lines
rename
SD_SHARE_PKG_RESOURCESintoSD_SHARE_LLC
but that's another topic...
Re: [PATCH v3 4/4] sched/fair: Check the SD_ASYM_PACKING flag in sched_use_asym_prio()
In reply to Ricardo NeriQuoted 43 lines · Ricardo Neri
Quoted 6 lines · On Thu, Feb 01, 2024 at 07:54:47PM +0800, [email protected] wrote:
From: Alex Shi <[email protected]>
sched_use_asym_prio()checks whether CPU priorities should be used. It makes sense to check for theSD_ASYM_PACKING()inside the function. Since bothsched_asym()andsched_group_asym()usesched_use_asym_prio(), remove the now superfluous checks for the flag in various places"s/places"/places./
Quoted 33 lines
Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Ben Segall <[email protected]>
To: Steven Rostedt <[email protected]>
To: Dietmar Eggemann <[email protected]>
To: Valentin Schneider <[email protected]>
To: Daniel Bristot de Oliveira <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>--- kernel/sched/fair.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)kernel/sched/fair.c +3
-0@@ -9741,6 +9741,9 @@ group_type group_classify(unsigned int imbalance_pct,*/ static bool sched_use_asym_prio (struct sched_domain *sd,int cpu) { +if (!(sd->flags &SD_ASYM_PACKING )) +return false; +if (!sched_smt_active ())return true;@@ -9940,11 +9943,9 @@ static inline void update_sg_lb_stats(struct lb_env *env, sgs->group_weight = group->group_weight;
Quoted 8 lines
kernel/sched/fair.c static inline void update_sg_lb_stats(struct lb_env *env, · line 9947
Quoted 6 lines
kernel/sched/fair.c +2
-3/* Check if dst CPU is idle and preferred to this group */ -if (!local_group && env->sd->flags &SD_ASYM_PACKING && - env->idle !=CPU_NOT_IDLE && sgs->sum_h_nr_running && -sched_group_asym (env, sgs, group)) { +if (!local_group && env->idle !=CPU_NOT_IDLE && sgs->sum_h_nr_running && +sched_group_asym (env, sgs, group))You should align
sched_group_asym()to !local_group.
Thanks for all suggestion. I will take them in next version.
Quoted 16 lines
Quoted 16 lines
kernel/sched/fair.c +1
-4sgs->group_asym_packing =1 ; - }/* Check for loaded SMT group to be balanced to dst CPU */ if (!local_group &&smt_balance (env, sgs, group))@@ -11040,9 +11041,7 @@ static struct rq *find_busiest_queue(struct lb_env *env,* If balancing between cores, let lower priority CPUs help * SMT cores with more than one busy sibling. */ -if ((env->sd->flags &SD_ASYM_PACKING ) && -sched_asym (env->sd, i, env->dst_cpu) && - nr_running ==1 ) +if (sched_asym (env->sd, i, env->dst_cpu) && nr_running ==1 )continue ;
Quoted 12 lines
kernel/sched/fair.c asym_active_balance(struct lb_env *env) · line 11142
Quoted 9 lines
kernel/sched/fair.c +1
-1switch (env->migration_type) {@@ -11138,7 +11137,7 @@ asym_active_balance(struct lb_env *env)* the lower priority @env::dst_cpu help it. Do not follow * CPU priority. */ -return env->idle !=CPU_NOT_IDLE && (env->sd->flags &SD_ASYM_PACKING ) && +return env->idle !=CPU_NOT_IDLE && sched_use_asym_prio(env->sd, env->dst_cpu) && (sched_asym_prefer(env->dst_cpu, env->src_cpu) ||Perhaps you can rearrange the spaghetti of conditions to make better use of the full 80-column line.
80-column doesn't work here, will try 100 column.
Thanks
Alex
Quoted 32 lines · Valentin Schneider
Subject nit: the prefix should be sched/topology
Quoted 20 lines · On 01/02/24 19:54, [email protected] wrote:
From: Alex Shi <[email protected]>
The description of
SD_CLUSTERis missing. Add it.Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>--- kernel/sched/topology.c | 1 + 1 file changed, 1 insertion(+)kernel/sched/topology.c +0
-0kernel/sched/topology.c static struct cpumask ***sched_domains_numa_masks; · line 1557
Quoted 4 lines
kernel/sched/topology.c +1
-0@@ -1554,6 +1554,7 @@ static struct cpumask ***sched_domains_numa_masks;* function: * * SD_SHARE_CPUCAPACITY - describes SMT topologies +* SD_CLUSTER - describes CPU Cluster topologies So I know this is the naming we've gone for the "Cluster" naming, but this comment isn't really explaining anything.
Quoted 3 lines
include/linux/sched/sd_flags.hhas a bit more info already:
* Domain members share CPU cluster (LLC tags or L2 cache)
Cluster topology in scheduler should mean CPUs beyond the SMT which are sharing some cache resources (currently L2 on some Intel platforms or L3 Tag on our platforms) but not the LLC.
A drawing in c5e22feffdd7 ("topology: Represent clusters of CPUs within a die") has a good illustration and comment of cpus_share_resources() also illustrate this a bit:
/*
* Whether CPUs are share cache resources, which means LLC on non-cluster
* machines and LLC tag or L2 on machines with clusters.
*/
bool cpus_share_resources(int this_cpu, int that_cpu)
Quoted 20 lines
I had to go through a bit of git history to remember what the CLUSTER thing was about, how about this:
*
SD_CLUSTER- describes shared shared caches, cache tags or busses
*SD_SHARE_PKG_RESOURCES- describes shared LLC cacheAnd looking at this it would make sense to:
renameSD_CLUSTERintoSD_SHARE_PKG_RESOURCES
renameSD_SHARE_PKG_RESOURCESintoSD_SHARE_LLC
but that's another topic...Quoted 5 lines
kernel/sched/topology.c +0
-1* SD_SHARE_PKG_RESOURCES - describes shared caches * SD_NUMA - describes NUMA topologies * -- 2.43.0
.
Quoted 33 lines · Ricardo Neri
Quoted 32 lines · Valentin Schneider
Subject nit: the prefix should be sched/topology
Quoted 20 lines · On 01/02/24 19:54, [email protected] wrote:
From: Alex Shi <[email protected]>
The description of
SD_CLUSTERis missing. Add it.Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>--- kernel/sched/topology.c | 1 + 1 file changed, 1 insertion(+)kernel/sched/topology.c +0
-0kernel/sched/topology.c static struct cpumask ***sched_domains_numa_masks; · line 1557
Quoted 4 lines
kernel/sched/topology.c +1
-0@@ -1554,6 +1554,7 @@ static struct cpumask ***sched_domains_numa_masks;* function: * * SD_SHARE_CPUCAPACITY - describes SMT topologies +* SD_CLUSTER - describes CPU Cluster topologies So I know this is the naming we've gone for the "Cluster" naming, but this comment isn't really explaining anything.
Quoted 8 lines
Quoted 2 lines
include/linux/sched/sd_flags.hhas a bit more info already:
* Domain members share CPU cluster (LLC tags or L2 cache)I also thought of this, but I didn't want to suggest to repeat in
topolog.cwhat is described insd_flags.h.Maybe it is better to remove the descriptions of all flags here and instead direct the reader to
sd_flags.h?
yes, good idea for getting their meaning directly from the header file. So is it fine for next sending?
sched/fair: remove duplicate comments for SD_ flags
Originally, it missed SD_CLUSTER flag description, but comparing to copy the flags meaning from sd_flags.h, reader is better to get info from there.
Keep SD_ASYM_PACKING unchange for a point from another way.
To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>
kernel/sched/topology.c +1 -5
@@ -1551,11 +1551,7 @@ static struct cpumask ***sched_domains_numa_masks;* * These flags are purely descriptive of the topology and do not prescribe * behaviour. Behaviour is artificial and mapped in the below sd_init() -* function: -* -* SD_SHARE_CPUCAPACITY - describes SMT topologies -* SD_SHARE_PKG_RESOURCES - describes shared caches -* SD_NUMA - describes NUMA topologies +* function, for details in include/linux/sched/sd_flags.h: * * Odd one out, which beside describing the topology has a quirk also * prescribes the desired behaviour that goes along with it:
Quoted 20 lines
Quoted 6 lines
I had to go through a bit of git history to remember what the CLUSTER thing was about, how about this:
*
SD_CLUSTER- describes shared shared caches, cache tags or bussesAFAIK, this describes a subset of CPUs in the package that share a resource, likely L2 cache.
Quoted 4 lines
*
SD_SHARE_PKG_RESOURCES- describes shared LLC cacheAnd looking at this it would make sense to:
renameSD_CLUSTERintoSD_SHARE_PKG_RESOURCESbut not all CPUs in the package share the resource
Quoted 3 lines
rename
SD_SHARE_PKG_RESOURCESintoSD_SHARE_LLC
but that's another topic...
Valentin Schneider
reviewerQuoted 33 lines · Ricardo Neri
Quoted 32 lines · Valentin Schneider
Subject nit: the prefix should be sched/topology
Quoted 20 lines · On 01/02/24 19:54, [email protected] wrote:
From: Alex Shi <[email protected]>
The description of
SD_CLUSTERis missing. Add it.Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>--- kernel/sched/topology.c | 1 + 1 file changed, 1 insertion(+)kernel/sched/topology.c +0
-0kernel/sched/topology.c static struct cpumask ***sched_domains_numa_masks; · line 1557
Quoted 4 lines
kernel/sched/topology.c +1
-0@@ -1554,6 +1554,7 @@ static struct cpumask ***sched_domains_numa_masks;* function: * * SD_SHARE_CPUCAPACITY - describes SMT topologies +* SD_CLUSTER - describes CPU Cluster topologies So I know this is the naming we've gone for the "Cluster" naming, but this comment isn't really explaining anything.
Quoted 9 lines
Quoted 2 lines
include/linux/sched/sd_flags.hhas a bit more info already:
* Domain members share CPU cluster (LLC tags or L2 cache)I also thought of this, but I didn't want to suggest to repeat in
topolog.cwhat is described insd_flags.h.Maybe it is better to remove the descriptions of all flags here and instead direct the reader to
sd_flags.h?
Yeah I agree on less duplication.
Quoted 9 lines
Quoted 5 lines
I had to go through a bit of git history to remember what the CLUSTER thing was about, how about this:
*
SD_CLUSTER- describes shared shared caches, cache tags or bussesAFAIK, this describes a subset of CPUs in the package that share a resource, likely L2 cache.
Quoted 6 lines
Quoted 4 lines
*
SD_SHARE_PKG_RESOURCES- describes shared LLC cacheAnd looking at this it would make sense to:
renameSD_CLUSTERintoSD_SHARE_PKG_RESOURCESbut not all CPUs in the package share the resource
But SD_CLUSTER never expands beyond the package, right?
Regardless, my main point is that having both SD_CLUSTER and SD_SHARE_PKG_RESOURCES is a source of confusion (at the very least for myself), and given SD_SHARE_PKG_RESOURCES is really used to mean "shares LLC" (see update_top_cache_domain()), we could make that flag more explicit and lift some ambiguity with SD_CLUSTER.
Quoted 4 lines
Quoted 4 lines
rename
SD_SHARE_PKG_RESOURCESintoSD_SHARE_LLC
but that's another topic...
Quoted 39 lines · kuiliang Shi
Quoted 36 lines · Ricardo Neri
Quoted 34 lines · Valentin Schneider
Subject nit: the prefix should be sched/topology
Quoted 20 lines · On 01/02/24 19:54, [email protected] wrote:
From: Alex Shi <[email protected]>
The description of
SD_CLUSTERis missing. Add it.Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>--- kernel/sched/topology.c | 1 + 1 file changed, 1 insertion(+)kernel/sched/topology.c +0
-0kernel/sched/topology.c static struct cpumask ***sched_domains_numa_masks; · line 1557
Quoted 4 lines
kernel/sched/topology.c +1
-0@@ -1554,6 +1554,7 @@ static struct cpumask ***sched_domains_numa_masks;* function: * * SD_SHARE_CPUCAPACITY - describes SMT topologies +* SD_CLUSTER - describes CPU Cluster topologies So I know this is the naming we've gone for the "Cluster" naming, but this comment isn't really explaining anything.
include/linux/sched/sd_flags.hhas a bit more info already:
* Domain members share CPU cluster (LLC tags or L2 cache)
Quoted 8 lines
Quoted 5 lines
I also thought of this, but I didn't want to suggest to repeat in
topolog.cwhat is described insd_flags.h.Maybe it is better to remove the descriptions of all flags here and instead direct the reader to
sd_flags.h?yes, good idea for getting their meaning directly from the header file. So is it fine for next sending?
Some tweaks below.
Quoted 2 lines
sched/fair: remove duplicate comments for
SD_flags
sched/topology: Remove duplicate descriptions from TOPOLOGY_SD_FLAGS
Quoted 4 lines
Originally, it missed
SD_CLUSTERflag description, but comparing to copy the flags meaning fromsd_flags.h, reader is better to get info from there.
These flags are already documented in include/linux/sched/sd_flags.h.
Keep the comment on SD_ASYM_PACKING as it is a special case.
Quoted 16 lines
Keep
SD_ASYM_PACKINGunchange for a point from another way.Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>kernel/sched/topology.c +0
-0
kernel/sched/topology.c static struct cpumask ***sched_domains_numa_masks; · line 1558
Quoted 8 lines
kernel/sched/topology.c +0
-5@@ -1551,11 +1551,7 @@ static struct cpumask ***sched_domains_numa_masks;* * These flags are purely descriptive of the topology and do not prescribe * behaviour. Behaviour is artificial and mapped in the below sd_init() -* function: -* -* SD_SHARE_CPUCAPACITY - describes SMT topologies -* SD_SHARE_PKG_RESOURCES - describes shared caches -* SD_NUMA - describes NUMA topologies
Maybe only remove the descriptions but keep the enumeration?
kernel/sched/topology.c static struct cpumask ***sched_domains_numa_masks; · line 1554
Quoted 1 line
kernel/sched/topology.c +1
-0+* function, for details in include/linux/sched/sd_flags.h:
function. For details, see include/linux/sched/sd_flags.h.
Quoted 55 lines · Valentin Schneider
Quoted 33 lines · Ricardo Neri
Quoted 32 lines · Valentin Schneider
Subject nit: the prefix should be sched/topology
Quoted 20 lines · On 01/02/24 19:54, [email protected] wrote:
From: Alex Shi <[email protected]>
The description of
SD_CLUSTERis missing. Add it.Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>--- kernel/sched/topology.c | 1 + 1 file changed, 1 insertion(+)kernel/sched/topology.c +0
-0kernel/sched/topology.c static struct cpumask ***sched_domains_numa_masks; · line 1557
Quoted 4 lines
kernel/sched/topology.c +1
-0@@ -1554,6 +1554,7 @@ static struct cpumask ***sched_domains_numa_masks;* function: * * SD_SHARE_CPUCAPACITY - describes SMT topologies +* SD_CLUSTER - describes CPU Cluster topologies So I know this is the naming we've gone for the "Cluster" naming, but this comment isn't really explaining anything.
Quoted 9 lines
Quoted 2 lines
include/linux/sched/sd_flags.hhas a bit more info already:
* Domain members share CPU cluster (LLC tags or L2 cache)I also thought of this, but I didn't want to suggest to repeat in
topolog.cwhat is described insd_flags.h.Maybe it is better to remove the descriptions of all flags here and instead direct the reader to
sd_flags.h?Yeah I agree on less duplication.
Quoted 9 lines
Quoted 5 lines
I had to go through a bit of git history to remember what the CLUSTER thing was about, how about this:
*
SD_CLUSTER- describes shared shared caches, cache tags or bussesAFAIK, this describes a subset of CPUs in the package that share a resource, likely L2 cache.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
*
SD_SHARE_PKG_RESOURCES- describes shared LLC cacheAnd looking at this it would make sense to:
renameSD_CLUSTERintoSD_SHARE_PKG_RESOURCESbut not all CPUs in the package share the resource
But
SD_CLUSTERnever expands beyond the package, right?
Correct.
Quoted 4 lines
Regardless, my main point is that having both
SD_CLUSTERandSD_SHARE_PKG_RESOURCESis a source of confusion (at the very least for myself),
Agreed!
Quoted 3 lines
and given
SD_SHARE_PKG_RESOURCESis really used to mean "shares LLC" (seeupdate_top_cache_domain()), we could make that flag more explicit and lift some ambiguity withSD_CLUSTER.
As Yicong stated, cluster topology should mean CPUs beyond SMT that share some resource but not LLC.
It makes sense to me to keep SD_CLUSTER name as it is today and rename SD_SHARE_PKG_RESOURCES as SD_SHARE_LLC.
Quoted 78 lines · Ricardo Neri
Quoted 55 lines · Valentin Schneider
Quoted 33 lines · Ricardo Neri
Quoted 32 lines · Valentin Schneider
Subject nit: the prefix should be sched/topology
Quoted 20 lines · On 01/02/24 19:54, [email protected] wrote:
From: Alex Shi <[email protected]>
The description of
SD_CLUSTERis missing. Add it.Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>--- kernel/sched/topology.c | 1 + 1 file changed, 1 insertion(+)kernel/sched/topology.c +0
-0kernel/sched/topology.c static struct cpumask ***sched_domains_numa_masks; · line 1557
Quoted 4 lines
kernel/sched/topology.c +1
-0@@ -1554,6 +1554,7 @@ static struct cpumask ***sched_domains_numa_masks;* function: * * SD_SHARE_CPUCAPACITY - describes SMT topologies +* SD_CLUSTER - describes CPU Cluster topologies So I know this is the naming we've gone for the "Cluster" naming, but this comment isn't really explaining anything.
Quoted 9 lines
Quoted 2 lines
include/linux/sched/sd_flags.hhas a bit more info already:
* Domain members share CPU cluster (LLC tags or L2 cache)I also thought of this, but I didn't want to suggest to repeat in
topolog.cwhat is described insd_flags.h.Maybe it is better to remove the descriptions of all flags here and instead direct the reader to
sd_flags.h?Yeah I agree on less duplication.
Quoted 9 lines
Quoted 5 lines
I had to go through a bit of git history to remember what the CLUSTER thing was about, how about this:
*
SD_CLUSTER- describes shared shared caches, cache tags or bussesAFAIK, this describes a subset of CPUs in the package that share a resource, likely L2 cache.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
*
SD_SHARE_PKG_RESOURCES- describes shared LLC cacheAnd looking at this it would make sense to:
renameSD_CLUSTERintoSD_SHARE_PKG_RESOURCESbut not all CPUs in the package share the resource
But
SD_CLUSTERnever expands beyond the package, right?Correct.
Quoted 4 lines
Regardless, my main point is that having both
SD_CLUSTERandSD_SHARE_PKG_RESOURCESis a source of confusion (at the very least for myself),Agreed!
Quoted 3 lines
and given
SD_SHARE_PKG_RESOURCESis really used to mean "shares LLC" (seeupdate_top_cache_domain()), we could make that flag more explicit and lift some ambiguity withSD_CLUSTER.
Quoted 5 lines
As Yicong stated, cluster topology should mean CPUs beyond SMT that share some resource but not LLC.
It makes sense to me to keep
SD_CLUSTERname as it is today and renameSD_SHARE_PKG_RESOURCESasSD_SHARE_LLC.
yes, agree with his.
Quoted 90 lines · Ricardo Neri
Quoted 39 lines · kuiliang Shi
Quoted 36 lines · Ricardo Neri
Quoted 34 lines · Valentin Schneider
Subject nit: the prefix should be sched/topology
Quoted 20 lines · On 01/02/24 19:54, [email protected] wrote:
From: Alex Shi <[email protected]>
The description of
SD_CLUSTERis missing. Add it.Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>--- kernel/sched/topology.c | 1 + 1 file changed, 1 insertion(+)kernel/sched/topology.c +0
-0kernel/sched/topology.c static struct cpumask ***sched_domains_numa_masks; · line 1557
Quoted 4 lines
kernel/sched/topology.c +1
-0@@ -1554,6 +1554,7 @@ static struct cpumask ***sched_domains_numa_masks;* function: * * SD_SHARE_CPUCAPACITY - describes SMT topologies +* SD_CLUSTER - describes CPU Cluster topologies So I know this is the naming we've gone for the "Cluster" naming, but this comment isn't really explaining anything.
include/linux/sched/sd_flags.hhas a bit more info already:
* Domain members share CPU cluster (LLC tags or L2 cache)Quoted 8 lines
Quoted 5 lines
I also thought of this, but I didn't want to suggest to repeat in
topolog.cwhat is described insd_flags.h.Maybe it is better to remove the descriptions of all flags here and instead direct the reader to
sd_flags.h?yes, good idea for getting their meaning directly from the header file. So is it fine for next sending?
Some tweaks below.
Quoted 2 lines
sched/fair: remove duplicate comments for
SD_flagssched/topology: Remove duplicate descriptions from
TOPOLOGY_SD_FLAGSQuoted 4 lines
Originally, it missed
SD_CLUSTERflag description, but comparing to copy the flags meaning fromsd_flags.h, reader is better to get info from there.These flags are already documented in
include/linux/sched/sd_flags.h.Keep the comment on
SD_ASYM_PACKINGas it is a special case.Quoted 16 lines
Keep
SD_ASYM_PACKINGunchange for a point from another way.Signed-off-by Alex Shi <[email protected]>To: Ricardo Neri <[email protected]>
To: Valentin Schneider <[email protected]>
To: Vincent Guittot <[email protected]>
To: Juri Lelli <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Ingo Molnar <[email protected]>kernel/sched/topology.c +0
-0kernel/sched/topology.c static struct cpumask ***sched_domains_numa_masks; · line 1558
Quoted 8 lines
kernel/sched/topology.c +0
-5@@ -1551,11 +1551,7 @@ static struct cpumask ***sched_domains_numa_masks;* * These flags are purely descriptive of the topology and do not prescribe * behaviour. Behaviour is artificial and mapped in the below sd_init() -* function: -* -* SD_SHARE_CPUCAPACITY - describes SMT topologies -* SD_SHARE_PKG_RESOURCES - describes shared caches -* SD_NUMA - describes NUMA topologies Maybe only remove the descriptions but keep the enumeration?
Quoted 4 lines
kernel/sched/topology.c static struct cpumask ***sched_domains_numa_masks; · line 1554
Quoted 1 line
kernel/sched/topology.c +1
-0+* function, for details in include/linux/sched/sd_flags.h: function. For details, see
include/linux/sched/sd_flags.h.
Thanks for comments. will update in next version.