From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-cys01nam02on0095.outbound.protection.outlook.com ([104.47.37.95]:24416 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728330AbeIOGru (ORCPT ); Sat, 15 Sep 2018 02:47:50 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Quentin Perret , Peter Zijlstra , Linus Torvalds , Thomas Gleixner , "dietmar.eggemann@arm.com" , "morten.rasmussen@arm.com" , "patrick.bellasi@arm.com" , Ingo Molnar , Sasha Levin Subject: [PATCH AUTOSEL 4.18 46/92] sched/fair: Fix util_avg of new tasks for asymmetric systems Date: Sat, 15 Sep 2018 01:30:21 +0000 Message-ID: <20180915012944.179481-45-alexander.levin@microsoft.com> References: <20180915012944.179481-1-alexander.levin@microsoft.com> In-Reply-To: <20180915012944.179481-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Quentin Perret [ Upstream commit 8fe5c5a937d0f4e84221631833a2718afde52285 ] 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 Signed-off-by: Peter Zijlstra (Intel) Acked-by: Vincent Guittot Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner 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.co= m Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- 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 9c219f7b0970..478d9d3e6be9 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 =3D (1024 - cfs_rq->avg.util_avg) / 2^n + * util_avg_cap =3D (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 =3D cfs_rq_of(se); struct sched_avg *sa =3D &se->avg; - long cap =3D (long)(SCHED_CAPACITY_SCALE - cfs_rq->avg.util_avg) / 2; + long cpu_scale =3D arch_scale_cpu_capacity(NULL, cpu_of(rq_of(cfs_rq))); + long cap =3D (long)(cpu_scale - cfs_rq->avg.util_avg) / 2; =20 if (cap > 0) { if (cfs_rq->avg.util_avg !=3D 0) { --=20 2.17.1