From patchwork Thu Jun 29 10:59:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 106631 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp4554517obb; Thu, 29 Jun 2017 04:00:20 -0700 (PDT) X-Received: by 10.84.231.131 with SMTP id g3mr8580079plk.176.1498734020770; Thu, 29 Jun 2017 04:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498734020; cv=none; d=google.com; s=arc-20160816; b=TnPFoRYtpCp0oH40GMG7Tsn0Sbvbxs6PiS25WycGjOl7d+hsvY6sT8wyXMEteBd5rI 4sdf3ZWTZ47KGdbt4xkKVE1h4CzoyjNgF1qQy7eLbhueTEOpFBm65Bbqg1mDT67hFwbi a/Df9r04xuH90hUB1KRbjw1efiIobjDcKUoxtx60Dg3JLrhSTIMCQjn69sR4GBPrXvZB lBO87dq3dUQ3M8sLh963F5ctMCuD2+Dqnl8GMyzutnXsx1U6ZbLLAge4sfYsGa0KqSQL NEY6MLnj26fGKV1fRbtjOTV9dfJVFPrN/r10jWg92aUAeD7Q8tSz+jkAQ9/zCyjA0ijW bRIg== 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=hFl0al/TBsLP+Sq+C2OlskkhJVMU1+PVxYPlO9xb75c=; b=yUO7YYcx50BmYwHGqhNaDWWhCErC0jVMeo01ReDnxTdOZONjp2bnG3TrZFbj0P/PxC D3ZQ6cPfJ+NmpGhIB5MdbFKK3ChSxpURuW6vmUOVwfZvX2kt2NjWKSMaNsEdnQA9a/tJ /Kzk9lWWSbgCiJ6vsAqp1bTXCtTLqZeI6TmVVuGkOFe7PRQalU+3mN1Oalb9z282CPF/ MgeF+yMzqiwVT7o/zjss9FNvi3ZlU1tUWMbkrHTl422xB7qaDgoFKKpfeLns+drBTfHz 4K94l8NqVF81B/yiCBnqMONFsCaxubQh0f2fho2BqH/wvqdi8kBxHCZHdkXYbA8jaMIJ myQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=BDbiGWG3; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 73si4037945pld.428.2017.06.29.04.00.20; Thu, 29 Jun 2017 04:00:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=BDbiGWG3; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1752562AbdF2LAL (ORCPT + 14 others); Thu, 29 Jun 2017 07:00:11 -0400 Received: from mail-pg0-f52.google.com ([74.125.83.52]:35561 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752670AbdF2K71 (ORCPT ); Thu, 29 Jun 2017 06:59:27 -0400 Received: by mail-pg0-f52.google.com with SMTP id j186so46254435pge.2 for ; Thu, 29 Jun 2017 03:59:27 -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=hFl0al/TBsLP+Sq+C2OlskkhJVMU1+PVxYPlO9xb75c=; b=BDbiGWG3h6zxd6DD2cT7DK7QJsDaIF59PJPjjtRESZOhcBbW/j9cQTq6/0f6EUdqSR sAPLoObPNbj3KxbNDhX7xIN6XM3yrAktgh3e58mqjZ91Evt68K+JzYoLXMMCk+GUlupo v4Sn1jg98nLuszXXGJ+4NBj4lYkjDbDDVALbk= 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=hFl0al/TBsLP+Sq+C2OlskkhJVMU1+PVxYPlO9xb75c=; b=SoWp0KpK5HTEjriBHzOIw1xKp+PECmzeES0698j6IrPkKzO5V8/3GTV+QITFtgojOJ NdnBuP7tPMbyfRsiNofhXgHJwEEmvs/QRzIZxcQnMWaSITEKngONFGVTVS4H2GM/YqNB /rIyqOjLI3DPw9opAKz2u6TqTwP6HfY7vhfkZKlM9V0tybt01cneWeWWqOsALUtdf87Z 70pcjmuLxjXgytFK1SdK8/gLsueGWU6xJsSQNrrDRBktomTmsQc4lJ/5klySVrXWnizT m+eBgVJMh1wWbAgI+yFMY9ckWIoYU84dAuoXoqu8qLNsDe46WZpm0VhA/+RcRSLmj5wU n+kQ== X-Gm-Message-State: AKS2vOwgschTX8uFSfkIRgK5FtzEY39fF6cvPanP06X1EqRpu5d5gvHq +rUqGgFhtjNGd0xk X-Received: by 10.98.10.153 with SMTP id 25mr2755890pfk.200.1498733966380; Thu, 29 Jun 2017 03:59:26 -0700 (PDT) Received: from localhost ([122.171.238.149]) by smtp.gmail.com with ESMTPSA id k194sm7678857pgc.31.2017.06.29.03.59.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 03:59:25 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Ingo Molnar , Peter Zijlstra Cc: linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 4/6] cpufreq: Use transition_delay_us for legacy governors as well Date: Thu, 29 Jun 2017 16:29:07 +0530 Message-Id: <157b6fdb97615e47126fcad7d7bc40370ed672f0.1498733506.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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The policy->transition_delay_us field is used only by the schedutil governor currently, but it should rather be a common thing across all governors. 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_governor.c | 9 +-------- include/linux/cpufreq.h | 15 +++++++++++++++ kernel/sched/cpufreq_schedutil.c | 11 +---------- 3 files changed, 17 insertions(+), 18 deletions(-) -- 2.13.0.71.gd7076ec9c9cb 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 083e7f3c23dd..dee6fe3d8af0 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -529,6 +529,21 @@ static inline void cpufreq_policy_apply_limits(struct cpufreq_policy *policy) __cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L); } +static inline unsigned int +cpufreq_policy_transition_delay_us(struct cpufreq_policy *policy) +{ + unsigned int delay_us = LATENCY_MULTIPLIER, latency; + + if (policy->transition_delay_us) + return policy->transition_delay_us; + + latency = policy->cpuinfo.transition_latency / NSEC_PER_USEC; + if (latency) + delay_us *= latency; + + return delay_us; +} + /* Governor attribute set */ struct gov_attr_set { struct kobject kobj; diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 076a2e31951c..3bdec2a08e1e 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;