Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752208AbdGSGMc (ORCPT ); Wed, 19 Jul 2017 02:12:32 -0400 Received: from mail-oi0-f43.google.com ([209.85.218.43]:32805 "EHLO mail-oi0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751376AbdGSGMa (ORCPT ); Wed, 19 Jul 2017 02:12:30 -0400 MIME-Version: 1.0 In-Reply-To: <20170719053711.GA352@vireshk-i7> References: <20170716080407.28492-1-joelaf@google.com> <20170717080441.GM352@vireshk-i7> <20170718054558.GU352@vireshk-i7> <20170718140254.qfsxczbkvrcugrv3@e106622-lin> <20170719053711.GA352@vireshk-i7> From: Joel Fernandes Date: Tue, 18 Jul 2017 23:12:29 -0700 Message-ID: Subject: Re: [PATCH RFC v5] cpufreq: schedutil: Make iowait boost more energy efficient To: Viresh Kumar Cc: Juri Lelli , LKML , Patrick Bellasi , Andres Oportus , Dietmar Eggemann , Srinivas Pandruvada , Len Brown , "Rafael J . Wysocki" , Ingo Molnar , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2084 Lines: 46 On Tue, Jul 18, 2017 at 10:37 PM, Viresh Kumar wrote: > On 18-07-17, 15:02, Juri Lelli wrote: >> Mmm, seems to make sense to me. :/ >> >> Would the following work (on top of Joel's v5)? Rationale being that >> only in sugov_set_iowait_boost we might bump freq up (if no iowait_boost >> was set) or start from policy->min. In sugov_iowait_boost (consumer) >> instead we do the decay (if no boosting was pending). >> >> --- >> kernel/sched/cpufreq_schedutil.c | 29 +++++++++++++++++++---------- >> 1 file changed, 19 insertions(+), 10 deletions(-) >> >> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c >> index 46b2479641cc..b270563c15a5 100644 >> --- a/kernel/sched/cpufreq_schedutil.c >> +++ b/kernel/sched/cpufreq_schedutil.c >> @@ -171,8 +171,14 @@ static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time, >> { >> if (flags & SCHED_CPUFREQ_IOWAIT) { >> sg_cpu->iowait_boost_pending = true; >> - sg_cpu->iowait_boost = max(sg_cpu->iowait_boost, >> - sg_cpu->sg_policy->policy->min); >> + if (sg_cpu->iowait_boost) { >> + /* Bump up 2*current_boost until hitting max */ >> + sg_cpu->iowait_boost = max(sg_cpu->iowait_boost << 1, >> + sg_cpu->iowait_boost_max); > > And we are back at where we started :) > > This wouldn't work because sugov_set_iowait_boost() gets called a lot. > Maybe 10 times within a rate_limit_us period. > > The thumb rule is, never double/half the boost from > sugov_set_iowait_boost() :) Ok so tomorrow I'll post something slightly different. In sugov_iowait_boost, if the flag is set and current iowait_boost < min, then set it to min, otherwise double it. If the flag is not set, halve it. And both these would be done, *before* consuming the boost (as in Viresh's last patch). I think that's reasonable and handles all cases. Hopefully that will put it to rest, let me know if any objections. thanks, -Joel