From patchwork Wed Nov 8 14:53:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 118269 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1893957edm; Wed, 8 Nov 2017 06:54:08 -0800 (PST) X-Google-Smtp-Source: ABhQp+QoBhSG698ypaZDGTjMaurIIhgtygnyLKtVInr0Mu4sWUldq1G3bmyTTFznOKwS28O/hKFL X-Received: by 10.84.194.1 with SMTP id g1mr694365pld.394.1510152848023; Wed, 08 Nov 2017 06:54:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510152848; cv=none; d=google.com; s=arc-20160816; b=F89Hg7eD3pbqawNU1qms+oQD2Pjf4/wPi7OnwQSzfyORT/vv5TVx+IUvnEnstHzgVb u9cTU4mIwPzZHlBocnosRO1z0XIONywUWekvkNAEb5mb/gKhLJYAKp48exSp7JaB3xp0 ACf2zR2ujOl6uY6yKfTXN2RdR42wzza1NxcknYT22y/bJ+KxpC9llZvQg4bgj1HKgY/4 pk/janD6Y9KScaGWWW0qFX6zCeqprUtU0bLDRLVOs9Y4hfbqapRpnaVOCO6wcHrtVsQb ijA8PD/zt2rmRV46CnHgs/34Ygl1sowZpUHjgq6w0D5AchjIRZ8rA3SBnd8t1L3V9oFe eOzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=PBBNkVnfAOG68Ib2EMZRHTwRxjNQ7EaCzf0yCmtUwHY=; b=duIG5gZhlCGHUA0GfejrKvq58Vm4OrFjOXFbDg0Gb9QkUxSW3JgpDOVWnQcNYX/vwF SfrdxQ6n1obYYMiH6vpPmX2/BVw1o1FuitNwZzXAGdQBja3/Rj3duIjFFFjdVZlE7tdy q9HvTUTce5l7G2WBlNbOmABpSQFEwevxqkJAEJ/GG82ZxauS/uEpE3hhiI+MqxYc0NYO usIIbMRpw37ON2/EBsKUZ4lB4U7iWHdzh4qcogk8GQ4yIanqv8fFk8lNypFD5Y5Dr87h gwpC8lgI6hATNLrHo5mpZ1JtoQzbY1uaa3LDLdJZf0cXNdPqjlh+pBobN3JVDh3EU0S1 lo3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CDEFwLTN; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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. [209.132.180.67]) by mx.google.com with ESMTP id w6si4119258pgc.681.2017.11.08.06.54.07; Wed, 08 Nov 2017 06:54:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b=CDEFwLTN; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 S1752537AbdKHOyG (ORCPT + 9 others); Wed, 8 Nov 2017 09:54:06 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:43588 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752361AbdKHOyF (ORCPT ); Wed, 8 Nov 2017 09:54:05 -0500 Received: by mail-pg0-f66.google.com with SMTP id s75so2048017pgs.0 for ; Wed, 08 Nov 2017 06:54:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=PBBNkVnfAOG68Ib2EMZRHTwRxjNQ7EaCzf0yCmtUwHY=; b=CDEFwLTNI30gfZKX4OKfHdPSjeZla71Rhm+eikWfhKfDQLYlqysgasNHNMfktVC+mI OE4WXA+U7IwhnuBu2wnCOt/Rorc+oShpIrA3oT66iXKxJ/5QmFYDC3UDT0DkmZ0QTjav OS3CkRC960y5ErnOqoBEQPIYIhkGfw+dlUWCE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PBBNkVnfAOG68Ib2EMZRHTwRxjNQ7EaCzf0yCmtUwHY=; b=qOrFGnCSc5BheGxJ2GrsUnqIOnaJY1sZuY67lTEmvZhZBT3uNbEQKiAKcFN6L5fsKy TVZvAvcmZi8ZWQVdb0UfLydXsiFnXWlIM6aqawyiKcxGJlQyvYr5ITORgSESZp1rMNAf K9cef1ALOQAwOOHfgOhl/XxkLJDP4m54LyJweqVwuelW5vJg0gVHSrnn/azLOupyh9RV qMiOK2lKfjQ9T9PxycFxGaEzJPgcJyjGkn0O7Lit0SaLlyChL7ohHuTq2LpZyYF8s5PH l9WkRk5l2vpWGjn9dhV2YNIIxQA+OtMDuNyEu3pfY6m2yR8FopMqN1nR89IjGbcFYVBb VmFg== X-Gm-Message-State: AJaThX6qlTu45kWmsR9ZILMQkuZSyKlSJHdpy/+1r3OieprNBYzaN4Vm 4oFHMCUeqvPOXD0Uuhxtbm4tpg== X-Received: by 10.84.241.5 with SMTP id a5mr672071pll.81.1510152844620; Wed, 08 Nov 2017 06:54:04 -0800 (PST) Received: from localhost ([122.172.219.3]) by smtp.gmail.com with ESMTPSA id p17sm7530686pgc.66.2017.11.08.06.54.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Nov 2017 06:54:03 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Ingo Molnar , Peter Zijlstra Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , stable@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] schedutil: Reset cached freq if it is not in sync with next_freq Date: Wed, 8 Nov 2017 20:23:55 +0530 Message-Id: <2897534536b2506cbdbd5f8ace6f1c2dcdad189d.1510152832.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.rc1.236.g92ea95045093 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 'cached_raw_freq' is used to get the next frequency quickly but should always be in sync with sg_policy->next_freq. There is a case where it is not and in such cases it should be reset to avoid switching to incorrect frequencies. Consider this case for example: - policy->cur is 1.2 GHz (Max) - New request comes for 780 MHz and we store that in cached_raw_freq. - Based on 780 MHz, we calculate the effective frequency as 800 MHz. - We then see the CPU wasn't idle recently and choose to keep the next freq as 1.2 GHz. - Now we have cached_raw_freq is 780 MHz and sg_policy->next_freq is 1.2 GHz. - Now if the utilization doesn't change in then next request, then the next target frequency will still be 780 MHz and it will match with cached_raw_freq. But we will choose 1.2 GHz instead of 800 MHz here. Change-Id: I71bd31a1b59d27c26c0b4885301e4ba6155c2c51 Cc: # 4.12 Fixes: b7eaf1aab9f8 ("cpufreq: schedutil: Avoid reducing frequency of busy CPUs prematurely") Signed-off-by: Viresh Kumar --- kernel/sched/cpufreq_schedutil.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.15.0.rc1.236.g92ea95045093 diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index ba0da243fdd8..2f52ec0f1539 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -282,8 +282,12 @@ 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) + if (busy && next_f < sg_policy->next_freq) { next_f = sg_policy->next_freq; + + /* Reset cached freq as next_freq has changed */ + sg_policy->cached_raw_freq = 0; + } } sugov_update_commit(sg_policy, time, next_f); }