Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp774872imm; Fri, 11 May 2018 06:16:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqJIAdysJFf6w67HSKHAtfDBGRY4IY0YvSXKZ6GhzI7SFhZStLoUcux6FrVO/9BcgY/TXaR X-Received: by 2002:a62:4353:: with SMTP id q80-v6mr5529570pfa.228.1526044587211; Fri, 11 May 2018 06:16:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526044587; cv=none; d=google.com; s=arc-20160816; b=OvoAfkNYEImSQUEVD1Jm3qfGRsOIvcbM1v1UMVOntmz6CZf7cIF/Kmj7W2mLMR9T4/ 0DMrA8Kzqp9i4a6iCp4Yt1787RgZO+mC/pQr6vKilsGoHTqCdOEidYPr0kr/sKVtNltz lkm8vr0/tEAFFeRcA7XP2mj7bh4a+3UCVF9QGYAlUGLLKIOPFWDH4CzY9v7GPlw3NNtl t/tMKfARb2lJ5YhwrEE/IeQ+lK3KQ/HAhWWFYySVYCckUxoPoNgH0w5zLcLYWHuSfM+R UIXhuvj9EuA8i/78WOEfGM5isOW953B+5Zu/TzyO+pB6jRV5u8pHsBf1PVWkkm4MPAWp g3yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=S92n1auCt1rsXIBXZQJLle6mtTSMqTjGZ44I6KYTAs8=; b=LLwNi8iv3LatuQl5uyecGnMMPu68hddN196lKEDoHCdBKpDeizuqKehG1TGxia81Ck 6YEM7wztoiWzh8y1MExk+nlE72HNBzWfq/4VnzwlW2ZMJ1Q5uvYeUr9kM1RXxBxNGlmC tdSa9M2pdpdrzAgjOH1J6JgjG+EJ742pTLfXr0zL8V4zAjvOX3N3A77PD+R9zoRdyIY1 VWf/bwUXSYamTyrnsGOkiNFZyUA0BJ2FPxVKXN/MSrByKNE8xfMaHSWhVcqSFyz5w2WX km45KrQ2KpDC++DG9newg5lJXzHrRUOzqYYO49jVS71+KS8YEdXmn1zbCuSqTvwSLEe0 mVMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c196-v6si2561151pga.494.2018.05.11.06.16.10; Fri, 11 May 2018 06:16:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753091AbeEKNPe (ORCPT + 99 others); Fri, 11 May 2018 09:15:34 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:41214 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753043AbeEKNPc (ORCPT ); Fri, 11 May 2018 09:15:32 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 786E71684; Fri, 11 May 2018 06:15:32 -0700 (PDT) Received: from e110439-lin.cambridge.arm.com (e110439-lin.cambridge.arm.com [10.1.210.68]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 448513F73E; Fri, 11 May 2018 06:15:30 -0700 (PDT) From: Patrick Bellasi To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , "Rafael J . Wysocki" , Viresh Kumar , Vincent Guittot , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Joel Fernandes , Steve Muckle Subject: [PATCH v2 2/3] sched/fair: util_est: update before schedutil Date: Fri, 11 May 2018 14:15:08 +0100 Message-Id: <20180511131509.16275-3-patrick.bellasi@arm.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180511131509.16275-1-patrick.bellasi@arm.com> References: <20180511131509.16275-1-patrick.bellasi@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a task is enqueue the estimated utilization of a CPU is updated to better support the selection of the required frequency. However, schedutil is (implicitly) updated by update_load_avg() which always happens before util_est_{en,de}queue(), thus potentially introducing a latency between estimated utilization updates and frequency selections. Let's update util_est at the beginning of enqueue_task_fair(), which will ensure that all schedutil updates will see the most updated estimated utilization value for a CPU. Reported-by: Vincent Guittot Signed-off-by: Patrick Bellasi Acked-by: Viresh Kumar Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Vincent Guittot Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org Fixes: 7f65ea42eb00 ("sched/fair: Add util_est on top of PELT") --- Changes in v2: - improve comment in enqueue_task_fair() (Peter) - add "Fixes" tag - add "Acked-by" Viresh tag --- kernel/sched/fair.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 1f6a23a5b451..f01f0f395f9a 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5356,6 +5356,14 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) struct cfs_rq *cfs_rq; struct sched_entity *se = &p->se; + /* + * The code below (indirectly) updates schedutil which looks at + * the cfs_rq utilization to select a frequency. + * Let's add the task's estimated utilization to the cfs_rq's + * estimated utilization, before we update schedutil. + */ + util_est_enqueue(&rq->cfs, p); + /* * If in_iowait is set, the code below may not trigger any cpufreq * utilization updates, so do it here explicitly with the IOWAIT flag @@ -5397,7 +5405,6 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) if (!se) add_nr_running(rq, 1); - util_est_enqueue(&rq->cfs, p); hrtick_update(rq); } -- 2.15.1