From patchwork Thu Jul 13 05:40:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 107541 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1780071qge; Wed, 12 Jul 2017 22:41:52 -0700 (PDT) X-Received: by 10.84.168.131 with SMTP id f3mr8225711plb.220.1499924512125; Wed, 12 Jul 2017 22:41:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499924512; cv=none; d=google.com; s=arc-20160816; b=gtP4l0Ll3e7PkDAOcXM+ge+gnzC3Vd2EnA0dUDc2WQ/kVdQOzCReJHRlWP6nDDiGuB J/FLs+iQgGORQOxPf3hlgJYvGEdnOIoAGfvo+UnaboZO5fJnnG9jS33llYf2uZlkAdY4 7ABAAwJBX9TK0+TZGDScKnelAGmsJttgsxKYhQromhQCOxMSezx0antjMY8wDmNG5cV7 85B+XDihNW8EjEX5Bnw8M8NDYK9SVmTJHDhx1f1TkxmCGy4YyamQjwlW8aNm3h00B+uc DgXlLLBr87NXDmiY47sokIEtIlkqU43oGqff4WG70w4eo1T+Ej018iDj6gNPdjb7b6c+ iWmg== 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=lxAlPCLsCl1wAUTWswkQxbWJ5P7uqsFJn8tkjMujtvc=; b=go6NZgmpGi8L86sM9UdOrCQnlH46Jke+53eQD6fcMpqok9ixFjBRkEfQCe6JYnpaGk dIHhi7+/YhVmLK864hTv9poDkybxsTH1WgqxuyotDDSOC/icjXD/1LMkEz+ggvnTWdbM JuCVcQ+blB70TNRQs+2dZOTPOfYNjyKgUB1J35iS87JTCt1dwYXxZE8LcSkgdDfDMuNz hvu3l4Pfo5QZTLTPSl0WAAWjHCVB43Ejrvmjb43VocIEf8HV9Qog/4X5PUiPG1bLqBiQ xiz2PKHCNKdWmV+ZDHbXutmdaLDOpvZsRhFAfa0SF16enbeX9Q4KyL5SqcWJ2fu2uQXO OPGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=J5nHhgMD; 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 q6si3490263pgq.8.2017.07.12.22.41.51; Wed, 12 Jul 2017 22:41:52 -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=J5nHhgMD; 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 S1751140AbdGMFlf (ORCPT + 25 others); Thu, 13 Jul 2017 01:41:35 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:33112 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750925AbdGMFld (ORCPT ); Thu, 13 Jul 2017 01:41:33 -0400 Received: by mail-pf0-f176.google.com with SMTP id e7so23992426pfk.0 for ; Wed, 12 Jul 2017 22:41:33 -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=lxAlPCLsCl1wAUTWswkQxbWJ5P7uqsFJn8tkjMujtvc=; b=J5nHhgMDkWyHvQUnina6TV8W5TFCbWyEtOFFMmZV98pRQiSy+MnRpX0GBsOKPBOabc hLWf69jxW5KjHdJy8rB5TCqkdRyA96RwLs7oX+vToA3zO4KVTKQLxrQ9OF2Upx3DHyXb o1hVcko2Lclh8OtoY2tVCa0NKEHsRGktwl9u8= 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=lxAlPCLsCl1wAUTWswkQxbWJ5P7uqsFJn8tkjMujtvc=; b=iHlvtS06mzHbwGVyOI8JY5qxsqXQtRoxZJIare4j/YY458zwKkvzTk9iW0rDtrG1lk OU23uNc4AmmaPDiqCmGB/V2NopDttw0qGAm89dN9M8tuclWdFLMLdtDsY7dKsazyyxO7 rWptixKFtTlFRP8EQ5/TbJSCTuTYEuhN8RbIa4ioSCHA2lr7Wkgog3LFqdY8Nt6ZQIQO gFee4AQ3ioWNg1nZxARvylyi5Gck127qD+NdlQGlGyj/h0AMUyAHBjAvFkS61DlJjAR1 0wZhZErByFijiasyL7ZJfZIr90Rj62DahecgI8sVswsewcrSqmnlkOFz3hHtTSMhLX8I cDQw== X-Gm-Message-State: AIVw113Bv6iewEtd0IrzNN5AD7IK5d4JVmqSqxM7m+OHQinPEp6NiaUp BQAVZOl38DnvELKT X-Received: by 10.84.133.226 with SMTP id f89mr8079563plf.11.1499924492504; Wed, 12 Jul 2017 22:41:32 -0700 (PDT) Received: from localhost ([122.171.81.230]) by smtp.gmail.com with ESMTPSA id k18sm7341790pgf.5.2017.07.12.22.41.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jul 2017 22:41:31 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar Cc: linux-pm@vger.kernel.org, Vincent Guittot , linux@dominikbrodowski.net, linux-kernel@vger.kernel.org Subject: [RFC V2 1/6] cpufreq: Replace "max_transition_latency" with "dynamic_switching" Date: Thu, 13 Jul 2017 11:10:52 +0530 Message-Id: <4b9ff9a3f546b2269ddb2da27c9e5be5f106a70f.1499853492.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 There is no limitation in the ondemand or conservative governors which disallow the transition_latency to be greater than 10 ms. The max_transition_latency field is rather used to disallow automatic dynamic frequency switching for platforms which didn't wanted these governors to run. Replace max_transition_latency with a boolean (dynamic_switching) and check for transition_latency == CPUFREQ_ETERNAL along with that. This makes it pretty straight forward to read/understand now. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 8 ++++---- drivers/cpufreq/cpufreq_governor.h | 2 +- include/linux/cpufreq.h | 9 ++------- 3 files changed, 7 insertions(+), 12 deletions(-) -- 2.13.0.71.gd7076ec9c9cb diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 9bf97a366029..dcef293c5e2c 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1988,13 +1988,13 @@ static int cpufreq_init_governor(struct cpufreq_policy *policy) if (!policy->governor) return -EINVAL; - if (policy->governor->max_transition_latency && - policy->cpuinfo.transition_latency > - policy->governor->max_transition_latency) { + /* Platform doesn't want dynamic frequency switching ? */ + if (policy->governor->dynamic_switching && + policy->cpuinfo.transition_latency == CPUFREQ_ETERNAL) { struct cpufreq_governor *gov = cpufreq_fallback_governor(); if (gov) { - pr_warn("%s governor failed, too long transition latency of HW, fallback to %s governor\n", + pr_warn("Transition latency set to CPUFREQ_ETERNAL, can't use %s governor. Fallback to %s governor\n", policy->governor->name, gov->name); policy->governor = gov; } else { diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index 0236ec2cd654..7b7839c45fba 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h @@ -160,7 +160,7 @@ void cpufreq_dbs_governor_limits(struct cpufreq_policy *policy); #define CPUFREQ_DBS_GOVERNOR_INITIALIZER(_name_) \ { \ .name = _name_, \ - .max_transition_latency = TRANSITION_LATENCY_LIMIT, \ + .dynamic_switching = true, \ .owner = THIS_MODULE, \ .init = cpufreq_dbs_governor_init, \ .exit = cpufreq_dbs_governor_exit, \ diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 905117bd5012..3d8c52b3b5df 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -487,14 +487,10 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, * polling frequency is 1000 times the transition latency of the processor. The * ondemand governor will work on any processor with transition latency <= 10ms, * using appropriate sampling rate. - * - * For CPUs with transition latency > 10ms (mostly drivers with CPUFREQ_ETERNAL) - * the ondemand governor will not work. All times here are in us (microseconds). */ #define MIN_SAMPLING_RATE_RATIO (2) #define LATENCY_MULTIPLIER (1000) #define MIN_LATENCY_MULTIPLIER (20) -#define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) struct cpufreq_governor { char name[CPUFREQ_NAME_LEN]; @@ -507,9 +503,8 @@ struct cpufreq_governor { char *buf); int (*store_setspeed) (struct cpufreq_policy *policy, unsigned int freq); - unsigned int max_transition_latency; /* HW must be able to switch to - next freq faster than this value in nano secs or we - will fallback to performance governor */ + /* For governors which change frequency dynamically by themselves */ + bool dynamic_switching; struct list_head governor_list; struct module *owner; }; From patchwork Thu Jul 13 05:40: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: 107543 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1780114qge; Wed, 12 Jul 2017 22:41:55 -0700 (PDT) X-Received: by 10.99.5.130 with SMTP id 124mr7436754pgf.51.1499924515280; Wed, 12 Jul 2017 22:41:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499924515; cv=none; d=google.com; s=arc-20160816; b=hdnjf7hMAP88IfRnbXIVOXht91EUvTX7wa3A6/8D48jYjBFgMu6rg9/j/GdQqYWc2l FCkwzxPhCTnhxgWWIXcuarHXjNs48Pi2PVC9Q/MOjvfhbyKtq4ZYe7q+VC/Atup1VBIa p6iHeSFNIa/kHREWHX0tG998rMfGjL3hr9o1Md2rQ7l3MnD2JAecD2LTOoyy0mNxQJ2W sTOIfwjvQTnPKlL6swWnqy341DoYL2ZJ5mSNBta7NAeXoxvq3HWnJHgmO8/8PWTbwX3e NTLw+Vmk2uhS3mo5hyc3sHyIznkkTuPlWT33/a89gT1zJasdrVFmO17F+hWk5iixlnKH hNvA== 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=fZFhdv4UgjIZaOVNkdCddKMuuvsYjBL6fiaiiiF+VZc=; b=J0BQ0u0xS2rhw7tRTyY770bCreyKcDqQerWoTy7KCAmqccVuONwjL5CEhanAQhbyUD HEZckct4YC81PleoAHNfZD0muRijm8RgcVbW47hLPgULShz6x9wu12Rxp5LC6BtLMNDD zXaPaIKjuQNswzTdDJNb4FeX6vc+0F8o5GtSCUa9sApmtYpKDeVwOwtXkT4KRT7vA/aB TsmA3N0X/dY7YNo/Ub5Q6LUoXHpWOu9L7tHaEB7YmYFrTa2GEzVYqvJayefT46LXsLlC RT0tDzk+T1WBoK/UO6KZv/0eeT8eqJ5ECMmhQsjURexJDJQvWpEgLkd9ABcsDGLJQR2t TJVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=Fy7BPdYK; 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 q6si3490263pgq.8.2017.07.12.22.41.53; Wed, 12 Jul 2017 22:41:55 -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=Fy7BPdYK; 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 S1751191AbdGMFlu (ORCPT + 25 others); Thu, 13 Jul 2017 01:41:50 -0400 Received: from mail-pg0-f47.google.com ([74.125.83.47]:35390 "EHLO mail-pg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751168AbdGMFlr (ORCPT ); Thu, 13 Jul 2017 01:41:47 -0400 Received: by mail-pg0-f47.google.com with SMTP id j186so24051748pge.2 for ; Wed, 12 Jul 2017 22:41:42 -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=fZFhdv4UgjIZaOVNkdCddKMuuvsYjBL6fiaiiiF+VZc=; b=Fy7BPdYK9DbnDL9wWB0htBcmlq4EIejR0kdXkF5fSOdev8fJTTOwdEjRR1ZkWowN0P J01BKf6HeMjRwHXNy9A32CoN6HRVxtCLRwPg1iVUx7I1YFGt7bcNQZTBSmGko+vj0nAh uEf3KtA79AuPjBGo2lWIet1lc/qvrOYhpU8lQ= 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=fZFhdv4UgjIZaOVNkdCddKMuuvsYjBL6fiaiiiF+VZc=; b=M3L/SZ1GtLWSIlpri5kxdwfcg+3M+QB0LiLA40eDtXmJMknfKHKOG3jPg+xGr9paWX VihuNbsXk2sTWUq/jBQACHMJ6kWH1SbskQnXd65Z/6F4hlHijDdEo+333Zd9mjkBwfnR pkU5CE4MEIV5nACnySWJ5hEllL3kubuF8vYEX+hbK0b17MC+zu1nOPh2+Olo9mKFLzfV 6hsCmF4RGkmfgMj+U9c41ACcIXQRSUaOek+EqAOovO3Nt5sDE9hOUXopTKtKwli3fZpc YgGd1ZW4gRjUi1cAG9LCDeT/ncvYX2MnoFmw7gnrGOheMCtvamN9ETpk/cQVbItWShYP VkWw== X-Gm-Message-State: AIVw111Z/+ku8+G+LwoRI5hLa4pVtBheH2jcAJq4QI7XVJLaMT1V/K5f pf9UmnpPHmTenGF6 X-Received: by 10.99.165.82 with SMTP id r18mr7657344pgu.65.1499924501748; Wed, 12 Jul 2017 22:41:41 -0700 (PDT) Received: from localhost ([122.171.81.230]) by smtp.gmail.com with ESMTPSA id w190sm8983293pgb.30.2017.07.12.22.41.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jul 2017 22:41:41 -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: [RFC V2 4/6] cpufreq: Use transition_delay_us for legacy governors as well Date: Thu, 13 Jul 2017 11:10:55 +0530 Message-Id: <2b3bfd2566ecaa0635c29a49c110e16803f80db0.1499853492.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_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 00e4c40a3249..14f0ab61ed17 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -532,6 +532,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 ab9d7a1b43dc..5c72c569ec2f 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;