[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220121050233.8708-1-quic_ctheegal@quicinc.com>
Date: Fri, 21 Jan 2022 10:32:33 +0530
From: Chitti Babu Theegala <quic_ctheegal@...cinc.com>
To: <mingo@...hat.com>, <peterz@...radead.org>,
<juri.lelli@...hat.com>, <vincent.guittot@...aro.org>,
<dietmar.eggemann@....com>, <rostedt@...dmis.org>,
<joel@...lfernandes.org>
CC: <linux-arm-msm@...r.kernel.org>, <quic_lingutla@...cinc.com>,
<linux-kernel@...r.kernel.org>, <quic_rjendra@...cinc.com>,
<vincent.donnefort@....com>,
Chitti Babu Theegala <quic_ctheegal@...cinc.com>
Subject: [PATCH v2] sched/fair: Prefer small idle cores for forkees
Newly forked threads don't have any useful utilization data yet and
it's not possible to forecast their impact on energy consumption.
These forkees (though very small, most times) end up waking big
cores from deep sleep for that very small durations.
Bias all forkees to small cores to prevent waking big cores from deep
sleep to save power.
Signed-off-by: Chitti Babu Theegala <quic_ctheegal@...cinc.com>
---
Changes in v2:
1. Enclosed the EAS check for this small core preferring logic
---
kernel/sched/fair.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index c6046446c50b3..72f9ea7c98c05 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5872,7 +5872,7 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p,
}
static struct sched_group *
-find_idlest_group(struct sched_domain *sd, struct task_struct *p, int this_cpu);
+find_idlest_group(struct sched_domain *sd, struct task_struct *p, int this_cpu, int sd_flag);
/*
* find_idlest_group_cpu - find the idlest CPU among the CPUs in the group.
@@ -5959,7 +5959,7 @@ static inline int find_idlest_cpu(struct sched_domain *sd, struct task_struct *p
continue;
}
- group = find_idlest_group(sd, p, cpu);
+ group = find_idlest_group(sd, p, cpu, sd_flag);
if (!group) {
sd = sd->child;
continue;
@@ -8885,7 +8885,8 @@ static inline void update_sg_wakeup_stats(struct sched_domain *sd,
static bool update_pick_idlest(struct sched_group *idlest,
struct sg_lb_stats *idlest_sgs,
struct sched_group *group,
- struct sg_lb_stats *sgs)
+ struct sg_lb_stats *sgs,
+ int sd_flag)
{
if (sgs->group_type < idlest_sgs->group_type)
return true;
@@ -8922,6 +8923,13 @@ static bool update_pick_idlest(struct sched_group *idlest,
if (idlest_sgs->idle_cpus > sgs->idle_cpus)
return false;
+ if (sched_energy_enabled()) {
+ /* Select smaller cpu group for newly woken up forkees */
+ if ((sd_flag & SD_BALANCE_FORK) && (idlest_sgs->idle_cpus &&
+ !capacity_greater(idlest->sgc->max_capacity, group->sgc->max_capacity)))
+ return false;
+ }
+
/* Select group with lowest group_util */
if (idlest_sgs->idle_cpus == sgs->idle_cpus &&
idlest_sgs->group_util <= sgs->group_util)
@@ -8940,7 +8948,7 @@ static bool update_pick_idlest(struct sched_group *idlest,
* Assumes p is allowed on at least one CPU in sd.
*/
static struct sched_group *
-find_idlest_group(struct sched_domain *sd, struct task_struct *p, int this_cpu)
+find_idlest_group(struct sched_domain *sd, struct task_struct *p, int this_cpu, int sd_flag)
{
struct sched_group *idlest = NULL, *local = NULL, *group = sd->groups;
struct sg_lb_stats local_sgs, tmp_sgs;
@@ -8978,7 +8986,7 @@ find_idlest_group(struct sched_domain *sd, struct task_struct *p, int this_cpu)
update_sg_wakeup_stats(sd, group, sgs, p);
- if (!local_group && update_pick_idlest(idlest, &idlest_sgs, group, sgs)) {
+ if (!local_group && update_pick_idlest(idlest, &idlest_sgs, group, sgs, sd_flag)) {
idlest = group;
idlest_sgs = *sgs;
}
--
2.17.1
Powered by blists - more mailing lists