The current implementation of overutilization, aborts energy aware
scheduling if any cpu in the system is over-utilized. This patch introduces
over utilization flag per sched group level instead of a single flag
system wide. Load balancing is done at the sched domain where any
of the sched group is over utilized. If energy aware scheduling is
enabled and no sched group in a sched domain is overuttilized,
load balancing is skipped for that sched domain and energy aware
scheduling continues at that level.
The implementation is based on two points
1. For every cpu in every sched domain the first group
is the group that contains the cpu itself.
2. sched groups are shared between cpus.
Thus if a sched group is overutilized the overutilized flag is
set at the first sched group of the parent sched domain. This ensures a
load balancing at the overutilzed sched domain level.
For example consider a big little system with two little cpu's (CPU A and CPU B)
and two big cpu's (CPU C and CPU D). In this system, the hierarchy will be as follows
CPU A
SD level 1 - SG1 (CPUA), SG2 (CPUB)
SD level 2 - SG5(CPUA, CPUB), SG6(CPU C, CPU D)
RD
CPU B
SD level 1 - SG2(CPUB), SG1 (CPUA)
SD level 2 - SG5(CPU A, CPU B), SG6(CPU C, CPUD)
RD
CPU C
SD level 1 - SG3(CPU C), SG4 (CPUD)
SD level 2 - SG6(CPUC, CPUD), SG5(CPUA, CPU B)
RD
CPU D
SD level 1 - SG4(CPU D), SG3(CPU C)
SD level2 - SG6(CPUC, CPU D), SG5(CPU A, APU B)
RD
In the above system if CPUA is overutilized, the overutilized
flag is set at SG5(parent sched domain first sched group). Similarly
if CPUB is overutilized, the flag is set at SG5. During load balancing,
at SD level 1, the overutilized flag is checked at the parent sched domain,
first sched group level(SG5). If there is no parent sched domain, then the flag
is set/checked at the root domain. This ensures that load balancing happens
irrespective of which cpu is over utilized in a sched domain.
Signed-off-by: Thara Gopinath <thara.gopinath(a)linaro.org>
---
kernel/sched/fair.c | 108 ++++++++++++++++++++++++++++++++++++++++++---------
kernel/sched/sched.h | 1 +
2 files changed, 90 insertions(+), 19 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 01fa969..0c97e0a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4559,6 +4559,36 @@ static inline void hrtick_update(struct rq *rq)
static bool cpu_overutilized(int cpu);
+static bool
+is_sd_overutilized(struct sched_domain *sd, struct root_domain *rd)
+{
+ if (sd && sd->parent)
+ return sd->parent->groups->overutilized;
+
+ if (!rd)
+ return false;
+
+ return rd->overutilized;
+}
+
+static void
+set_sd_overutilized(struct sched_domain *sd, struct root_domain *rd)
+{
+ if (sd && sd->parent)
+ sd->parent->groups->overutilized = true;
+ else if (rd)
+ rd->overutilized = true;
+}
+
+static void
+clear_sd_overutilized(struct sched_domain *sd, struct root_domain *rd)
+{
+ if (sd && sd->parent)
+ sd->parent->groups->overutilized = false;
+ else if (rd)
+ rd->overutilized = false;
+}
+
/*
* The enqueue_task method is called before nr_running is
* increased. Here we update the fair scheduling stats and
@@ -4568,6 +4598,7 @@ static void
enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
{
struct cfs_rq *cfs_rq;
+ struct sched_domain *sd;
struct sched_entity *se = &p->se;
int task_new = !(flags & ENQUEUE_WAKEUP);
@@ -4603,9 +4634,12 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
if (!se) {
add_nr_running(rq, 1);
- if (!task_new && !rq->rd->overutilized &&
- cpu_overutilized(rq->cpu))
- rq->rd->overutilized = true;
+ rcu_read_lock();
+ sd = rcu_dereference(rq->sd);
+ if (!task_new && !is_sd_overutilized(sd, rq->rd) &&
+ cpu_overutilized(rq->cpu))
+ set_sd_overutilized(sd, rq->rd);
+ rcu_read_unlock();
}
hrtick_update(rq);
}
@@ -5989,8 +6023,6 @@ static int select_energy_cpu_brute(struct task_struct *p, int prev_cpu)
unsigned long max_spare = 0;
struct sched_domain *sd;
- rcu_read_lock();
-
sd = rcu_dereference(per_cpu(sd_ea, prev_cpu));
if (!sd)
@@ -6028,7 +6060,6 @@ static int select_energy_cpu_brute(struct task_struct *p, int prev_cpu)
}
unlock:
- rcu_read_unlock();
if (energy_cpu == prev_cpu && !cpu_overutilized(prev_cpu))
return prev_cpu;
@@ -6063,10 +6094,16 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f
&& cpumask_test_cpu(cpu, tsk_cpus_allowed(p));
}
- if (energy_aware() && !(cpu_rq(prev_cpu)->rd->overutilized))
- return select_energy_cpu_brute(p, prev_cpu);
-
rcu_read_lock();
+ sd = rcu_dereference(cpu_rq(prev_cpu)->sd);
+ if (energy_aware() &&
+ !is_sd_overutilized(sd,
+ cpu_rq(cpu)->rd)) {
+ new_cpu = select_energy_cpu_brute(p, prev_cpu);
+ goto unlock;
+ }
+
+ sd = NULL;
for_each_domain(cpu, tmp) {
if (!(tmp->flags & SD_LOAD_BALANCE))
break;
@@ -6131,6 +6168,8 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f
}
/* while loop will break here if sd == NULL */
}
+
+unlock:
rcu_read_unlock();
return new_cpu;
@@ -7178,6 +7217,7 @@ struct sd_lb_stats {
struct sched_group *local; /* Local group in this sd */
unsigned long total_load; /* Total load of all groups in sd */
unsigned long total_capacity; /* Total capacity of all groups in sd */
+ unsigned long total_util; /* Total util of all groups in sd */
unsigned long avg_load; /* Average load across all groups in sd */
struct sg_lb_stats busiest_stat;/* Statistics of the busiest group */
@@ -7197,6 +7237,7 @@ static inline void init_sd_lb_stats(struct sd_lb_stats *sds)
.local = NULL,
.total_load = 0UL,
.total_capacity = 0UL,
+ .total_util = 0UL,
.busiest_stat = {
.avg_load = 0UL,
.sum_nr_running = 0,
@@ -7692,6 +7733,7 @@ next_group:
/* Now, start updating sd_lb_stats */
sds->total_load += sgs->group_load;
sds->total_capacity += sgs->group_capacity;
+ sds->total_util += sgs->group_util;
sg = sg->next;
} while (sg != env->sd->groups);
@@ -7701,17 +7743,26 @@ next_group:
env->src_grp_nr_running = sds->busiest_stat.sum_nr_running;
+ /* Setting overutilized flag might not be necessary here
+ * Revisit
+ */
if (!lb_sd_parent(env->sd)) {
/* update overload indicator if we are at root domain */
if (env->dst_rq->rd->overload != overload)
env->dst_rq->rd->overload = overload;
+ }
- /* Update over-utilization (tipping point, U >= 0) indicator */
- if (env->dst_rq->rd->overutilized != overutilized)
- env->dst_rq->rd->overutilized = overutilized;
- } else {
- if (!env->dst_rq->rd->overutilized && overutilized)
- env->dst_rq->rd->overutilized = true;
+ if (overutilized)
+ set_sd_overutilized(env->sd, env->dst_rq->rd);
+
+ /* If the domain util is greater that domain capacity, load balancing
+ * needs to be done at the next sched domain level as well
+ */
+ if (sds->total_capacity * 1024 < sds->total_util * capacity_margin) {
+ /* If already at the highest domain nothing can be done */
+ if (env->sd->parent)
+ set_sd_overutilized(env->sd->parent,
+ env->dst_rq->rd);
}
}
@@ -7932,8 +7983,11 @@ static struct sched_group *find_busiest_group(struct lb_env *env)
*/
update_sd_lb_stats(env, &sds);
- if (energy_aware() && !env->dst_rq->rd->overutilized)
- goto out_balanced;
+ /* Is this check really required here?? Revisit */
+ if (energy_aware()) {
+ if (!is_sd_overutilized(env->sd, env->dst_rq->rd))
+ goto out_balanced;
+ }
local = &sds.local_stat;
busiest = &sds.busiest_stat;
@@ -8000,6 +8054,12 @@ static struct sched_group *find_busiest_group(struct lb_env *env)
force_balance:
/* Looks like there is an imbalance. Compute it */
calculate_imbalance(env, &sds);
+
+ /* Is this the correct place to clear this flag? Should access
+ * to flag be locked? Revisit.
+ */
+ clear_sd_overutilized(env->sd, env->dst_rq->rd);
+
return sds.busiest;
out_balanced:
@@ -8790,6 +8850,11 @@ static void rebalance_domains(struct rq *rq, enum cpu_idle_type idle)
rcu_read_lock();
for_each_domain(cpu, sd) {
+ if (energy_aware()) {
+ if (!is_sd_overutilized(sd, rq->rd))
+ continue;
+ }
+
/*
* Decay the newidle max times here because this is a regular
* visit to all the domains. Decay ~1% per second.
@@ -9083,6 +9148,7 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued)
{
struct cfs_rq *cfs_rq;
struct sched_entity *se = &curr->se;
+ struct sched_domain *sd;
for_each_sched_entity(se) {
cfs_rq = cfs_rq_of(se);
@@ -9092,8 +9158,12 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued)
if (static_branch_unlikely(&sched_numa_balancing))
task_tick_numa(rq, curr);
- if (!rq->rd->overutilized && cpu_overutilized(task_cpu(curr)))
- rq->rd->overutilized = true;
+ rcu_read_lock();
+ sd = rcu_dereference(rq->sd);
+ if (!is_sd_overutilized(sd, rq->rd) &&
+ cpu_overutilized(task_cpu(curr)))
+ set_sd_overutilized(sd, rq->rd);
+ rcu_read_unlock();
}
/*
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index f99391d..90c48ac 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -913,6 +913,7 @@ struct sched_group {
unsigned int group_weight;
struct sched_group_capacity *sgc;
const struct sched_group_energy const *sge;
+ bool overutilized;
/*
* The CPUs this group covers.
--
2.1.4
Dear Manager;
How is everything going? I had sent you some emails before but got no response, It will be very much grateful if you can give me a short reply this time.
The price is still unstable in China steel market, It is predicted it will continue to rise very soon, we decided to make promotion with stock steel pipes to thanks our new and old clients.The price is really good in such a market situation and we can arrange delivery before Spring Festival.
ItemTypeStandardMaterialOD (MM)WT
(MM)Length
(M)QuantityCoatingFOB Tianjin(20"*5)
PcsTon UNIT
USD/TonAmount
1SMLSAPI 5LGr.B21.32.775.8190714.00 Bare$769.91$10,778.73
2SMLSAPI 5LGr.B13.72.245.8381314.00 Bare$988.91$13,844.54
3SMLSAPI 5LGr.B26.72.875.8143114.00 Bare$718.38$10,055.92
4SMLSAPI 5LGr.B42.23.565.852910.41 Bare$639.80$6,658.97
5SMLSAPI 5LGr.B48.33.685.846810.99 Bare$621.76$6,833.91
6SMLSAPI 5LGr.B735.165.81798.96 Bare$620.48$5,560.76
7SMLSAPI 5LGr.B88.95.495.8140.92 Bare$620.48$568.94
8SMLSAPI 5LGr.B101.65.745.820315.98 Bare$611.46$9,768.61
9SMLSAPI 5LGr.B114.36.025.8555.13 Bare$611.46$3,135.41
10SMLSAPI 5LGr.B141.36.555.8688.58 Bare$614.03$5,270.99
11SMLSAPI 5LGr.B219.18.185.8204.94 Bare$614.03$3,030.50
12SMLSAPI 5LGr.B2739.275.86020.98 Bare$614.03$12,882.61
13SMLSAPI 5LGr.B323.810.315.8104.62 Bare$614.03$2,838.54
14SMLSAPI 5LGr.B355.69.535.894.25 Bare$641.09$2,721.68
Please don't hesitate to let me know if any inquiry or questions.
All the best,
P Please consider the environment before printing this e-mail.
Dear Friend;
Happy New Year!
How time flies, It has been a fresh new year now. you must have had a fruitful and wonderful year in 2016, may the joy and fortune continue to be in company with you and your families in 2017.
We are planing to make promotion with some stock steel pipes include but not limited to welded steel pipe to support you at the beginning of this year. The quantities are very small and price is very favorable , please check the form below and don't hesitate to let me know if any inquiry or questions.
ItemNameStandardMaterialSizeQuantityRemark
OD
(mm)THK
(mm)Length(m)PCSTONS
1ERWAPI 5LQ345B139.75.1 6.5879.57PE ends,Black Paint
2ERWAPI 5LQ345B168.36.1 11.955014.58PE ends,Black Paint
3LSAWASTM A516 GR70 CL2276212.7668.45 BE ends,Light Oil Paint
4LSAWASTM A516 GR70 CL22660.412.762024.34 BE ends,Light Oil Paint
5LSAWASTM A516 GR70 CL22660.49.52665.50 BE ends,Light Oil Paint
6LSAWA672C60 CL13406.49.531222.24 Bare Pipe, BE ends
7LSAWA672C60 CL13609.69.53122847.38 Bare Pipe, BE ends
8LSAWA672C60 CL13914.49.531212.55 Bare Pipe, BE ends
9LSAWA672C60 CL13101611.13120.00 Bare Pipe, BE ends
10LSAWA672C60 CL13406.46.35121813.53 Bare Pipe, BE ends
11LSAWA672C60 CL13457.26.351221.69 Bare Pipe, BE ends
12LSAWA672C60 CL135086.351210.94 Bare Pipe, BE ends
13LSAWA672C60 CL13609.67.92120.00 Bare Pipe, BE ends
14LSAWA672C65 CL13609.69.5312813.54 Bare Pipe, BE ends
15Welded PipeA358304/304L219.13.57610 1.15 PE ends, end caps in woven bags
16Welded PipeA358304/304L2733.98622 3.52 PE ends, end caps in woven bags
17Welded PipeA358304/304L323.84.3464 0.83 PE ends, end caps in woven bags
18Welded PipeA358304/304L355.64.5465 1.19 PE ends, end caps in woven bags
19Welded PipeA358304/304L406.44.5464 1.09 PE ends, end caps in woven bags
20Welded PipeA358304/304L406.412.0765 3.56 PE ends, end caps in woven bags
21Welded PipeA358304/304L457.24.5464 1.23 PE ends, end caps in woven bags
22Welded PipeA358304/304L50814.3461 1.06 PE ends, end caps in woven bags
23Welded PipeA358304/304L7627.5263 2.54 PE ends, end caps in woven bags
24Welded PipeA312N0890488.92.961 0.04 PE ends, end caps in woven bags
25Welded PipeA312N08904219.13.5761 0.12 PE ends, end caps in woven bags
26Welded PipeA312N08904168.33.2361 0.08 PE ends, end caps in woven bags
27Welded PipeA312N08904219.13.5762 0.23 PE ends, end caps in woven bags
28Welded PipeA312N08904355.64.5462 0.48 PE ends, end caps in woven bags
29Welded PipeA312N08904406.44.5462 0.55 PE ends, end caps in woven bags
33SSAWAPI 5LGr.B10167.2512000170367.91 PE ends
34ERWAPI 5LGr.B60.33122500127.17 PE ends
35Hollow SectionASTM A500Gr.B40*401.512m370081.22 Bare Pipe, PE ends
36Hollow SectionASTM A500Gr.B80*801.512m3700164.91 Bare Pipe, PE ends
37Hollow SectionASTM A500Gr.B100*1008.7512m493148.32 Bare Pipe, PE ends
38Hollow SectionASTM A500Gr.B100*1504.7512m38783.29 Bare Pipe, PE ends
All the best,
P Please consider the environment before printing this e-mail.
In energy aware path for waken task, it calculates energy difference to
select power saving CPU. For some corner case, the task utilization is
0, this means the task has run very short time and don't cross 1024us
(1ms). At the end energy difference = 0 when task utilized is 0, so
finally select an unexpected target CPU for below scenario:
If the task previously run on CPUA and CPUA is a higher capacity CPU,
when calculate energy difference between CPUA with another lower
capacity CPU (CPUB), we will get energy_diff = 0. Finally this task
sticks on CPUA and miss the chance to migrate to CPUB.
If the energy difference calculation happens between two CPUs with same
capacity, it will always stay on previous CPU so the calculation is
pointless.
This patch checks if the task util_avg is 0, it directly returns back
'target_cpu' which is selected by the power efficiency loop.
Signed-off-by: Leo Yan <leo.yan(a)linaro.org>
---
kernel/sched/fair.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d1d5dad..7b1f65b 100755
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5616,6 +5616,9 @@ static int energy_aware_wake_cpu(struct task_struct *p, int target, int sync)
}
}
+ if (unlikely(!task_util(p)))
+ return target_cpu;
+
if (target_cpu != task_cpu(p)) {
struct energy_env eenv = {
.util_delta = task_util(p),
--
2.7.4
Hi Leo.
[CC'ing eas-dev].
As discussed, here's an useful break-down of middleware configuration
examples and resources shared with us. The publically available
resources provide additional context about how hinting is coupled to
SchedTune.
cpusets
https://android.googlesource.com/device/google/marlin/+/nougat-dr1-release/…
write /dev/cpuset/top-app/cpus 0-3
write /dev/cpuset/foreground/boost/cpus 0-2
write /dev/cpuset/foreground/cpus 0-2
write /dev/cpuset/background/cpus 0 write
/dev/cpuset/system-background/cpus 0-2
cpuctl
https://android.googlesource.com/device/google/marlin/+/nougat-dr1-release/…
write /dev/cpuctl/cpu.shares 1024
write /dev/cpuctl/cpu.rt_runtime_us 800000
write /dev/cpuctl/cpu.rt_period_us 1000000
mkdir /dev/cpuctl/bg_non_interactive
chown system system /dev/cpuctl/bg_non_interactive/tasks
chmod 0666 /dev/cpuctl/bg_non_interactive/tasks
# 5.0 %
write /dev/cpuctl/bg_non_interactive/cpu.shares 52
write /dev/cpuctl/bg_non_interactive/cpu.rt_runtime_us 700000
write /dev/cpuctl/bg_non_interactive/cpu.rt_period_us 1000000
SchedTune
https://android.googlesource.com/device/google/marlin/+/nougat-dr1-release/…
write /dev/stune/foreground/schedtune.prefer_idle 1
write /dev/stune/top-app/schedtune.boost 10
write /dev/stune/top-app/schedtune.prefer_idle 1
PowerHAL
https://android.googlesource.com/device/google/marlin/+/nougat-dr1-release/…
Robin
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Hi,
Would you be keen on Computer Software Clients List for your deals and
showcasing effort?
Key Decision makers:
CIOs /COOs/ CTOs/ CFO's/ IT Directors
IT Management
IT Architects
Line of Business Managers & Directors
Security Professionals
Data Centre Managers
IP Communications industry'
Including Service Providers
Carriers, Enterprises,
Government Agencies
Reseller
Manufacturers
Developers
As well as Business and Technology Leaders, CTOs, Channel & Partner
Managers, Business Development Managers, Analysts & Infrastructure Teams
from Cloud Service Providers, Telecommunications, ISPs, ISVs and the IT
Channel and Industry serving the cloud community.
We are glad to inform you that we running with a Q4 Offer and can provide
you the complete list for a discount price.
Looking forward to hear from you.
Regards,
Claire Divas
Online Marketing Manager
To opt out kindly reply back with
'unsubscribe' or 'leave out'