From patchwork Mon Apr 10 00:10:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 9671831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3B87E600CB for ; Mon, 10 Apr 2017 00:18:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C17A27FA8 for ; Mon, 10 Apr 2017 00:18:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2066527FBE; Mon, 10 Apr 2017 00:18:10 +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=-6.9 required=2.0 tests=BAYES_00,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 BA8A827F7F for ; Mon, 10 Apr 2017 00:18:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752744AbdDJASC (ORCPT ); Sun, 9 Apr 2017 20:18:02 -0400 Received: from cloudserver094114.home.net.pl ([79.96.170.134]:64026 "EHLO cloudserver094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752726AbdDJASB (ORCPT ); Sun, 9 Apr 2017 20:18:01 -0400 Received: from adkt186.ipv4.supernova.orange.pl (79.184.253.186) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.82) id ef6ccd9fbf308f62; Mon, 10 Apr 2017 02:17:59 +0200 From: "Rafael J. Wysocki" To: Linux PM Cc: Juri Lelli , LKML , Peter Zijlstra , Srinivas Pandruvada , Viresh Kumar , Vincent Guittot , Patrick Bellasi , Joel Fernandes , Morten Rasmussen Subject: [RFC/RFT][PATCH 1/2] cpufreq: schedutil: Use policy-dependent latency multupliers Date: Mon, 10 Apr 2017 02:10:46 +0200 Message-ID: <2407280.n9qVSLCrF5@aspire.rjw.lan> User-Agent: KMail/4.14.10 (Linux/4.11.0-rc4+; KDE/4.14.9; x86_64; ; ) In-Reply-To: <3498238.liCqOyIkGA@aspire.rjw.lan> References: <3498238.liCqOyIkGA@aspire.rjw.lan> MIME-Version: 1.0 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: Rafael J. Wysocki Make the schedutil governor compute the initial (default) value of the rate_limit_us sysfs attribute by multiplying the transition latency by a multiplier depending on the policy and set by the scaling driver (instead of using a constant for this purpose). That will allow scaling drivers to make schedutil use smaller default values of rate_limit_us and reduce the default average time interval between consecutive frequency changes. Make intel_pstate use the opportunity to reduce the rate limit somewhat. Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 1 + drivers/cpufreq/intel_pstate.c | 2 ++ include/linux/cpufreq.h | 8 ++++++++ kernel/sched/cpufreq_schedutil.c | 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) Index: linux-pm/drivers/cpufreq/cpufreq.c =================================================================== --- linux-pm.orig/drivers/cpufreq/cpufreq.c +++ linux-pm/drivers/cpufreq/cpufreq.c @@ -1072,6 +1072,7 @@ static struct cpufreq_policy *cpufreq_po init_waitqueue_head(&policy->transition_wait); init_completion(&policy->kobj_unregister); INIT_WORK(&policy->update, handle_update); + policy->latency_multiplier = LATENCY_MULTIPLIER; policy->cpu = cpu; return policy; Index: linux-pm/include/linux/cpufreq.h =================================================================== --- linux-pm.orig/include/linux/cpufreq.h +++ linux-pm/include/linux/cpufreq.h @@ -120,6 +120,14 @@ struct cpufreq_policy { bool fast_switch_possible; bool fast_switch_enabled; + /* + * Multiplier to apply to the transition latency to obtain the preferred + * average time interval between consecutive invocations of the driver + * to set the frequency for this policy. Initialized by the core to the + * LATENCY_MULTIPLIER value. + */ + unsigned int latency_multiplier; + /* Cached frequency lookup from cpufreq_driver_resolve_freq. */ unsigned int cached_target_freq; int cached_resolved_idx; Index: linux-pm/kernel/sched/cpufreq_schedutil.c =================================================================== --- linux-pm.orig/kernel/sched/cpufreq_schedutil.c +++ linux-pm/kernel/sched/cpufreq_schedutil.c @@ -530,7 +530,7 @@ static int sugov_init(struct cpufreq_pol goto stop_kthread; } - tunables->rate_limit_us = LATENCY_MULTIPLIER; + tunables->rate_limit_us = policy->latency_multiplier; lat = policy->cpuinfo.transition_latency / NSEC_PER_USEC; if (lat) tunables->rate_limit_us *= lat; Index: linux-pm/drivers/cpufreq/intel_pstate.c =================================================================== --- linux-pm.orig/drivers/cpufreq/intel_pstate.c +++ linux-pm/drivers/cpufreq/intel_pstate.c @@ -41,6 +41,7 @@ #define INTEL_PSTATE_HWP_SAMPLING_INTERVAL (50 * NSEC_PER_MSEC) #define INTEL_CPUFREQ_TRANSITION_LATENCY 20000 +#define INTEL_CPUFREQ_LATENCY_MULTIPLIER 250 #ifdef CONFIG_ACPI #include @@ -2237,6 +2238,7 @@ static int intel_cpufreq_cpu_init(struct return ret; policy->cpuinfo.transition_latency = INTEL_CPUFREQ_TRANSITION_LATENCY; + policy->latency_multiplier = INTEL_CPUFREQ_LATENCY_MULTIPLIER; /* This reflects the intel_pstate_get_cpu_pstates() setting. */ policy->cur = policy->cpuinfo.min_freq;