From patchwork Wed Jul 19 10:12:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 108259 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp664553obm; Wed, 19 Jul 2017 03:13:28 -0700 (PDT) X-Received: by 10.98.49.67 with SMTP id x64mr2331599pfx.22.1500459208198; Wed, 19 Jul 2017 03:13:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500459208; cv=none; d=google.com; s=arc-20160816; b=tBogeZi1coOhXYWSyKLBTpSPsD0cr+sDkkyonR5suRGFnK9OPez2WkF3VOUKYjxtOc sIo5LtQt64UpwMhQohMZgdXalQsmY3tydISbyodhUwkM5xiYA7K+q8IVbJqPlmsb3ZLM 5aRq8uI76YfHj6yABOd/fPTrVaTN0JPDxFpYsMN6FDxgZcsRobTu7h/8GKC/hxkL2h9T YG+7a9cKH7T6UNDeqlXXTnqs8LSKso/DT64MWUZAuX8Vv3n1uIEfwC+mxxRp7rb50czl 6sS/JFfTiwi8JA18VeJ4xN+QohRZQFt3sYffU345UfbsaybalNS7isfZs5lFVzSyQ0eB 1ltA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=6JQWWAPw3OgjMp6jQEqIs4Yl7udrFl5rkcFTz7cxYNw=; b=Y5k3nZkYZdaBr+DLh1c5Iy26pezBN+yLcBBA/S8OKGQGggLAbr9KB9ptuH3810pfBo HFulvMT7r3owvMjrray/fPUAhY140AvJesnzTWe0FTrNKg8Zv/IV8P3cVR8xt58bcgUs ASga4Y5pPvI5ADRoMJc0QKjIfvPD6XtfTnfM33lAfSpUseZ/NbGeRz2t41rRH1/gOKKx /QtCrRlsN1PywpLQnXVcH+jow7T+8MOyGCNB7lx39jyzOxU/4+6TnK3qnHThj8079RK8 sqpCg0VzdwxN+N05Tyh28ib0C+GEpY7kwncIl5stVuCUsFlJwNDRpz/PexJaC8w0xKby h+zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=Rcdz6vm9; 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; 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 n27si3922715pfa.146.2017.07.19.03.13.27; Wed, 19 Jul 2017 03:13:28 -0700 (PDT) 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=@linaro.org header.b=Rcdz6vm9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754246AbdGSKNX (ORCPT + 25 others); Wed, 19 Jul 2017 06:13:23 -0400 Received: from mail-pg0-f50.google.com ([74.125.83.50]:38815 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754126AbdGSKNS (ORCPT ); Wed, 19 Jul 2017 06:13:18 -0400 Received: by mail-pg0-f50.google.com with SMTP id s4so31813pgr.5 for ; Wed, 19 Jul 2017 03:13:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=6JQWWAPw3OgjMp6jQEqIs4Yl7udrFl5rkcFTz7cxYNw=; b=Rcdz6vm9V1DiLMsCH69Ig7vUU3Ud7Efmf/gpqRih5fU8hZO81HGm7tq7y5P1Vjfd0s sYMewr8ziUM+vbqTNJfykrN2W5Qi3XJiDhivBLea3qDEEraeE8RbNH1Fimtc+c3OQp4C MXZns1pBDrwCJsrOgYE3P1+yvQzYw/XcpFEnY= 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:in-reply-to :references:in-reply-to:references; bh=6JQWWAPw3OgjMp6jQEqIs4Yl7udrFl5rkcFTz7cxYNw=; b=ftKH9u5G/n9ZI86390p2YGY7XtEoOfvqmFKTCvRAgRw8tcRtoCRXbNHVESuE4G7Dxs 6PWYCifjWjDqcH+QS+VLJKaw4BG78pdhaS2DOEJlz+JamfBRFvqozuMpidH1Wx1Dj/c3 wR5BEX7UJkhvytq8VTo+HEep55QZlOB6BXvtS9ZYY5bSwafW0M2Zt+le8wY5EhhVYwgo U3yQAbwhpw+2oBYWnNaVrb39WYUmxIjijvcMGsSiviW1I9rImT4/i+VdZYVVHD6GUrXN GF1fKSd2A5fupy7+YmiMCg5NSGRdz9RX4MylWASgkHYHt8H+kmLlILVyRI6QfsELhLMa WthQ== X-Gm-Message-State: AIVw112XoV28oFvGcBTK8RQ1TkkF/8gFAckuV6os6+lBv31kNBumwsgW kyf4GfRUu2N0Izxo X-Received: by 10.98.65.76 with SMTP id o73mr2287270pfa.88.1500459197614; Wed, 19 Jul 2017 03:13:17 -0700 (PDT) Received: from localhost ([122.167.171.93]) by smtp.gmail.com with ESMTPSA id e131sm9705801pgc.64.2017.07.19.03.13.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jul 2017 03:13:17 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Ingo Molnar , Peter Zijlstra Cc: linux-pm@vger.kernel.org, Vincent Guittot , linux@dominikbrodowski.net, linux-kernel@vger.kernel.org Subject: [PATCH V3 2/9] cpufreq: Use transition_delay_us for legacy governors as well Date: Wed, 19 Jul 2017 15:42:42 +0530 Message-Id: <46734e7c365a024632e8b1d52990d4400899727b.1500373914.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.13.0.71.gd7076ec9c9cb In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The policy->transition_delay_us field is used only by the schedutil governor currently, and this field describes how fast the driver wants the cpufreq governor to change CPUs frequency. It should rather be a common thing across all governors, as it doesn't have any schedutil dependency here. Create a new helper cpufreq_policy_transition_delay_us() to get the transition delay across all governors. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 15 +++++++++++++++ drivers/cpufreq/cpufreq_governor.c | 9 +-------- include/linux/cpufreq.h | 1 + kernel/sched/cpufreq_schedutil.c | 11 +---------- 4 files changed, 18 insertions(+), 18 deletions(-) -- 2.13.0.71.gd7076ec9c9cb diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 9bf97a366029..c426d21822f7 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -524,6 +524,21 @@ unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy, } EXPORT_SYMBOL_GPL(cpufreq_driver_resolve_freq); +unsigned int cpufreq_policy_transition_delay_us(struct cpufreq_policy *policy) +{ + unsigned int latency; + + if (policy->transition_delay_us) + return policy->transition_delay_us; + + latency = policy->cpuinfo.transition_latency / NSEC_PER_USEC; + if (latency) + return latency * LATENCY_MULTIPLIER; + + return LATENCY_MULTIPLIER; +} +EXPORT_SYMBOL_GPL(cpufreq_policy_transition_delay_us); + /********************************************************************* * SYSFS INTERFACE * *********************************************************************/ diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 858081f9c3d7..eed069ecfd5e 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -389,7 +389,6 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *policy) struct dbs_governor *gov = dbs_governor_of(policy); struct dbs_data *dbs_data; struct policy_dbs_info *policy_dbs; - unsigned int latency; int ret = 0; /* State should be equivalent to EXIT */ @@ -428,13 +427,7 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *policy) if (ret) goto free_policy_dbs_info; - /* policy latency is in ns. Convert it to us first */ - latency = policy->cpuinfo.transition_latency / 1000; - if (latency == 0) - latency = 1; - - /* Bring kernel and HW constraints together */ - dbs_data->sampling_rate = LATENCY_MULTIPLIER * latency; + dbs_data->sampling_rate = cpufreq_policy_transition_delay_us(policy); if (!have_governor_per_policy()) gov->gdbs_data = dbs_data; diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 02aec384cab9..aaadfc543f63 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -523,6 +523,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, unsigned int relation); unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy, unsigned int target_freq); +unsigned int cpufreq_policy_transition_delay_us(struct cpufreq_policy *policy); int cpufreq_register_governor(struct cpufreq_governor *governor); void cpufreq_unregister_governor(struct cpufreq_governor *governor); diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 29a397067ffa..89c4dd9777bb 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -528,16 +528,7 @@ static int sugov_init(struct cpufreq_policy *policy) goto stop_kthread; } - if (policy->transition_delay_us) { - tunables->rate_limit_us = policy->transition_delay_us; - } else { - unsigned int lat; - - tunables->rate_limit_us = LATENCY_MULTIPLIER; - lat = policy->cpuinfo.transition_latency / NSEC_PER_USEC; - if (lat) - tunables->rate_limit_us *= lat; - } + tunables->rate_limit_us = cpufreq_policy_transition_delay_us(policy); policy->governor_data = sg_policy; sg_policy->tunables = tunables;