Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1405258 > unrolled thread
| Started by | Morten Rasmussen <morten.rasmussen@arm.com> |
|---|---|
| First post | 2016-05-23 13:10 +0200 |
| Last post | 2016-05-23 13:10 +0200 |
| Articles | 4 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH 00/16] sched: Clean-ups and asymmetric cpu capacity support Morten Rasmussen <morten.rasmussen@arm.com> - 2016-05-23 13:10 +0200
[PATCH 08/16] sched: Store maximum per-cpu capacity in root domain Morten Rasmussen <morten.rasmussen@arm.com> - 2016-05-23 13:10 +0200
[PATCH 10/16] sched/fair: Compute task/cpu utilization at wake-up more correctly Morten Rasmussen <morten.rasmussen@arm.com> - 2016-05-23 13:10 +0200
[PATCH 02/16] sched/fair: Consistent use of prev_cpu in wakeup path Morten Rasmussen <morten.rasmussen@arm.com> - 2016-05-23 13:10 +0200
| From | Morten Rasmussen <morten.rasmussen@arm.com> |
|---|---|
| Date | 2016-05-23 13:10 +0200 |
| Subject | [PATCH 00/16] sched: Clean-ups and asymmetric cpu capacity support |
| Message-ID | <rBVKx-4Lf-3@gated-at.bofh.it> |
Hi,
The scheduler is currently not doing much to help performance on systems with
asymmetric compute capacities (read ARM big.LITTLE). This series improves the
situation with a few tweaks mainly to the task wake-up path that considers
compute capacity at wake-up and not just whether a cpu is idle for these
systems. This gives us consistent, and potentially higher, throughput in
partially utilized scenarious. SMP behaviour and performance should be
unaffected.
Test 0:
for i in `seq 1 10`; \
do sysbench --test=cpu --max-time=3 --num-threads=1 run; \
done \
| awk '{if ($4=="events:") {print $5; sum +=$5; runs +=1}} \
END {print "Average events: " sum/runs}'
Target: ARM TC2 (2xA15+3xA7)
(Higher is better)
tip: Average events: 150.2
patch: Average events: 217.9
Test 1:
perf stat --null --repeat 10 -- \
perf bench sched messaging -g 50 -l 5000
Target: Intel IVB-EP (2*10*2)
tip: 4.831538935 seconds time elapsed ( +- 1.58% )
patch: 4.839951382 seconds time elapsed ( +- 1.01% )
Target: ARM TC2 A7-only (3xA7) (-l 1000)
tip: 61.406552538 seconds time elapsed ( +- 0.12% )
patch: 61.589263159 seconds time elapsed ( +- 0.22% )
Active migration of tasks away from small capacity cpus isn't addressed
in this set although it is necessary for consistent throughput in other
scenarios on asymmetric cpu capacity systems.
Patch 1-4: Generic fixes and clean-ups.
Patch 5-13: Improve capacity awareness.
Patch 14-16: Arch features for arm to enable asymmetric capacity support.
Dietmar Eggemann (1):
sched: Store maximum per-cpu capacity in root domain
Morten Rasmussen (15):
sched: Fix power to capacity renaming in comment
sched/fair: Consistent use of prev_cpu in wakeup path
sched/fair: Disregard idle task wakee_flips in wake_wide
sched/fair: Optimize find_idlest_cpu() when there is no choice
sched: Introduce SD_ASYM_CPUCAPACITY sched_domain topology flag
sched: Disable WAKE_AFFINE for asymmetric configurations
sched: Make SD_BALANCE_WAKE a topology flag
sched/fair: Let asymmetric cpu configurations balance at wake-up
sched/fair: Compute task/cpu utilization at wake-up more correctly
sched/fair: Consider spare capacity in find_idlest_group()
sched: Add per-cpu max capacity to sched_group_capacity
sched/fair: Avoid pulling tasks from non-overloaded higher capacity
groups
arm: Set SD_ASYM_CPUCAPACITY for big.LITTLE platforms
arm: Set SD_BALANCE_WAKE flag for asymmetric capacity systems
arm: Update arch_scale_cpu_capacity() to reflect change to define
arch/arm/include/asm/topology.h | 5 +
arch/arm/kernel/topology.c | 25 ++++-
include/linux/sched.h | 3 +-
kernel/sched/core.c | 25 ++++-
kernel/sched/fair.c | 217 ++++++++++++++++++++++++++++++++++++----
kernel/sched/sched.h | 5 +-
6 files changed, 250 insertions(+), 30 deletions(-)
--
1.9.1
[toc] | [next] | [standalone]
| From | Morten Rasmussen <morten.rasmussen@arm.com> |
|---|---|
| Date | 2016-05-23 13:10 +0200 |
| Subject | [PATCH 08/16] sched: Store maximum per-cpu capacity in root domain |
| Message-ID | <rBVUe-53H-27@gated-at.bofh.it> |
| In reply to | #1405258 |
From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To be able to compare the capacity of the target cpu with the highest
available cpu capacity, store the maximum per-cpu capacity in the root
domain.
cc: Ingo Molnar <mingo@redhat.com>
cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Morten Rasmussen <morten.rasmussen@arm.com>
---
kernel/sched/core.c | 9 +++++++++
kernel/sched/sched.h | 2 ++
2 files changed, 11 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 8014b4a..1d4059c 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6841,6 +6841,7 @@ static int build_sched_domains(const struct cpumask *cpu_map,
enum s_alloc alloc_state;
struct sched_domain *sd;
struct s_data d;
+ struct rq *rq = NULL;
int i, ret = -ENOMEM;
alloc_state = __visit_domain_allocation_hell(&d, cpu_map);
@@ -6891,11 +6892,19 @@ static int build_sched_domains(const struct cpumask *cpu_map,
/* Attach the domains */
rcu_read_lock();
for_each_cpu(i, cpu_map) {
+ rq = cpu_rq(i);
sd = *per_cpu_ptr(d.sd, i);
cpu_attach_domain(sd, d.rd, i);
+
+ if (rq->cpu_capacity_orig > rq->rd->max_cpu_capacity)
+ rq->rd->max_cpu_capacity = rq->cpu_capacity_orig;
}
rcu_read_unlock();
+ if (rq)
+ pr_info("span: %*pbl (max cpu_capacity = %lu)\n",
+ cpumask_pr_args(cpu_map), rq->rd->max_cpu_capacity);
+
ret = 0;
error:
__free_domain_allocs(&d, alloc_state, cpu_map);
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index e51145e..72150c2 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -564,6 +564,8 @@ struct root_domain {
*/
cpumask_var_t rto_mask;
struct cpupri cpupri;
+
+ unsigned long max_cpu_capacity;
};
extern struct root_domain def_root_domain;
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Morten Rasmussen <morten.rasmussen@arm.com> |
|---|---|
| Date | 2016-05-23 13:10 +0200 |
| Subject | [PATCH 10/16] sched/fair: Compute task/cpu utilization at wake-up more correctly |
| Message-ID | <rBVUe-53H-35@gated-at.bofh.it> |
| In reply to | #1405258 |
At task wake-up load-tracking isn't updated until the task is enqueued.
The task's own view of its utilization contribution may therefore not be
aligned with its contribution to the cfs_rq load-tracking which may have
been updated in the meantime. Basically, the task's own utilization
hasn't yet accounted for the sleep decay, while the cfs_rq may have
(partially). Estimating the cfs_rq utilization in case the task is
migrated at wake-up as task_rq(p)->cfs.avg.util_avg - p->se.avg.util_avg
is therefore incorrect as the two load-tracking signals aren't time
synchronized (different last update).
To solve this problem, this patch introduces task_util_wake() which
computes the decayed task utilization based on the last update of the
previous cpu's last load-tracking update. It is done without having to
take the rq lock, similar to how it is done in remove_entity_load_avg().
cc: Ingo Molnar <mingo@redhat.com>
cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Morten Rasmussen <morten.rasmussen@arm.com>
---
kernel/sched/fair.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index ce44fa7..6d3369a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5304,6 +5304,75 @@ static inline int task_util(struct task_struct *p)
return p->se.avg.util_avg;
}
+/*
+ * task_util_wake: Returns an updated estimate of the utilization contribution
+ * of a waking task. At wake-up the task blocked utilization contribution
+ * (cfs_rq->avg) may have decayed while the utilization tracking of the task
+ * (se->avg) hasn't yet.
+ * Note that this estimate isn't perfectly accurate as the 1ms boundaries used
+ * for updating util_avg in __update_load_avg() are not considered here. This
+ * results in an error of up to 1ms utilization decay/accumulation which leads
+ * to an absolute util_avg error margin of 1024*1024/LOAD_AVG_MAX ~= 22
+ * (for LOAD_AVG_MAX = 47742).
+ */
+static inline int task_util_wake(struct task_struct *p)
+{
+ struct cfs_rq *prev_cfs_rq = &task_rq(p)->cfs;
+ struct sched_avg *psa = &p->se.avg;
+ u64 cfs_rq_last_update, p_last_update, delta;
+ u32 util_decayed;
+
+ p_last_update = psa->last_update_time;
+
+ /*
+ * Task on rq (exec()) should be load-tracking aligned already.
+ * New tasks have no history and should use the init value.
+ */
+ if (p->se.on_rq || !p_last_update)
+ return task_util(p);
+
+ cfs_rq_last_update = cfs_rq_last_update_time(prev_cfs_rq);
+ delta = cfs_rq_last_update - p_last_update;
+
+ if ((s64)delta <= 0)
+ return task_util(p);
+
+ delta >>= 20;
+
+ if (!delta)
+ return task_util(p);
+
+ util_decayed = decay_load((u64)psa->util_sum, delta);
+ util_decayed /= LOAD_AVG_MAX;
+
+ /*
+ * psa->util_avg can be slightly out of date as it is only updated
+ * when a 1ms boundary is crossed.
+ * See 'decayed' in __update_load_avg()
+ */
+ util_decayed = min_t(unsigned long, util_decayed, task_util(p));
+
+ return util_decayed;
+}
+
+/*
+ * cpu_util_wake: Compute cpu utilization with any contributions from
+ * the waking task p removed.
+ */
+static int cpu_util_wake(int cpu, struct task_struct *p)
+{
+ unsigned long util, capacity;
+
+ /* Task has no contribution or is new */
+ if (cpu != task_cpu(p) || !p->se.avg.last_update_time)
+ return cpu_util(cpu);
+
+ capacity = capacity_orig_of(cpu);
+ util = max_t(long, cpu_rq(cpu)->cfs.avg.util_avg - task_util_wake(p), 0);
+
+ return (util >= capacity) ? capacity : util;
+}
+
static int wake_cap(struct task_struct *p, int cpu, int prev_cpu)
{
long delta;
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Morten Rasmussen <morten.rasmussen@arm.com> |
|---|---|
| Date | 2016-05-23 13:10 +0200 |
| Subject | [PATCH 02/16] sched/fair: Consistent use of prev_cpu in wakeup path |
| Message-ID | <rBVUe-53H-37@gated-at.bofh.it> |
| In reply to | #1405258 |
In commit ac66f5477239 ("sched/numa: Introduce migrate_swap()")
select_task_rq() got a 'cpu' argument to enable overriding of prev_cpu
in special cases (NUMA task swapping). However, the
select_task_rq_fair() helper functions: wake_affine() and
select_idle_sibling(), still use task_cpu(p) directly to work out
prev_cpu which leads to inconsistencies.
This patch passes prev_cpu (potentially overridden by NUMA code) into
the helper functions to ensure prev_cpu is indeed the same cpu
everywhere in the wakeup path.
cc: Ingo Molnar <mingo@redhat.com>
cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Morten Rasmussen <morten.rasmussen@arm.com>
---
kernel/sched/fair.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 218f8e8..c49e25a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -656,7 +656,7 @@ static u64 sched_vslice(struct cfs_rq *cfs_rq, struct sched_entity *se)
}
#ifdef CONFIG_SMP
-static int select_idle_sibling(struct task_struct *p, int cpu);
+static int select_idle_sibling(struct task_struct *p, int prev_cpu, int cpu);
static unsigned long task_h_load(struct task_struct *p);
/*
@@ -1502,7 +1502,8 @@ static void task_numa_compare(struct task_numa_env *env,
* Call select_idle_sibling to maybe find a better one.
*/
if (!cur)
- env->dst_cpu = select_idle_sibling(env->p, env->dst_cpu);
+ env->dst_cpu = select_idle_sibling(env->p, env->src_cpu,
+ env->dst_cpu);
assign:
assigned = true;
@@ -5013,18 +5014,18 @@ static int wake_wide(struct task_struct *p)
return 1;
}
-static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync)
+static int wake_affine(struct sched_domain *sd, struct task_struct *p,
+ int prev_cpu, int sync)
{
s64 this_load, load;
s64 this_eff_load, prev_eff_load;
- int idx, this_cpu, prev_cpu;
+ int idx, this_cpu;
struct task_group *tg;
unsigned long weight;
int balanced;
idx = sd->wake_idx;
this_cpu = smp_processor_id();
- prev_cpu = task_cpu(p);
load = source_load(prev_cpu, idx);
this_load = target_load(this_cpu, idx);
@@ -5189,11 +5190,10 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
/*
* Try and locate an idle CPU in the sched_domain.
*/
-static int select_idle_sibling(struct task_struct *p, int target)
+static int select_idle_sibling(struct task_struct *p, int prev, int target)
{
struct sched_domain *sd;
struct sched_group *sg;
- int i = task_cpu(p);
if (idle_cpu(target))
return target;
@@ -5201,8 +5201,8 @@ static int select_idle_sibling(struct task_struct *p, int target)
/*
* If the prevous cpu is cache affine and idle, don't be stupid.
*/
- if (i != target && cpus_share_cache(i, target) && idle_cpu(i))
- return i;
+ if (prev != target && cpus_share_cache(prev, target) && idle_cpu(prev))
+ return prev;
/*
* Otherwise, iterate the domains and find an eligible idle cpu.
@@ -5223,6 +5223,8 @@ static int select_idle_sibling(struct task_struct *p, int target)
for_each_lower_domain(sd) {
sg = sd->groups;
do {
+ int i;
+
if (!cpumask_intersects(sched_group_cpus(sg),
tsk_cpus_allowed(p)))
goto next;
@@ -5331,13 +5333,13 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f
if (affine_sd) {
sd = NULL; /* Prefer wake_affine over balance flags */
- if (cpu != prev_cpu && wake_affine(affine_sd, p, sync))
+ if (cpu != prev_cpu && wake_affine(affine_sd, p, prev_cpu, sync))
new_cpu = cpu;
}
if (!sd) {
if (sd_flag & SD_BALANCE_WAKE) /* XXX always ? */
- new_cpu = select_idle_sibling(p, new_cpu);
+ new_cpu = select_idle_sibling(p, prev_cpu, new_cpu);
} else while (sd) {
struct sched_group *group;
--
1.9.1
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web