Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1273083imm; Fri, 11 May 2018 13:47:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoEwnO1H5G5u8uMkdHlGPq7McS7MJUBV7piJH/bnHaetHwQaRINLMblvPLJlfupEGm0btvA X-Received: by 2002:a17:902:704c:: with SMTP id h12-v6mr6913316plt.269.1526071678761; Fri, 11 May 2018 13:47:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526071678; cv=none; d=google.com; s=arc-20160816; b=fpahyg9hNG6X+jlOwuVvYMsZxW4agnwWETPaIspV8k9csWMkP74IJTXgpWSH/mU4JI aICl2R1/I1l6fK+Plk02SENlELzh/Z8AZkB+aXHtQaK20teOjMd0waN9iSdb6nzbmNn2 Jo4A2eOTBO/9hZYQ7KKJ9nRgChhDvySDmYI16GOm8OtLEpjQ1eVaUkM0TSh60x7+qPlF CUXyp5omFE53lNSk0RcIAdek4fomYtC3nMVxHcJfKuX3jxdfOirr9QKc463xJCqxNNHF Mglzke2XRb/g3Qco52bkFxH/BPa9pmrYTB/nN/ekyYKcUMzzVsfmmBb1Ks7Yy9KcPfx6 zp/A== 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=TDkhjmESMVxVNYbsDBZnuG9N47qIvrq8ukIPZp4ZQzw=; b=XqaucYgQ8hVyPXMrixiCSlRSx34R/mVcaLc4gEFLJ4CEgxvPuVJ4sZrJD4/Dwpsqdy YWxGe/qnoTkx8vToSfx8+AbNRlhucJbFIdGL6fsKfvsViobPBXXkkxvtuSQ3i2gxE9EB 3iSkrUvUzeAKxjfu7XSRQK8g3Ka+7m7VClasWoqYrf+cpVZ+Bb3zHaNW5jLNSH2EjhPw EQ9uqx0LbQG97COBqhK3ELcn72Aw9IOilvImRYisNdZsfkS82ESOdCChjNCRG2NFkYxp vYu40dYwGhB8LLOlmOGSHqaTwMknsOFekx67C0R5QYEmr/zXSGhJXlirlIu2WIPLV2EI Ufqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes-org.20150623.gappssmtp.com header.s=20150623 header.b=T1oBTczF; 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 z9-v6si3887416plo.263.2018.05.11.13.47.28; Fri, 11 May 2018 13:47:58 -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=@joelfernandes-org.20150623.gappssmtp.com header.s=20150623 header.b=T1oBTczF; 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 S1751373AbeEKUrQ (ORCPT + 99 others); Fri, 11 May 2018 16:47:16 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:39409 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751147AbeEKUrO (ORCPT ); Fri, 11 May 2018 16:47:14 -0400 Received: by mail-pl0-f65.google.com with SMTP id c19-v6so3898597pls.6 for ; Fri, 11 May 2018 13:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=TDkhjmESMVxVNYbsDBZnuG9N47qIvrq8ukIPZp4ZQzw=; b=T1oBTczFSHUem4pJP7AH75IO0QCrdaFo2+J0Bse0q49Cq8Z0fpMBt5qBZwxKb3y/8R ytb7nDhxlMt/Bs3w4B9w/Lg9mhXgp7JKpKbBzHXHh4YB5l5qkoHCFz/OknutxYmfbYZb mHS9ThwuQ+rzHULEMG48AeCzw+mSeScnRfQ/AcR5cjBjyxXR4y23+S0/BjqcXDi19kYS IOGaCSdY0HDGShSeW5R68WNG04zA6BSlAxOc9GzutqDACbnhFwqDtrL4WLfFiV1mVQZ8 pT91IQektH/epciPpnb7Hq8jdGRpI/qsWtvNKm7x/7pq6VAkPgbxdaczjR2bfV+hCKLX 5uiA== 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=TDkhjmESMVxVNYbsDBZnuG9N47qIvrq8ukIPZp4ZQzw=; b=dqF4nysknbw1NX4nGwuo3ucdPtV8jZXp0W0YZlqWlAlFKLp1gYKGVWiBWsBMPgqOXL R+Fz1qNOg8UX830/VV7qQyhBnN0ROUxQazJxnKrmY2Kt7h2cqsG7ljEcK2Zb7JFlN01f ftbmND4PbDhN6UrQLPurTMUp+fLVU+QdRrOZ6o3b8AEDR/1eIEuMtGIfH3En55NotFHR qRf7rZyM0GWCnxZ4wdFjUD5tn8v1yfMWZ8ziI9aGvikaVeTlUd0hOEaDuY0jx9UshyB6 4cA4QtBey51jCIx6W2cusKKuCYDRLi8Ugp5IHziX8OAm441EHTvoiRVjRrQKI9pFkAzP Kbyg== X-Gm-Message-State: ALKqPwdmTSCXyF1Zijk6meKSQXtul+S0yk7mVej2IuOHSaeoL4DddKbz inV4tTe0fwA0LMzeG+gcm3jtlOlhNoU= X-Received: by 2002:a17:902:2924:: with SMTP id g33-v6mr7008515plb.26.1526071633948; Fri, 11 May 2018 13:47:13 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id n18-v6sm11257219pfg.36.2018.05.11.13.47.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 May 2018 13:47:12 -0700 (PDT) Date: Fri, 11 May 2018 13:47:12 -0700 From: Joel Fernandes To: Viresh Kumar Cc: Rafael Wysocki , Ingo Molnar , Peter Zijlstra , linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org Subject: Re: [V2] sched/schedutil: Don't set next_freq to UINT_MAX Message-ID: <20180511204712.GA83958@joelaf.mtv.corp.google.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 On Wed, May 09, 2018 at 04:05:24PM +0530, Viresh Kumar wrote: > The schedutil driver sets sg_policy->next_freq to UINT_MAX on certain > occasions to discard the cached value of next freq: > - In sugov_start(), when the schedutil governor is started for a group > of CPUs. > - And whenever we need to force a freq update before rate-limit > duration, which happens when: > - there is an update in cpufreq policy limits. > - Or when the utilization of DL scheduling class increases. > > In return, get_next_freq() doesn't return a cached next_freq value but > recalculates the next frequency instead. > > But having special meaning for a particular value of frequency makes the > code less readable and error prone. We recently fixed a bug where the > UINT_MAX value was considered as valid frequency in > sugov_update_single(). > > All we need is a flag which can be used to discard the value of > sg_policy->next_freq and we already have need_freq_update for that. Lets > reuse it instead of setting next_freq to UINT_MAX. > > Signed-off-by: Viresh Kumar > --- > V2: > - Rebased over the fix sent by Rafael > > lkml.kernel.org/r/2276196.ev9rMjHTR0@aspire.rjw.lan > > - Remove the additional check from sugov_update_single() as well. > - This is for 4.18 now instead of stable kernels. Reviewed-by: Joel Fernandes (Google) (please note my email address change as well in your contact/address-book). thanks, - Joel > > kernel/sched/cpufreq_schedutil.c | 18 ++++++------------ > 1 file changed, 6 insertions(+), 12 deletions(-) > > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c > index e23e84724f39..daaca23697dc 100644 > --- a/kernel/sched/cpufreq_schedutil.c > +++ b/kernel/sched/cpufreq_schedutil.c > @@ -95,15 +95,8 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time) > if (sg_policy->work_in_progress) > return false; > > - if (unlikely(sg_policy->need_freq_update)) { > - sg_policy->need_freq_update = false; > - /* > - * This happens when limits change, so forget the previous > - * next_freq value and force an update. > - */ > - sg_policy->next_freq = UINT_MAX; > + if (unlikely(sg_policy->need_freq_update)) > return true; > - } > > delta_ns = time - sg_policy->last_freq_update_time; > > @@ -165,8 +158,10 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy, > > freq = (freq + (freq >> 2)) * util / max; > > - if (freq == sg_policy->cached_raw_freq && sg_policy->next_freq != UINT_MAX) > + if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update) > return sg_policy->next_freq; > + > + sg_policy->need_freq_update = false; > sg_policy->cached_raw_freq = freq; > return cpufreq_driver_resolve_freq(policy, freq); > } > @@ -305,8 +300,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, > * Do not reduce the frequency if the CPU has not been idle > * recently, as the reduction is likely to be premature then. > */ > - if (busy && next_f < sg_policy->next_freq && > - sg_policy->next_freq != UINT_MAX) { > + if (busy && next_f < sg_policy->next_freq) { > next_f = sg_policy->next_freq; > > /* Reset cached freq as next_freq has changed */ > @@ -671,7 +665,7 @@ static int sugov_start(struct cpufreq_policy *policy) > > sg_policy->freq_update_delay_ns = sg_policy->tunables->rate_limit_us * NSEC_PER_USEC; > sg_policy->last_freq_update_time = 0; > - sg_policy->next_freq = UINT_MAX; > + sg_policy->next_freq = 0; > sg_policy->work_in_progress = false; > sg_policy->need_freq_update = false; > sg_policy->cached_raw_freq = 0;