Received: by 10.213.65.68 with SMTP id h4csp1084212imn; Wed, 21 Mar 2018 02:06:18 -0700 (PDT) X-Google-Smtp-Source: AG47ELsoZgy+foV4DfPgFW+mULLMjCh7xSD0CwrqsPhSzkgFO4inxRu7KaAPUxruZSa/tfiw6tR8 X-Received: by 10.101.100.141 with SMTP id e13mr14739281pgv.333.1521623178470; Wed, 21 Mar 2018 02:06:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521623178; cv=none; d=google.com; s=arc-20160816; b=rF+sy2GvzK3bQ7R8uhx5VN0Bb4A1YgWGhbtYCr9i4HhCrvREpG8D1eJFHtx1rD8Hvy P4BYjaoNZuBvMXpyMieS6iPl0qOMyhVkjN8cwtZG/ZlY7Lshv1hiDYg+4nNjLfqES3Iz U5odm9B1GTlHQ5xvuF0UTNJMo40ovFEX8kkjsIVyJU3QqtuH+fEKng187vJLmnEkVNf3 bhKYv2cBJwJaYTN9pJEs+SEdUbTMP267rNi8F2MWl4bbO1DEIzInkO93XX7I62DGv+2q 39eNomwgFifZE5rehf+DH/CdJ3Ig7f5/jKxuYmGD3rziFYtu3QPVS/x0EQRu2FPvn0l2 ZbQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=yAlxNNXdaEbV2qnnJSgN6cLkcsUSiZ15OTd38v53xSg=; b=Wlmi3pYuYF5Mg0SVLmFeie503DKUkmEHUfbBAEo4oy3UqAP1c9hGWCETOwXK/73OcD Le0290zSV/fFlNjUuh1+H3QLyFWC9hZI4vqmDF/+FPU8XTt2HfYrSM6+mtGMo0ax90We P9HA7j+1oD7hGqJRxQAFymnuCZYd4XDYUcqMEIiqICv+kW0dzuI5a8iJ51ytUyk5DM/S lg/QeeAIc+JsztcCHhGCHB5lc+PEJKFIQcGUx1yJoHiIo/U8ZJwP/8Ox1W97vMGINkDT 06NMiFy5LwN6EVH1puhU+wgUPxTSC4gQKM0mQ2aWTft57u5k0FhV0i9Lvd6T4oOl1W/d N8rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vI4OJxSd; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m61-v6si3582452plb.63.2018.03.21.02.06.04; Wed, 21 Mar 2018 02:06:18 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vI4OJxSd; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751731AbeCUJEi (ORCPT + 99 others); Wed, 21 Mar 2018 05:04:38 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:41647 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751464AbeCUJEf (ORCPT ); Wed, 21 Mar 2018 05:04:35 -0400 Received: by mail-wr0-f194.google.com with SMTP id f14so4361241wre.8; Wed, 21 Mar 2018 02:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=yAlxNNXdaEbV2qnnJSgN6cLkcsUSiZ15OTd38v53xSg=; b=vI4OJxSdyA0GFYGb38nwqwMsIpDqh438U65qGiDANA/WtN7qjNYp95SN5zI9MWdfx5 gnOAB9q+KJNo+trE+NFQT+SjNzIIjd/oVlPnt0zQO0P8WarVutsQN3aXmTRoVUNdWSoX e8YWzJXBBTMMU+uNjBnYBfTHfqbkEwMhO6vykYNR0DM6Wa1rlGJmLp7iwcr24NI0ZuOV fBtKItKBF+93nwtlFmGmfVkhMg2EfkBGo/j8snZSfZ50P3kibZiwnSiCYNbuKZHn++Wz yOeHABzQ0bdya5k+/+7Gvjm/2V8lUswV7d97TgxEhHOoTq5EnN8XWwz/MD5eScuwun/n 9wbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=yAlxNNXdaEbV2qnnJSgN6cLkcsUSiZ15OTd38v53xSg=; b=YYVU3vA+sy1qzwFi/nB2DjGoOJr8GgmQhzi6fYoP/VE0p3BsyiFfaO8E7bxaWbVx+y qs3pRNBq5emdRdMMSnSU4GxjcckMrDfdSDygs+e16Afh3NAjzQQxIwnl2kIEkjPZWZQV Pa7v2Qgqg1MHV3Skrg5cl4VR3rJ91Zzt1EZljr3alPU6vU+b1qoczPpLIMH+CwJZiytT Uq4IifomXc+TCKmP8Zns8nwszvYnhyDVeTWU5rOXa8OhQyQ9fB+tneFmdMCPePx871d1 TTCg/9qADGl6GrHKMOvINxJt1waLX892kWUUTZ0Xqb3/JHObys0FpS7DvzKFjmO2blhw BWBA== X-Gm-Message-State: AElRT7ETvY0LYcsdtVqjQzuDuQQtF7QGZxDWl1S1FTvy/JgrbbDcnWDF 1e6/dy01BUKSWSge9N9/g+8= X-Received: by 10.223.157.194 with SMTP id q2mr1073123wre.125.1521623073569; Wed, 21 Mar 2018 02:04:33 -0700 (PDT) Received: from localhost.localdomain ([151.15.242.31]) by smtp.gmail.com with ESMTPSA id b9sm4177948wrh.68.2018.03.21.02.04.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Mar 2018 02:04:32 -0700 (PDT) Date: Wed, 21 Mar 2018 10:04:30 +0100 From: Juri Lelli To: Dietmar Eggemann Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Quentin Perret , Thara Gopinath , linux-pm@vger.kernel.org, Morten Rasmussen , Chris Redpath , Patrick Bellasi , Valentin Schneider , "Rafael J . Wysocki" , Greg Kroah-Hartman , Vincent Guittot , Viresh Kumar , Todd Kjos , Joel Fernandes Subject: Re: [RFC PATCH 4/6] sched/fair: Introduce an energy estimation helper function Message-ID: <20180321090430.GA6913@localhost.localdomain> References: <20180320094312.24081-1-dietmar.eggemann@arm.com> <20180320094312.24081-5-dietmar.eggemann@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180320094312.24081-5-dietmar.eggemann@arm.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 20/03/18 09:43, Dietmar Eggemann wrote: > From: Quentin Perret > > In preparation for the definition of an energy-aware wakeup path, a > helper function is provided to estimate the consequence on system energy > when a specific task wakes-up on a specific CPU. compute_energy() > estimates the OPPs to be reached by all frequency domains and estimates > the consumption of each online CPU according to its energy model and its > percentage of busy time. > > Cc: Ingo Molnar > Cc: Peter Zijlstra > Signed-off-by: Quentin Perret > Signed-off-by: Dietmar Eggemann > --- > kernel/sched/fair.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 81 insertions(+) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 6c72a5e7b1b0..76bd46502486 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6409,6 +6409,30 @@ static inline int cpu_overutilized(int cpu) > } > > /* > + * Returns the util of "cpu" if "p" wakes up on "dst_cpu". > + */ > +static unsigned long cpu_util_next(int cpu, struct task_struct *p, int dst_cpu) > +{ > + unsigned long util = cpu_rq(cpu)->cfs.avg.util_avg; What about other classes? Shouldn't we now also take into account DEADLINE (as schedutil does)? BTW, we now also have a getter method in sched/sched.h; it takes UTIL_EST into account, though. Do we need to take that into account when estimating energy consumption? > + unsigned long capacity = capacity_orig_of(cpu); > + > + /* > + * If p is where it should be, or if it has no impact on cpu, there is > + * not much to do. > + */ > + if ((task_cpu(p) == dst_cpu) || (cpu != task_cpu(p) && cpu != dst_cpu)) > + goto clamp_util; > + > + if (dst_cpu == cpu) > + util += task_util(p); > + else > + util = max_t(long, util - task_util(p), 0); > + > +clamp_util: > + return (util >= capacity) ? capacity : util; > +} > + > +/* > * Disable WAKE_AFFINE in the case where task @p doesn't fit in the > * capacity of either the waking CPU @cpu or the previous CPU @prev_cpu. > * > @@ -6432,6 +6456,63 @@ static int wake_cap(struct task_struct *p, int cpu, int prev_cpu) > return !util_fits_capacity(task_util(p), min_cap); > } > > +static struct capacity_state *find_cap_state(int cpu, unsigned long util) > +{ > + struct sched_energy_model *em = *per_cpu_ptr(energy_model, cpu); > + struct capacity_state *cs = NULL; > + int i; > + > + /* > + * As the goal is to estimate the OPP reached for a specific util > + * value, mimic the behaviour of schedutil with a 1.25 coefficient > + */ > + util += util >> 2; What about other governors (ondemand for example). Is this supposed to work only when schedutil is in use (if so we should probably make it conditional on that)? Also, even when schedutil is in use, shouldn't we ask it for a util "computation" instead of replicating its _current_ heuristic? I fear the two might diverge in the future. Best, - Juri