From: Peter Zijlstra <peterz@infradead.org>
To: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Ricardo Neri <ricardo.neri@intel.com>,
"Ravi V . Shankar" <ravi.v.shankar@intel.com>,
Ben Segall <bsegall@google.com>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Len Brown <len.brown@intel.com>, Mel Gorman <mgorman@suse.de>,
"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Steven Rostedt <rostedt@goodmis.org>,
Valentin Schneider <vschneid@redhat.com>,
Ionela Voinescu <ionela.voinescu@arm.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
Shrikanth Hegde <sshegde@linux.vnet.ibm.com>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
naveen.n.rao@linux.vnet.ibm.com,
Yicong Yang <yangyicong@hisilicon.com>,
Barry Song <v-songbaohua@oppo.com>,
Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Subject: Re: [PATCH 2/6] sched/fair: Check whether active load balance is needed in busiest group
Date: Fri, 5 May 2023 14:16:31 +0200 [thread overview]
Message-ID: <20230505121631.GF4253@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <231cf298efb8627499bb42788588a6108c7b8f7c.1683156492.git.tim.c.chen@linux.intel.com>
On Thu, May 04, 2023 at 09:09:52AM -0700, Tim Chen wrote:
> From: Tim C Chen <tim.c.chen@linux.intel.com>
>
> In the busiest group, we need to consider whether active load balance
> to a local group is needed even when it is not overloaded. For example,
> when the busiest group is a SMT group that's fully busy and the destination group
> is a cluster group with idle CPU. Such condition is considered by
> asym_active_balance() in load balancing but not when looking for busiest
> group and load imbalance. Add this consideration in find_busiest_group()
> and calculate_imbalance().
>
> Reviewed-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
> Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
> ---
> kernel/sched/fair.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 87317634fab2..bde962aa160a 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9433,6 +9433,17 @@ static inline void update_sg_lb_stats(struct lb_env *env,
> sgs->group_capacity;
> }
>
> +/* One group is SMT while the other group is not */
> +static inline bool asymmetric_groups(struct sched_group *sg1,
> + struct sched_group *sg2)
> +{
> + if (!sg1 || !sg2)
> + return false;
> +
> + return (sg1->flags & SD_SHARE_CPUCAPACITY) !=
> + (sg2->flags & SD_SHARE_CPUCAPACITY);
> +}
> +
> /**
> * update_sd_pick_busiest - return 1 on busiest group
> * @env: The load balancing environment.
> @@ -10079,6 +10090,31 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd
> update_idle_cpu_scan(env, sum_util);
> }
>
> +static inline bool asym_active_balance_busiest(struct lb_env *env, struct sd_lb_stats *sds)
> +{
> + /*
> + * Don't balance to a group without spare capacity.
> + *
> + * Skip non asymmetric sched group balancing. That check
> + * is handled by code path handling imbalanced load between
> + * similar groups.
> + */
> + if (env->idle == CPU_NOT_IDLE ||
> + sds->local_stat.group_type != group_has_spare ||
> + !asymmetric_groups(sds->local, sds->busiest))
> + return false;
> +
> + /*
> + * For SMT source group, pull when there are two or more
> + * tasks over-utilizing a core.
> + */
> + if (sds->busiest->flags & SD_SHARE_CPUCAPACITY &&
> + sds->busiest_stat.sum_h_nr_running > 1)
> + return true;
> +
> + return false;
> +}
This all seems to be mixing two 'asymmetric' things in the 'asym'
namespace :/ One being the SD_ASYM_PACKING and then the above SMT/no-SMT
core thing.
> +
> /**
> * calculate_imbalance - Calculate the amount of imbalance present within the
> * groups of a given sched_domain during load balance.
> @@ -10164,6 +10200,12 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
> return;
> }
>
> + if (asym_active_balance_busiest(env, sds)) {
> + env->migration_type = migrate_task;
> + env->imbalance = 1;
> + return;
> + }
> +
> if (busiest->group_weight == 1 || sds->prefer_sibling) {
> unsigned int nr_diff = busiest->sum_nr_running;
> /*
> @@ -10371,6 +10413,9 @@ static struct sched_group *find_busiest_group(struct lb_env *env)
> */
> goto out_balanced;
>
> + if (asym_active_balance_busiest(env, &sds))
> + goto force_balance;
> +
> if (busiest->group_weight > 1 &&
> local->idle_cpus <= (busiest->idle_cpus + 1))
> /*
All the cases here have a nice (CodingStyle busting) comment, perhaps
add the missing {} when hou add the comment?
next prev parent reply other threads:[~2023-05-05 12:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-04 16:09 [PATCH 0/6] Enable Cluster Scheduling for x86 Hybrid CPUs Tim Chen
2023-05-04 16:09 ` [PATCH 1/6] sched/topology: Propagate SMT flags when removing degenerate domain Tim Chen
2023-05-04 16:09 ` [PATCH 2/6] sched/fair: Check whether active load balance is needed in busiest group Tim Chen
2023-05-05 12:16 ` Peter Zijlstra [this message]
2023-05-05 22:29 ` Tim Chen
2023-05-05 23:44 ` Peter Zijlstra
2023-05-09 13:31 ` Vincent Guittot
2023-05-04 16:09 ` [PATCH 3/6] sched/fair: Fix busiest group selection for asym groups Tim Chen
2023-05-05 13:19 ` Peter Zijlstra
2023-05-05 22:36 ` Tim Chen
2023-05-04 16:09 ` [PATCH 4/6] sched/fair: Skip prefer sibling move between SMT group and non-SMT group Tim Chen
2023-05-05 13:22 ` Peter Zijlstra
2023-05-05 23:07 ` Tim Chen
2023-05-05 23:38 ` Peter Zijlstra
2023-05-06 0:08 ` Peter Zijlstra
2023-05-09 13:36 ` Vincent Guittot
2023-05-09 23:35 ` Tim Chen
2023-05-04 16:09 ` [PATCH 5/6] sched/fair: Consider the idle state of the whole core for load balance Tim Chen
2023-05-05 13:23 ` Peter Zijlstra
2023-05-05 22:51 ` Tim Chen
2023-05-04 16:09 ` [PATCH 6/6] sched/x86: Add cluster topology to hybrid CPU Tim Chen
[not found] ` <20230505071735.4083-1-hdanton@sina.com>
2023-05-05 22:49 ` [PATCH 5/6] sched/fair: Consider the idle state of the whole core for load balance Tim Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230505121631.GF4253@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=ionela.voinescu@arm.com \
--cc=juri.lelli@redhat.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=naveen.n.rao@linux.vnet.ibm.com \
--cc=rafael.j.wysocki@intel.com \
--cc=ravi.v.shankar@intel.com \
--cc=ricardo.neri-calderon@linux.intel.com \
--cc=ricardo.neri@intel.com \
--cc=rostedt@goodmis.org \
--cc=srikar@linux.vnet.ibm.com \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=sshegde@linux.vnet.ibm.com \
--cc=tim.c.chen@linux.intel.com \
--cc=v-songbaohua@oppo.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=x86@kernel.org \
--cc=yangyicong@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox