Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2529073imm; Mon, 10 Sep 2018 02:33:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYZOrjyDDWKeld9vCnBmwICel3KuvwbrLNfSZli5XAe7uQQsmMkfcrCjbDgpEkd9/O1FFDh X-Received: by 2002:a62:f555:: with SMTP id n82-v6mr22370665pfh.59.1536572027597; Mon, 10 Sep 2018 02:33:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536572027; cv=none; d=google.com; s=arc-20160816; b=bDD6TgdD1ooWng3pCCR3lIiDvH75AxIHNyOcV3sGd5/GYyArbeDW+Zj5VRdPswiRxA ppfAT31MnOWGJAJKLdYLuDoWndRdNWK1qjpFgv4MbZFAednNdN2bo+4vL+Imc0DNXMXI quhX5MAgkrs85EGTy8bmEr7gSD4UujzzLniTpJ0H3FwNYmxZPLR5/cnYFlCEzBc2TbtD s+z4W8i8p8iYxGqjE5luq+T3QIm8s2GKHXH43E77nB8/gSX7a4gUr90PwZmzAJu/y4jU M0LQ4u1EHwfruomYZppo31Z09TgBvsTjDjG25+xcVQvn47urM+/STKLK7MUQVLOPzfhH yYuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=c+uRr04sM5judOhWigkDpNujATpwPPq1wmBnm3lAz5M=; b=dnPayTNecM29kMih9BG4pWY5kUCST3XepYH37UVA2KFbT/W6NsiaG0trA+2+Fyh9k6 nayhBWW3gVXMCMENINfYlkN9KGHDmBufCTa1GG0g8AD6BK/iQ+XMAhtgIHFpTi8Vd2sq 2OzKsQQljuQTlJUKvzw/jJ2g8ADHonOLZ5Cd65jZUScHbFZXf3i3tE9p4R2WEpMUMPdM Bay0qetavVajccuJJdie5hZUsU9PZQuIyRaw8qlp/Yvvsr6FFlcQoTj3w4xT8akaarqp GVGrBJPZUx40EUyEwCHEVmVHlj+R41RCLjBAK8043s5adqWGcRzEpG5zEr95xfJUxjzG dw9g== 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 d10-v6si16406197pla.436.2018.09.10.02.33.32; Mon, 10 Sep 2018 02:33:47 -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 S1728037AbeIJOZO (ORCPT + 99 others); Mon, 10 Sep 2018 10:25:14 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:62502 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726148AbeIJOZO (ORCPT ); Mon, 10 Sep 2018 10:25:14 -0400 Received: from 79.184.255.178.ipv4.supernova.orange.pl (79.184.255.178) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.123) id 38a6200d9d1b09e6; Mon, 10 Sep 2018 11:32:04 +0200 From: "Rafael J. Wysocki" To: Quentin Perret Cc: peterz@infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, gregkh@linuxfoundation.org, mingo@redhat.com, dietmar.eggemann@arm.com, morten.rasmussen@arm.com, chris.redpath@arm.com, patrick.bellasi@arm.com, valentin.schneider@arm.com, vincent.guittot@linaro.org, thara.gopinath@linaro.org, viresh.kumar@linaro.org, tkjos@google.com, joel@joelfernandes.org, smuckle@google.com, adharmap@codeaurora.org, skannan@codeaurora.org, pkondeti@codeaurora.org, juri.lelli@redhat.com, edubezval@gmail.com, srinivas.pandruvada@linux.intel.com, currojerez@riseup.net, javi.merino@kernel.org Subject: Re: [PATCH v6 02/14] sched/cpufreq: Factor out utilization to frequency mapping Date: Mon, 10 Sep 2018 11:29:27 +0200 Message-ID: <1631407.Oe3rajKQQm@aspire.rjw.lan> In-Reply-To: <20180820094420.26590-3-quentin.perret@arm.com> References: <20180820094420.26590-1-quentin.perret@arm.com> <20180820094420.26590-3-quentin.perret@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, August 20, 2018 11:44:08 AM CEST Quentin Perret wrote: > The schedutil governor maps utilization values to frequencies by applying > a 25% margin. Since this sort of mapping mechanism can be needed by other > users (i.e. EAS), factor the utilization-to-frequency mapping code out > of schedutil and move it to include/linux/sched/cpufreq.h to avoid code > duplication. The new map_util_freq() function is inlined to avoid > overheads. There really is more to this change than it seems at the face value IMO, because the formula in question represents the policy part of the governor. Namely, it is roughly equivalent to the assumption that the governor will attempt to "stabilize" the "busy" time of the CPU at 80% of its total time (if possible for the given "raw" utilization and performance limits). If you take that formula into EAS, it will cause EAS to implicitly require the cpufreq governor to follow this assumption. Now, I know that you want to let EAS only work with the schedutil governor, which is consistent with the above, but the implicit assumption here should at least be documented somehow IMO. > Cc: Ingo Molnar > Cc: Peter Zijlstra > Signed-off-by: Quentin Perret > --- > include/linux/sched/cpufreq.h | 6 ++++++ > kernel/sched/cpufreq_schedutil.c | 3 ++- > 2 files changed, 8 insertions(+), 1 deletion(-) > > diff --git a/include/linux/sched/cpufreq.h b/include/linux/sched/cpufreq.h > index 59667444669f..afa940cd50dc 100644 > --- a/include/linux/sched/cpufreq.h > +++ b/include/linux/sched/cpufreq.h > @@ -20,6 +20,12 @@ void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data, > void (*func)(struct update_util_data *data, u64 time, > unsigned int flags)); > void cpufreq_remove_update_util_hook(int cpu); > + > +static inline unsigned long map_util_freq(unsigned long util, > + unsigned long freq, unsigned long cap) > +{ > + return (freq + (freq >> 2)) * util / cap; > +} > #endif /* CONFIG_CPU_FREQ */ > > #endif /* _LINUX_SCHED_CPUFREQ_H */ > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c > index 3fffad3bc8a8..f5206c950143 100644 > --- a/kernel/sched/cpufreq_schedutil.c > +++ b/kernel/sched/cpufreq_schedutil.c > @@ -13,6 +13,7 @@ > > #include "sched.h" > > +#include > #include > > struct sugov_tunables { > @@ -167,7 +168,7 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy, > unsigned int freq = arch_scale_freq_invariant() ? > policy->cpuinfo.max_freq : policy->cur; > > - freq = (freq + (freq >> 2)) * util / max; > + freq = map_util_freq(util, freq, max); > > if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update) > return sg_policy->next_freq; >