Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3493434imu; Sun, 11 Nov 2018 16:21:03 -0800 (PST) X-Google-Smtp-Source: AJdET5c4TIUvpNFURQZd7WDT7VkqJHH6J6B3M5ps9qXkOflvcPjMQu6tbcSOCeQpcKSa1mpyHqmc X-Received: by 2002:a17:902:bccc:: with SMTP id o12-v6mr18160158pls.281.1541982063236; Sun, 11 Nov 2018 16:21:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541982063; cv=none; d=google.com; s=arc-20160816; b=DGCzXfV4To+RBLFMDPwOLvxOHwYn9IwQzej6a8SAmWW3f5nU/ae3uEXpZsMtYRBCXu HOQ4Lya5UgH2Yuksj0fTMlLIu3RfP3PxeeOHLg6e7ns5j1m7p/Avh2l9DhJozEQed5zA x2B5zvNZ+ATs872Dyby7eGXjwHNnWmIX6AsyBwMRA1Od9HDq7MQ97jdhPnGWWHfYNBju vwHi7NVMSqZYpxGrsXyjMrK3IIC6PoUCUKyeu2QNFjZi4pKCqV+JFOVb01McJF19p6Zx Ek1kmRPsSVN0VH2JXC4Mp2u/hhZ7/m5ZYEbZZIgvlfEn6VmztMB6y3+s15+BTPqg1ves iEkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0q00NAyCVkP3UZuBjXWNCUxSQi9E7C7NntcqnDtmhUM=; b=oWCjbp6siRGkawdnntupZTG3DceJvvfUHS3jDGmdnuTM900ciMopfdn1KwjiY/HWsl r5kjTkXUV/puJfE5x56/o+qQZ2vIF13BBj0SwzMXbfW6s/3uXpg3UYgxK1dIjxyWf8sp 3My+o5mGi0+KPZ0J37izZy7mucP2qlV481Xw4+pXd2F2rKLnk5t82mZluShLiRrNylJL IwXb/+FsnYybGLj+ejT1OXeAJCWFTnGnbbK0o6mkq68t+9MofuC1MlrdtIoLfHNHttDM 44ejovjTHxqwFsAIu/OKsmXCqHNj2Zg7VpMneTwsYpe2Aj49P03zYBwoWJYxHFs7p/cq GLEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GNfa69sE; 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 w65-v6si17789733pfd.55.2018.11.11.16.20.48; Sun, 11 Nov 2018 16:21:03 -0800 (PST) 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=@kernel.org header.s=default header.b=GNfa69sE; 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 S1729908AbeKLIQz (ORCPT + 99 others); Mon, 12 Nov 2018 03:16:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:58446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729859AbeKLIQy (ORCPT ); Mon, 12 Nov 2018 03:16:54 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8469C21104; Sun, 11 Nov 2018 22:26:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975219; bh=Dm+7vvDHL6yDavxr/GtmeoMgqkahksZQbaEboyzqNlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GNfa69sEjrootOowRlU8BHrUEEkrBZ3gx5CSsnZWdSMYu+XRzpFqmyJK4YVaUslfD ijs1Hb4KYPWxiTHE2ZbxYt5oq8J82U9gng1CM3qsNVasckk+C3Hep7DYdXZOUJcse/ 602ItzeeYr/62sHXAArWbOaTqBCr/Prp4UcnJy6E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Waldemar Rymarkiewicz , "Rafael J. Wysocki" , Viresh Kumar Subject: [PATCH 4.19 021/361] cpufreq: conservative: Take limits changes into account properly Date: Sun, 11 Nov 2018 14:16:08 -0800 Message-Id: <20181111221622.648784556@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rafael J. Wysocki commit da5e79bc70b84971d2b3a55fb252e34e51d81d48 upstream. If the policy limits change between invocations of cs_dbs_update(), the requested frequency value stored in dbs_info may not be updated and the function may use a stale value of it next time. Moreover, if idle periods are takem into account by cs_dbs_update(), the requested frequency value stored in dbs_info may be below the min policy limit, which is incorrect. To fix these problems, always update the requested frequency value in dbs_info along with the local copy of it when the previous requested frequency is beyond the policy limits and avoid decreasing the requested frequency below the min policy limit when taking idle periods into account. Fixes: abb6627910a1 (cpufreq: conservative: Fix next frequency selection) Fixes: 00bfe05889e9 (cpufreq: conservative: Decrease frequency faster for deferred updates) Reported-by: Waldemar Rymarkiewicz Cc: All applicable Signed-off-by: Rafael J. Wysocki Acked-by: Waldemar Rymarkiewicz Acked-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- drivers/cpufreq/cpufreq_conservative.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c @@ -80,8 +80,10 @@ static unsigned int cs_dbs_update(struct * changed in the meantime, so fall back to current frequency in that * case. */ - if (requested_freq > policy->max || requested_freq < policy->min) + if (requested_freq > policy->max || requested_freq < policy->min) { requested_freq = policy->cur; + dbs_info->requested_freq = requested_freq; + } freq_step = get_freq_step(cs_tuners, policy); @@ -92,7 +94,7 @@ static unsigned int cs_dbs_update(struct if (policy_dbs->idle_periods < UINT_MAX) { unsigned int freq_steps = policy_dbs->idle_periods * freq_step; - if (requested_freq > freq_steps) + if (requested_freq > policy->min + freq_steps) requested_freq -= freq_steps; else requested_freq = policy->min;