* [PATCH v2] sched/fair: Fix util_avg of new tasks for asymmetric systems
@ 2018-06-12 11:22 Quentin Perret
2018-07-05 7:53 ` Quentin Perret
2018-07-15 23:25 ` [tip:sched/core] " tip-bot for Quentin Perret
0 siblings, 2 replies; 4+ messages in thread
From: Quentin Perret @ 2018-06-12 11:22 UTC (permalink / raw)
To: peterz, mingo
Cc: linux-kernel, vincent.guittot, dietmar.eggemann,
morten.rasmussen, patrick.bellasi, Quentin Perret
When a new task wakes-up for the first time, its initial utilization
is set to half of the spare capacity of its CPU. The current
implementation of post_init_entity_util_avg() uses SCHED_CAPACITY_SCALE
directly as a capacity reference. As a result, on a big.LITTLE system, a
new task waking up on an idle little CPU will be given ~512 of util_avg,
even if the CPU's capacity is significantly less than that.
Fix this by computing the spare capacity with arch_scale_cpu_capacity().
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Acked-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Quentin Perret <quentin.perret@arm.com>
---
v2: added "Acked-by: Vincent Guittot <vincent.guittot@linaro.org>"
---
kernel/sched/fair.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index e497c05aab7f..f19432c17017 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -735,11 +735,12 @@ static void attach_entity_cfs_rq(struct sched_entity *se);
* To solve this problem, we also cap the util_avg of successive tasks to
* only 1/2 of the left utilization budget:
*
- * util_avg_cap = (1024 - cfs_rq->avg.util_avg) / 2^n
+ * util_avg_cap = (cpu_scale - cfs_rq->avg.util_avg) / 2^n
*
- * where n denotes the nth task.
+ * where n denotes the nth task and cpu_scale the CPU capacity.
*
- * For example, a simplest series from the beginning would be like:
+ * For example, for a CPU with 1024 of capacity, a simplest series from
+ * the beginning would be like:
*
* task util_avg: 512, 256, 128, 64, 32, 16, 8, ...
* cfs_rq util_avg: 512, 768, 896, 960, 992, 1008, 1016, ...
@@ -751,7 +752,8 @@ void post_init_entity_util_avg(struct sched_entity *se)
{
struct cfs_rq *cfs_rq = cfs_rq_of(se);
struct sched_avg *sa = &se->avg;
- long cap = (long)(SCHED_CAPACITY_SCALE - cfs_rq->avg.util_avg) / 2;
+ long cpu_scale = arch_scale_cpu_capacity(NULL, cpu_of(rq_of(cfs_rq)));
+ long cap = (long)(cpu_scale - cfs_rq->avg.util_avg) / 2;
if (cap > 0) {
if (cfs_rq->avg.util_avg != 0) {
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] sched/fair: Fix util_avg of new tasks for asymmetric systems
2018-06-12 11:22 [PATCH v2] sched/fair: Fix util_avg of new tasks for asymmetric systems Quentin Perret
@ 2018-07-05 7:53 ` Quentin Perret
2018-07-05 9:45 ` Peter Zijlstra
2018-07-15 23:25 ` [tip:sched/core] " tip-bot for Quentin Perret
1 sibling, 1 reply; 4+ messages in thread
From: Quentin Perret @ 2018-07-05 7:53 UTC (permalink / raw)
To: peterz, mingo
Cc: linux-kernel, vincent.guittot, dietmar.eggemann,
morten.rasmussen, patrick.bellasi
Hi,
On Tuesday 12 Jun 2018 at 12:22:15 (+0100), Quentin Perret wrote:
> When a new task wakes-up for the first time, its initial utilization
> is set to half of the spare capacity of its CPU. The current
> implementation of post_init_entity_util_avg() uses SCHED_CAPACITY_SCALE
> directly as a capacity reference. As a result, on a big.LITTLE system, a
> new task waking up on an idle little CPU will be given ~512 of util_avg,
> even if the CPU's capacity is significantly less than that.
>
> Fix this by computing the spare capacity with arch_scale_cpu_capacity().
>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Acked-by: Vincent Guittot <vincent.guittot@linaro.org>
> Signed-off-by: Quentin Perret <quentin.perret@arm.com>
>
> ---
> v2: added "Acked-by: Vincent Guittot <vincent.guittot@linaro.org>"
> ---
> kernel/sched/fair.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index e497c05aab7f..f19432c17017 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -735,11 +735,12 @@ static void attach_entity_cfs_rq(struct sched_entity *se);
> * To solve this problem, we also cap the util_avg of successive tasks to
> * only 1/2 of the left utilization budget:
> *
> - * util_avg_cap = (1024 - cfs_rq->avg.util_avg) / 2^n
> + * util_avg_cap = (cpu_scale - cfs_rq->avg.util_avg) / 2^n
> *
> - * where n denotes the nth task.
> + * where n denotes the nth task and cpu_scale the CPU capacity.
> *
> - * For example, a simplest series from the beginning would be like:
> + * For example, for a CPU with 1024 of capacity, a simplest series from
> + * the beginning would be like:
> *
> * task util_avg: 512, 256, 128, 64, 32, 16, 8, ...
> * cfs_rq util_avg: 512, 768, 896, 960, 992, 1008, 1016, ...
> @@ -751,7 +752,8 @@ void post_init_entity_util_avg(struct sched_entity *se)
> {
> struct cfs_rq *cfs_rq = cfs_rq_of(se);
> struct sched_avg *sa = &se->avg;
> - long cap = (long)(SCHED_CAPACITY_SCALE - cfs_rq->avg.util_avg) / 2;
> + long cpu_scale = arch_scale_cpu_capacity(NULL, cpu_of(rq_of(cfs_rq)));
> + long cap = (long)(cpu_scale - cfs_rq->avg.util_avg) / 2;
>
> if (cap > 0) {
> if (cfs_rq->avg.util_avg != 0) {
> --
> 2.17.1
>
Is there anything else I should do for this patch ?
Thanks,
Quentin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] sched/fair: Fix util_avg of new tasks for asymmetric systems
2018-07-05 7:53 ` Quentin Perret
@ 2018-07-05 9:45 ` Peter Zijlstra
0 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2018-07-05 9:45 UTC (permalink / raw)
To: Quentin Perret
Cc: mingo, linux-kernel, vincent.guittot, dietmar.eggemann,
morten.rasmussen, patrick.bellasi
On Thu, Jul 05, 2018 at 08:53:50AM +0100, Quentin Perret wrote:
> Is there anything else I should do for this patch ?
Pinging me was the right thing. Have it now, much thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip:sched/core] sched/fair: Fix util_avg of new tasks for asymmetric systems
2018-06-12 11:22 [PATCH v2] sched/fair: Fix util_avg of new tasks for asymmetric systems Quentin Perret
2018-07-05 7:53 ` Quentin Perret
@ 2018-07-15 23:25 ` tip-bot for Quentin Perret
1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Quentin Perret @ 2018-07-15 23:25 UTC (permalink / raw)
To: linux-tip-commits
Cc: torvalds, peterz, tglx, linux-kernel, vincent.guittot, hpa,
mingo, quentin.perret
Commit-ID: 8fe5c5a937d0f4e84221631833a2718afde52285
Gitweb: https://git.kernel.org/tip/8fe5c5a937d0f4e84221631833a2718afde52285
Author: Quentin Perret <quentin.perret@arm.com>
AuthorDate: Tue, 12 Jun 2018 12:22:15 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sun, 15 Jul 2018 23:51:20 +0200
sched/fair: Fix util_avg of new tasks for asymmetric systems
When a new task wakes-up for the first time, its initial utilization
is set to half of the spare capacity of its CPU. The current
implementation of post_init_entity_util_avg() uses SCHED_CAPACITY_SCALE
directly as a capacity reference. As a result, on a big.LITTLE system, a
new task waking up on an idle little CPU will be given ~512 of util_avg,
even if the CPU's capacity is significantly less than that.
Fix this by computing the spare capacity with arch_scale_cpu_capacity().
Signed-off-by: Quentin Perret <quentin.perret@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: dietmar.eggemann@arm.com
Cc: morten.rasmussen@arm.com
Cc: patrick.bellasi@arm.com
Link: http://lkml.kernel.org/r/20180612112215.25448-1-quentin.perret@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/sched/fair.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 321cd5dcf2e8..08b89ae34233 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -735,11 +735,12 @@ static void attach_entity_cfs_rq(struct sched_entity *se);
* To solve this problem, we also cap the util_avg of successive tasks to
* only 1/2 of the left utilization budget:
*
- * util_avg_cap = (1024 - cfs_rq->avg.util_avg) / 2^n
+ * util_avg_cap = (cpu_scale - cfs_rq->avg.util_avg) / 2^n
*
- * where n denotes the nth task.
+ * where n denotes the nth task and cpu_scale the CPU capacity.
*
- * For example, a simplest series from the beginning would be like:
+ * For example, for a CPU with 1024 of capacity, a simplest series from
+ * the beginning would be like:
*
* task util_avg: 512, 256, 128, 64, 32, 16, 8, ...
* cfs_rq util_avg: 512, 768, 896, 960, 992, 1008, 1016, ...
@@ -751,7 +752,8 @@ void post_init_entity_util_avg(struct sched_entity *se)
{
struct cfs_rq *cfs_rq = cfs_rq_of(se);
struct sched_avg *sa = &se->avg;
- long cap = (long)(SCHED_CAPACITY_SCALE - cfs_rq->avg.util_avg) / 2;
+ long cpu_scale = arch_scale_cpu_capacity(NULL, cpu_of(rq_of(cfs_rq)));
+ long cap = (long)(cpu_scale - cfs_rq->avg.util_avg) / 2;
if (cap > 0) {
if (cfs_rq->avg.util_avg != 0) {
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-15 23:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12 11:22 [PATCH v2] sched/fair: Fix util_avg of new tasks for asymmetric systems Quentin Perret
2018-07-05 7:53 ` Quentin Perret
2018-07-05 9:45 ` Peter Zijlstra
2018-07-15 23:25 ` [tip:sched/core] " tip-bot for Quentin Perret
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome