2024-01-30 13:18:48

by alexs

[permalink] [raw]
Subject: [PATCH v2 1/6] sched/fair: add SD_CLUSTER in comments

From: Alex Shi <[email protected]>

The SD_CLUSTER omitted in following TOPOLOGY_SD_FLAGS explaination, add
it to fill the absent.

Signed-off-by: Alex Shi <[email protected]>
To: [email protected]
To: Daniel Bristot de Oliveira <[email protected]>
To: Ben Segall <[email protected]>
To: Steven Rostedt <[email protected]>
To: Dietmar Eggemann <[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(+)

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 10d1391e7416..c342c52b1f34 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -1554,6 +1554,7 @@ static struct cpumask ***sched_domains_numa_masks;
* function:
*
* SD_SHARE_CPUCAPACITY - describes SMT topologies
+ * SD_CLUSTER - describes Cluster topologies
* SD_SHARE_PKG_RESOURCES - describes shared caches
* SD_NUMA - describes NUMA topologies
*
--
2.43.0



2024-01-30 13:19:00

by alexs

[permalink] [raw]
Subject: [PATCH v2 2/6] sched/fair: remove unused parameters

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]>
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(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 46ba8329b10a..8d70417f5125 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -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


2024-01-30 13:56:23

by alexs

[permalink] [raw]
Subject: [PATCH v2 5/6] sched/fair: pack SD_ASYM_PACKING into sched_use_asym_prio

From: Alex Shi <[email protected]>

Then the flags check passed into sched_asym and sched_group_asym.
It's a code cleanup, no func changes.

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(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 835dbe77b260..6680cb39c787 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -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;
+
return (!sched_smt_active()) ||
(sd->flags & SD_SHARE_CPUCAPACITY) || is_core_idle(cpu);
}
@@ -9935,11 +9938,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))
@@ -11035,9 +11036,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) {
@@ -11133,7 +11132,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));
--
2.43.0


2024-02-01 03:19:34

by Ricardo Neri

[permalink] [raw]
Subject: Re: [PATCH v2 1/6] sched/fair: add SD_CLUSTER in comments

On Tue, Jan 30, 2024 at 09:17:03PM +0800, [email protected] wrote:
> From: Alex Shi <[email protected]>
>
> The SD_CLUSTER omitted in following TOPOLOGY_SD_FLAGS explaination, add
> it to fill the absent.

Perhaps saying: "The description of SD_CLUSTER is missing. Add it." is
sufficient.

>
> Signed-off-by: Alex Shi <[email protected]>
> To: [email protected]
> To: Daniel Bristot de Oliveira <[email protected]>
> To: Ben Segall <[email protected]>
> To: Steven Rostedt <[email protected]>
> To: Dietmar Eggemann <[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(+)
>
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 10d1391e7416..c342c52b1f34 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -1554,6 +1554,7 @@ static struct cpumask ***sched_domains_numa_masks;
> * function:
> *
> * SD_SHARE_CPUCAPACITY - describes SMT topologies
> + * SD_CLUSTER - describes Cluster topologies

This description does not really add much. Perhaps syaing "describes
CPU cluster topologies". Then users can go to the definiton of
SD_CLUSTER.

2024-02-01 05:40:18

by Ricardo Neri

[permalink] [raw]
Subject: Re: [PATCH v2 5/6] sched/fair: pack SD_ASYM_PACKING into sched_use_asym_prio

On Tue, Jan 30, 2024 at 09:17:07PM +0800, [email protected] wrote:
> From: Alex Shi <[email protected]>
pack SD_ASYM_PACKING into sched_use_asym_prio

Instead of saying `pack` you could say "Check the SD_ASYM_PACKING flag
in sched_use_asym_prio()"

>
> Then the flags check passed into sched_asym and sched_group_asym.
> It's a code cleanup, no func changes.

I'd the changelog as follows:

"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"

2024-02-01 08:45:49

by Alex Shi

[permalink] [raw]
Subject: Re: [PATCH v2 5/6] sched/fair: pack SD_ASYM_PACKING into sched_use_asym_prio



On 2/1/24 8:55 AM, Ricardo Neri wrote:
> On Tue, Jan 30, 2024 at 09:17:07PM +0800, [email protected] wrote:
>> From: Alex Shi <[email protected]>
> pack SD_ASYM_PACKING into sched_use_asym_prio
>
> Instead of saying `pack` you could say "Check the SD_ASYM_PACKING flag
> in sched_use_asym_prio()"
>
>>
>> Then the flags check passed into sched_asym and sched_group_asym.
>> It's a code cleanup, no func changes.
>
> I'd the changelog as follows:
>
> "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"

Thanks a lot for all comments for this series patches, will take your versions in all commits' logs.

Thanks!
Alex

2024-02-01 08:59:17

by Shrikanth Hegde

[permalink] [raw]
Subject: Re: [PATCH v2 1/6] sched/fair: add SD_CLUSTER in comments



On 1/30/24 6:47 PM, [email protected] wrote:
> From: Alex Shi <[email protected]>
>
> The SD_CLUSTER omitted in following TOPOLOGY_SD_FLAGS explaination, add
> it to fill the absent.
>
> Signed-off-by: Alex Shi <[email protected]>
> To: [email protected]
> To: Daniel Bristot de Oliveira <[email protected]>
> To: Ben Segall <[email protected]>
> To: Steven Rostedt <[email protected]>
> To: Dietmar Eggemann <[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(+)
>
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 10d1391e7416..c342c52b1f34 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -1554,6 +1554,7 @@ static struct cpumask ***sched_domains_numa_masks;
> * function:
> *
> * SD_SHARE_CPUCAPACITY - describes SMT topologies
> + * SD_CLUSTER - describes Cluster topologies

nit: would be better if - aligns. Some additional text in between.

> * SD_SHARE_PKG_RESOURCES - describes shared caches
> * SD_NUMA - describes NUMA topologies
> *


On Patch 3/6 and 6/6 agree with Ricardo. It is more difficult to understand
when it is compressed. Some future change in this function would make it more
difficult.