Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2837294imm; Thu, 24 May 2018 17:14:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpe7kg2ggNBwKsGYzo3MH/ckY/zMb0ZzpBm4d2eoR0TTnM8Jdj1RhdidNv9GJoKmPz9V3GH X-Received: by 2002:a65:4805:: with SMTP id h5-v6mr155571pgs.96.1527207280126; Thu, 24 May 2018 17:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527207280; cv=none; d=google.com; s=arc-20160816; b=tiNAq304m6r+XbY0Of++lxj258EhTPhS8KV13Tb3e/lboDxDACDfK/5pPqdMbXy9nk qbpCrww0L88cDxYptouLnjn+znRQhg66HHl84H6mUBXTzP9OVm8Wjxni5vyaRx1XFrLv F7Ujsq/3q0YW2EU9wC1wxaZXuVE7zQGmjGbaOpsEdHLm+kjIdUbvepslPfZz4VmldQR/ upbn4lAHwXwTDTkHbNydADtQ2u4/fCBGAkmmo+65kJtdyQA496kryqNF6DM/FtMV62EY c8Lb8oxYVPw0t98C0Ro7Iiv+y9PHtRY6zBVTGRF4F0CVgjUaNfDXmgMZOliF6ZB4QK9/ Kgww== 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=0UcUK8I58V+49AWfbWKlBJVq++9NX9THMbASHf1dHKw=; b=s2DdsLKiDytDyqLvUcPVqRhMKgtj5C13uvhwsLrsHrekyH6K1+0TioHmZ4I1Ee9YfF sCo2Fhgn/w+1nttNlAwoJDYfGF/hWESnRuetrhZFDZgKRG8NSzZNCuXcx3LrUTboQHE0 ybx0aVsfYS/YLFcNxPo5pClZOtnlY3Zvxy478X7AvrvPgMfN1PYEgvQ21DrK1Q1/Y6Vq 1GCuUDNMQizkUaHoDwAOo/G6BjyM1qS8fbkdpH9EOjr/m6ZAZX0mrAenkDeGCZ3RAQRL pOEoxqR2r2eBZw0wtENNqT95NQb/2GoU1JQFoOO2AmUBrp3N9zt5+zQDJJ6dO1UYdWHi qRrQ== 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 k4-v6si22064798pll.118.2018.05.24.17.14.25; Thu, 24 May 2018 17:14:40 -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 S967946AbeEXOLM (ORCPT + 99 others); Thu, 24 May 2018 10:11:12 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:45480 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970395AbeEXOKk (ORCPT ); Thu, 24 May 2018 10:10:40 -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 8DBA0165D; Thu, 24 May 2018 07:10:40 -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 42D9F3F24A; Thu, 24 May 2018 07:10:38 -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 v3 2/2] sched/fair: util_est: update before schedutil Date: Thu, 24 May 2018 15:10:23 +0100 Message-Id: <20180524141023.13765-3-patrick.bellasi@arm.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180524141023.13765-1-patrick.bellasi@arm.com> References: <20180524141023.13765-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 Acked-by: Vincent Guittot 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 v3: - add "Acked-by" Vincent tags 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 748cb054fefd..e497c05aab7f 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5385,6 +5385,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 @@ -5426,7 +5434,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