Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1326460ybt; Thu, 25 Jun 2020 03:26:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypsdGJAJy5Cieyu7TJDqb6ttS7OuaxHOzDK+zIszAPRcUupgdor+Lftq991Glrr9dn79Ep X-Received: by 2002:a17:907:a92:: with SMTP id by18mr12639371ejc.116.1593080795346; Thu, 25 Jun 2020 03:26:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593080795; cv=none; d=google.com; s=arc-20160816; b=QYemZCxb951R8HQ7suX0pIjstUppVM1toyGz/ymQNLR/aqPbg+HVOPIpnhZjBx2ukb +duYJT/4mp3hdakwAnw+hRQ3824i/PjfBQj93EcTXYqms0qNIIiZ2fycFJQUP0cJfnuF eWUPni9I3tlEKBbptS3x0goaOmTaWAAvgogrD6Z+iMq+Clxj/C7b95LxxwHAsnm2aqeA LtDBvNHTqT9nG14Pfp5BdemJPNH6JfWJXkglbnJiZQAjHLt046BXiqOk6nVWAlDOd7W8 BYkKBr8Q+SBbri4r2YMZgQGfd/+S/Qj5e64KYoite67am8bsmxfVJXaC7G9qu6uimIMN 0jFw== 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; bh=aD0Mm08bVawc8uNEZ8jOYlVBKSND1d88I7GODmq3fsk=; b=ykTdOWudRkDp7WuxPZ06zHaXezlfXb0wJPlbnKdZduU2p2IimvxuW6zD7y/lUOMLBp RmgitHYdkwdvfIbToEiGcby9rpDAenoefGSlV1N3zt7STv11b1ZfJoMKygezSS/4pppG 7jkO391mPq+cL1lODzWBJanjYITy9cTRjeCYljGhkyzXI59ZGZE1iOUJ9B6gZJNKh0hP 3EMBm9HL0Wio3vogx1eh2IIOOwy4St8pAzcdPBnWbqvJQlEA2fP29uY4auYFljSc4+Pt cP1CVnXCFFGsQ6IN/UMLbCBOSBetibICbaxR9ZgyLGxnG6MQYYfd3nFBju1brZc+sTa1 32jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ubk1Hqqi; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z9si14327413ejm.47.2020.06.25.03.26.11; Thu, 25 Jun 2020 03:26:35 -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=@linaro.org header.s=google header.b=ubk1Hqqi; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404012AbgFYKYP (ORCPT + 99 others); Thu, 25 Jun 2020 06:24:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403899AbgFYKXI (ORCPT ); Thu, 25 Jun 2020 06:23:08 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97BF3C061573 for ; Thu, 25 Jun 2020 03:23:08 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id l63so3074094pge.12 for ; Thu, 25 Jun 2020 03:23:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=aD0Mm08bVawc8uNEZ8jOYlVBKSND1d88I7GODmq3fsk=; b=ubk1HqqiONXNwRyZOSAqaegZ688nbffSZAhNPWm5ubGgemju0MhV7Zj+Qw0nPU2Kr4 ymfAXK71pWR5Q0VooRWKs2fi5wA3sCheKoM7d9I64mgi3UdQEAYRmKhwMGarOGxnJsUv 5SSUGfPO3q7yVF5xhRnPNvPocbDqKEM2Lp4AZYSSIAJJlgmG4d3nDchw2oncY3HZ9LOR 4tyxLyAnWh0oWIhRtt9kB2dodpKcxX+zgs5A3B/FYyB8BTPBpQEgdfBW3nMoOsZwoCKr /7FSSntstxKukbfkBRLkjswV/ZwYBQ7A8y0mZpDbzrf4Xp9k20mT4GJhbPjc78m3I15a LtNQ== 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=aD0Mm08bVawc8uNEZ8jOYlVBKSND1d88I7GODmq3fsk=; b=g+wIn9tWAvQQeAqev6Yce2+wdZ4hu2RSJBntGzTfhm+gFrWf6hmNTV83X1ItJYfbdb Zu8xk2Z8X5Pb4XalI2ljQrBcEmv2plJiQI1ijLuPxMQlArC/4PKqf6I6vLpK/LnNb1bd Ems3GKBraQCPa8Q1bkIvQf7gVQFB38B8gOV4xQH3ztrVgEHUNYFzHyITTW1eRZx4/Szq 1dnVjzMsRcWeTaAU+DxTELM/2Qyxnz6bfDSmymtPsLzUiQ35Pcm5Fc3chnIOZXdMvjKH fME+Ue5r0/GqLi+dkEa3Mawy61NNrVxjni8sK041zLh9s3xIkL7KLbq3NDnFQ6xUIQ0R A85Q== X-Gm-Message-State: AOAM531nzwDoE5KlSK0c64qdF76/0FMJTPZe6kwfh5QtAJkBCBfIgnFV QEKrzXcxhNdgAGDzQfBsrUmCdw== X-Received: by 2002:a63:7f17:: with SMTP id a23mr19440822pgd.3.1593080587955; Thu, 25 Jun 2020 03:23:07 -0700 (PDT) Received: from localhost ([122.172.111.76]) by smtp.gmail.com with ESMTPSA id 4sm19566182pgk.68.2020.06.25.03.23.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jun 2020 03:23:07 -0700 (PDT) Date: Thu, 25 Jun 2020 15:53:05 +0530 From: Viresh Kumar To: Wei Wang Cc: wei.vince.wang@gmail.com, 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@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] cpufreq: schedutil: force frequency update when limits change Message-ID: <20200625102305.gu3xo4ovcqyd35vd@vireshk-i7> References: <20200625064614.101183-1-wvw@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200625064614.101183-1-wvw@google.com> User-Agent: NeoMutt/20180716-391-311a52 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > ... > > 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 ? > 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