Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1205180ybt; Wed, 24 Jun 2020 23:47:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMjoEL69BTOGByheNIAMUWEXxLJIcQyi6gVj97xWC9If3K1kbUaZdLvHXhR1aSpfXfg8v/ X-Received: by 2002:a17:906:1a54:: with SMTP id j20mr15948510ejf.455.1593067644889; Wed, 24 Jun 2020 23:47:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593067644; cv=none; d=google.com; s=arc-20160816; b=A+JaeWUopObLD6D7oDefeq88at5Ay+WV6+be3V+8X2k72jlXy5TXyx0F7r4b8tKrxI R6xoJRWhSGlm5borKthByfwYEWqam7yjH2b4xDyskZIdiA+OQS2GTa1YXzizZnUwOlt9 kUHjKHY3nv/9NcR1kEGWLVqkLSG8M/szSnLpSqorLkDt//SeyQCZWCAIbt5dHq5yBpa1 Jcc9JRkMBLTmONUn1Y8QkFuNrbPmlwKhjb6stjtZd23uCpBPU7sUuhjwUDm8h2qQHNnj RIE5xNtdn7XqG9CRoxI85auqrihr+ArkbBI/ruMhDsbddaL9ca2awKWP8Kg8KSdW7+Js 326A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:cc:from:subject:mime-version :message-id:date:dkim-signature; bh=9en45t/QzNaNM6uWfEIwyjVyBid8D5wBKicPYDDrGpo=; b=GTA6SW/iN7Dia7owBjMAsXeaObnBsDOw4ZSg7oogM1jNWF5E4O5EgwxW1tYBu8bfxA usQuvH3fBE0d2EmL7pbMcIvIBKpgpMbRVWi07KCcNc/SXau82n9787lE51TNR9EyunJl oWyqMoI/KZWR5WZuyP0/6/9CUOvAz8QRf1QDrf1sycmqReSpQsb2N0yEDnNR8Rv9doMm 9kcXs+ITb18dXekcBa87A3eEY/UYJ2/ALHdDKXF6+smeuWfN86D6KO8/IOme9gG4J5rO 095QTljDCMr4Xl4y8JAiFnTR21UMuIXxMlSBr+Jf91R8JfUH7l4VAuFPcfisJFo2q3Hm tfkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Gc4Yxt3I; 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 i12si2727939edj.491.2020.06.24.23.47.01; Wed, 24 Jun 2020 23:47:24 -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=Gc4Yxt3I; 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 S2390024AbgFYGqV (ORCPT + 99 others); Thu, 25 Jun 2020 02:46:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389962AbgFYGqU (ORCPT ); Thu, 25 Jun 2020 02:46:20 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C9E7C061573 for ; Wed, 24 Jun 2020 23:46:20 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id r17so4889610ybj.22 for ; Wed, 24 Jun 2020 23:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:cc; bh=9en45t/QzNaNM6uWfEIwyjVyBid8D5wBKicPYDDrGpo=; b=Gc4Yxt3I7/UcYTu0bsH1RFH6diu2RtYT0O5GLSOd5lrZmADKnymrdsOeLqV7AlTUZP djUwVJ5/iT8vzS/u1jfong1rtooTiqAFZsJNVZ/160i+YN93vacdCFS1xcNRwfGJX5np BfgeCY4eblYzBNNzloHFyKelqnmsz1OWakPsArY7nfTdJSHMhy1F0VirmZLWRc1m9LVu 5Rb/mm2BR1sZqZ1pSoqr2TPS/SUpYzn3FuzU74kQWex+UPMJZgn0FzjcI9WiuSuEwNNg TiZC21Nfi2SFU+LhECZz9cL8/tcQ4maAyHFNYis0t157qx0PFD3Ewl/A6us03VBPRj5u fv1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:cc; bh=9en45t/QzNaNM6uWfEIwyjVyBid8D5wBKicPYDDrGpo=; b=k1qf7R3DLc2LWvm8c4nhJlQuYo/+xaSSE1rAYBeZXXpWY/2n4ZWlWzv3shTCSrAU9l vNDFHZySP8o0VEMak2fFC5t6Q1aJ+WJO+GE8HIf1vpAoGtCJbMSwe32IZgmvaRb7p6aj tjrKU9DiG8z8PR/WekYhd2os2lAVtBFCzzY/Merc6bBCUHX/0UUEXb/xfQPsL4r0t/TA 9/mBX2kjMa2I4QWVZLO40o3/EJ6MPZ0xgCk1Aultheg6wJjV7dz0DUxgM3ea7vj+uMmU vczy2tyxxvDJ7akCSOcbx4PSzXEBsEdnmuOHkwskLyWPq5JQ0maDLc+64sBTH9pcRfXJ cVsw== X-Gm-Message-State: AOAM532GXXypNF8zSHTq8AJK/xQ1HzidpYhjPtSsiOOaoPe9qklfZTNz 8cUw7/agbhaS4HaWd4dguqiuW6E= X-Received: by 2002:a25:be05:: with SMTP id h5mr49833690ybk.131.1593067579604; Wed, 24 Jun 2020 23:46:19 -0700 (PDT) Date: Wed, 24 Jun 2020 23:46:14 -0700 Message-Id: <20200625064614.101183-1-wvw@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog Subject: [PATCH] cpufreq: schedutil: force frequency update when limits change From: Wei Wang Cc: wei.vince.wang@gmail.com, dsmythies@telus.net, viresh.kumar@linaro.org, Wei Wang , "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 Content-Type: text/plain; charset="UTF-8" To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ... 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. 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) 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