Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp106372ybt; Thu, 25 Jun 2020 16:35:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfeizxGN6qQPcSYcaSeT43/n7e/n2bm1zWSwAXViK7LqlJX4Sb3M2wndPsUZPoZpAH/ROr X-Received: by 2002:aa7:c2c5:: with SMTP id m5mr249050edp.214.1593128115978; Thu, 25 Jun 2020 16:35:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593128115; cv=none; d=google.com; s=arc-20160816; b=gYFQAkKOnfg9uMybbDEYPeYKO9/H/2XE/oaN3G4tD7e38AxpqXboLnpyWbjTYF1xOz MkhQPnAUWlNhsUHAuPTsybEdtkO4FcP7BabET87T39PMjbP27wjbrdZOCIztt0u+Lpm/ LDyWBAlEPXlJuo+Bjts+dgdNH38YoxWdfi+twnC7BpZnTfE+QGZE6GfTZQINNRSkPuUc xh9j2mKi1PKpM1AhcsUjHg6zCzBYUDeh4Y6cX7oMYj0jIWKp7Iitsb+0gv8cl2yAufwC tXwMEO43RUgpiL6uOE9GKJDpTtbMOd0XqIYG45ZCbJGLLVFUEOnu9VdAcYdPH1tbWwgU 0fHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Tn33QMHZ+qNx5YT7oVBhQ/nQOONeR57qMeYBaxKkSXo=; b=oivxMCvXFwRhW4+45kzVcrBOuHShA5F7e7DG+7tdR/h3GJ0GlgTeNocYiVFjULkFZQ AOa8NlQZrYQCW02UKnSpOOaB2yVgxSPjh3tILbwV1SJy8XjDxBiY3LdObG/j6NGsldKw pIlqPwnuHWhYfeT6IHfKptIzKr0oo7gs9gi6BMePmekena/EKs731UZAt5Ig+L9iCXHY s8X1Gif/H+bdEWkpMRPUPPFT7oBMgDifmgkSRX+ZOZ0bsSvwZarY9RLr8hfJ6a1D/9Dn qPmv5EQNAW9zjlTTk5L/Tzz3XFgSoczFKsmmBoww29VlZIb+pybRSoGHqpcgSp4ct5B+ cXEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ggd+eURO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d24si10777365ejb.602.2020.06.25.16.34.52; Thu, 25 Jun 2020 16:35:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ggd+eURO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405175AbgFYUsD (ORCPT + 99 others); Thu, 25 Jun 2020 16:48:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405077AbgFYUsC (ORCPT ); Thu, 25 Jun 2020 16:48:02 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A13FC08C5DB for ; Thu, 25 Jun 2020 13:48:02 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id d15so5272523edm.10 for ; Thu, 25 Jun 2020 13:48:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Tn33QMHZ+qNx5YT7oVBhQ/nQOONeR57qMeYBaxKkSXo=; b=Ggd+eURO6bXZrXb/VrO6+GxK6IB0ymlMRAjfKYtjDGfvFU0I0yzRD6yvgotEk3BWPf PGehawuwWuxJffh9+td9mlCHcAVUQNWj2ejefuznqGo8V+4g+wTK+ufuWOvYOvF38Sup 7nzPAtDMJb+KbyRYO0JXywstw/xOGIiXzZDlSixrgKtxcDWVHwPcShzNUeSjCkYWiKUd 2c9/E+zttHjji2yyoaRZ+fuMLDcTKrFh6AV3QLqK17VFBDK/HfnKPU/diOPh45NxYWre 62t3JyO6a9VOns7Ewz3MXGMCdE9+p4yl8BRtNzVIF3LHlDZSGqc89OP4BfMlGiedk6HO k2fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Tn33QMHZ+qNx5YT7oVBhQ/nQOONeR57qMeYBaxKkSXo=; b=LGVi9c9iNu9EoqTYELVa8yADghS1FD+8aJx+b5tp0Qg3Q2Mi4pOQ10h/shs0DufHGJ pXDjam+E0QGEDlkGzyPmnt/V6EpvZmdQbmCJowUhL3BrC9LY0WP4frfEkwwFc66QxbTV FZ4MKKBojpjQAghe6iC6wwIMMBnksUhBLXQXiU+aRoaDDUkz8Xl1j+V3UcipsaO6xXfE trH2126WQrmzN+2KYa93zGeWhXuULyjmm9PdqDj1ISo6u8tdkKLE/xwKnICdy10CZHXp Q4KhsUE+GNWsS572D2g2qfnNn9buK/uBApIq+gMSbS7DpavOvhZwZAInbQKqv3xJ3/nm BLmQ== X-Gm-Message-State: AOAM533FztyIymacczvvitPd5yQgPtB0dUKhqjQp53rpUU7YWI8a6blM HSTF1r7kpEeLjnQLFulqCXFhJLXYc533Rj8WxyDnBA== X-Received: by 2002:a50:e606:: with SMTP id y6mr28081edm.303.1593118080706; Thu, 25 Jun 2020 13:48:00 -0700 (PDT) MIME-Version: 1.0 References: <20200625064614.101183-1-wvw@google.com> <20200625102305.gu3xo4ovcqyd35vd@vireshk-i7> In-Reply-To: <20200625102305.gu3xo4ovcqyd35vd@vireshk-i7> From: Wei Wang Date: Thu, 25 Jun 2020 13:47:49 -0700 Message-ID: Subject: Re: [PATCH] cpufreq: schedutil: force frequency update when limits change To: Viresh Kumar Cc: Wei Wang , dsmythies@telus.net, "Rafael J. Wysocki" , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , "Joel Fernandes (Google)" , Linux PM list , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 25, 2020 at 3:23 AM Viresh Kumar wrote: > > On 24-06-20, 23:46, Wei Wang wrote: > > To avoid reducing the frequency of a CPU prematurely, we skip reducing > > the frequency if the CPU had been busy recently. > > > > This should not be done when the limits of the policy are changed, for > > example due to thermal throttling. We should always get the frequency > > within the new limits as soon as possible. > > > > There was a fix in > > commit 600f5badb78c ("cpufreq: schedutil: Don't skip freq update when > > limits change") upstream which introduced another flag. However, the > > fix didn't address the case when next_freq is the same as previously > > voted, which is then checked in sugov_update_next_freq. As a result, the > > frequency would be stuck at low until the high demanding workload quits. > > > > test trace: > > kworker/u19:0-1872 ( 1872) [002] .... 347.878871: cpu_frequency_limits: min=600000 max=2348000 cpu_id=6 > > dhry64-11525 (11525) [007] d.h2 347.880012: sugov_should_update_freq: thermal limit on policy6 > > dhry64-11525 (11525) [007] d.h2 347.880012: sugov_deferred_update: policy6 skipped update > > dhry64-11525 (11525) [007] d.h2 347.884040: sugov_deferred_update: policy6 skipped update > > I am not sure these are helpful in the logs as the code which > generated them isn't there in the kernel. > Yes, those traceprintk were added to those particular functions to help debug. > > ... > > > > This patch fixes this by skipping the check and forcing an update in > > this case. The second flag was kept as the limits_change flag could be > > updated in thermal kworker from another CPU. > > I am sorry but I am not fully sure of what the problem is. Can you > describe that by giving an example with some random frequency, and > tell the expected and actual behavior ? > The problem is sugov thought next_freq already updated (but actually skipped by the rate limit thing) and all following updates will be skipped. Actually this is specifically for Android common kernel 4.19's issue which has sugov_up_down_rate_limit in sugov_update_next_freq, let's continue discussion there. Thanks! -Wei > > Fixes: ecd288429126 ("cpufreq: schedutil: Don't set next_freq to UINT_MAX") > > Signed-off-by: Wei Wang > > --- > > kernel/sched/cpufreq_schedutil.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c > > index 7fbaee24c824..dc2cd768022e 100644 > > --- a/kernel/sched/cpufreq_schedutil.c > > +++ b/kernel/sched/cpufreq_schedutil.c > > @@ -102,11 +102,12 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time) > > static bool sugov_update_next_freq(struct sugov_policy *sg_policy, u64 time, > > unsigned int next_freq) > > { > > - if (sg_policy->next_freq == next_freq) > > + if (!sg_policy->need_freq_update && sg_policy->next_freq == next_freq) > > AFAIU, if the next freq is same as currently programmed one, there is > no need to force update it. > > > return false; > > > > sg_policy->next_freq = next_freq; > > sg_policy->last_freq_update_time = time; > > + sg_policy->need_freq_update = false; > > > > return true; > > } > > @@ -178,7 +179,6 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy, > > 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); > > } > > -- > > 2.27.0.212.ge8ba1cc988-goog > > -- > viresh