From patchwork Mon Oct 8 15:09:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waldemar Rymarkiewicz X-Patchwork-Id: 10630949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C995112B for ; Mon, 8 Oct 2018 15:11:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BE1A29782 for ; Mon, 8 Oct 2018 15:11:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 373FB2979D; Mon, 8 Oct 2018 15:11:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0D0F29782 for ; Mon, 8 Oct 2018 15:11:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726383AbeJHWXk (ORCPT ); Mon, 8 Oct 2018 18:23:40 -0400 Received: from mga05.intel.com ([192.55.52.43]:10653 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbeJHWXk (ORCPT ); Mon, 8 Oct 2018 18:23:40 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Oct 2018 08:11:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,357,1534834800"; d="scan'208";a="93292011" Received: from mucrsa0015.imu.intel.com ([10.62.163.98]) by fmsmga002.fm.intel.com with ESMTP; 08 Oct 2018 08:11:08 -0700 From: Waldemar Rymarkiewicz To: "Rafael J. Wysocki" , Viresh Kumar Cc: Waldemar Rymarkiewicz , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cpufreq: conservative: Fix requested_freq handling Date: Mon, 8 Oct 2018 17:09:00 +0200 Message-Id: <20181008150901.19667-1-waldemar.rymarkiewicz@gmail.com> X-Mailer: git-send-email 2.10.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Waldemar Rymarkiewicz The governor updates dbs_info->requested_freq only after increasing or decreasing frequency. There is, however, an use case when this is not sufficient. Imagine, external module constraining cpufreq policy in a way that policy->max = policy->min = max_available_freq (eg. 1Ghz). CPUfreq will set freq to max_freq and conservative gov will not try downscale/upscale due to the limits. It will just exit instead if (requested_freq > policy->max || requested_freq < policy->min) //max=min=1Ghz -> requested_freq=cur=1Ghz requested_freq = policy->cur; [...] if (requested_freq == policy->max) goto out; In a result, dbs_info->requested_freq is not updated with newly calculated requested_freq=1Ghz. Next, execution of update routine will use again previously stored requested_freq (in my case it was min_available_freq) [...] unsigned int requested_freq = dbs_info->requested_freq; [....] Now, when external module returns to previous policy limits that is policy->min = min_available_freq and policy->max = max_available_freq, conservative governor is not able to decrease frequency because stored requested_freq is still or rather already set to min_available_freq so the check (for decreasing) [...] if (load < cs_tuners->down_threshold) { [....] if (requested_freq == policy->min) goto out; [...] returns from routine before it does any freq change. To fix that just update dbs_info->requested_freq every time we go out from the update routine. Signed-off-by: Waldemar Rymarkiewicz --- drivers/cpufreq/cpufreq_conservative.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index f20f20a..7f90f6e 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c @@ -113,7 +113,6 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy) requested_freq = policy->max; __cpufreq_driver_target(policy, requested_freq, CPUFREQ_RELATION_H); - dbs_info->requested_freq = requested_freq; goto out; } @@ -136,10 +135,10 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy) requested_freq = policy->min; __cpufreq_driver_target(policy, requested_freq, CPUFREQ_RELATION_L); - dbs_info->requested_freq = requested_freq; } out: + dbs_info->requested_freq = requested_freq; return dbs_data->sampling_rate; }