From patchwork Tue Jul 4 17:34:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Bellasi X-Patchwork-Id: 107007 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1251187qge; Tue, 4 Jul 2017 10:34:53 -0700 (PDT) X-Received: by 10.84.131.162 with SMTP id d31mr17563375pld.16.1499189693133; Tue, 04 Jul 2017 10:34:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499189693; cv=none; d=google.com; s=arc-20160816; b=PvhuYRm44Dq+VIDmms2ZLOeHtcESAHORbWPbrAthOzBzR9JTZYiAsX4sg7taQ49OSK TeNDhZX7RPJoM1CkrdORAJeLPnGysMG8MCKmHdlq2aTEKxahr9MBoOInoLUcCPpzeOHe iNEERJaslRrhOIKiudu7QatCHPU0ansiwkdUnoAW1Yne7nZ+44O6Uk8I7J5lZhWP1Hro cLeS2ODDVq8nwYTmNjeaQjlmr4BlA90uh8fPqqMTUz2i1bbNb2Zvle9kbLeJOBvYKrpI 2hTj0MFZ/bsn2bsShXNwRUa46Kw8x+0mWp9OGKd36kO9If88rVoIhY8eIJj9so6D9tp8 gJiw== 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:message-id:date :subject:cc:to:from:arc-authentication-results; bh=zpj7BBxoFHeA7scAiKUNN0TAoUotUCjDc/LIIh1WZvg=; b=BKVzIP5D6mFfT5Ovva9I1WmyJ4popEtcSvleWPE97e6jFpzWArOq+q2spxccHjdb9t +KvTAo3KaO9yUcAMPamjbJ8BBntW7i2IGe1eZPH6PqgCfMxU2VRlHjSI203tLSTlFfjl rtCidwOx40WtjGbPb66vg4Xv4E0F5/qBp5NydOVcEpq/eym7kF4M7sxNFEqGjtAxI1VH DZaj8pF/psQMq9vLk95u5uUm5+03gUdjJEYOp6yX8DgRzIMeu2PZXZeuQtDZbF5mK4P8 XkgWqlCJ0eOSfLGvvEVV6M8LzdYUQgtT7DpDIR3vFzG19GmCJkzNLURnAJseJvGg9gRw SiPA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s1si16073408plj.439.2017.07.04.10.34.52; Tue, 04 Jul 2017 10:34:53 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752408AbdGDRet (ORCPT + 14 others); Tue, 4 Jul 2017 13:34:49 -0400 Received: from foss.arm.com ([217.140.101.70]:48184 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752395AbdGDRes (ORCPT ); Tue, 4 Jul 2017 13:34:48 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 47572165D; Tue, 4 Jul 2017 10:34:37 -0700 (PDT) Received: from e110439-lin.cambridge.arm.com (e110439-lin.cambridge.arm.com [10.1.210.68]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 28AD23F41F; Tue, 4 Jul 2017 10:34:35 -0700 (PDT) From: Patrick Bellasi To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , "Rafael J . Wysocki" , Viresh Kumar , Vincent Guittot , Juri Lelli , Joel Fernandes , Andres Oportus , Todd Kjos , Morten Rasmussen , Dietmar Eggemann Subject: [PATCH v2 6/6] cpufreq: schedutil: relax rate-limiting while running RT/DL tasks Date: Tue, 4 Jul 2017 18:34:11 +0100 Message-Id: <1499189651-18797-7-git-send-email-patrick.bellasi@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499189651-18797-1-git-send-email-patrick.bellasi@arm.com> References: <1499189651-18797-1-git-send-email-patrick.bellasi@arm.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The policy in use for RT/DL tasks sets the maximum frequency when a task in these classes calls for a cpufreq_update_this_cpu(). However, the current implementation is still enforcing a frequency switch rate limiting when these tasks are running. This is potentially working against the goal to switch to the maximum OPP when RT tasks are running. In certain unfortunate cases it can also happen that a RT task almost completes its activation at a lower OPP. This patch overrides on purpose the rate limiting configuration to better serve RT/DL tasks. As long as a frequency scaling operation is not in progress, a frequency switch is always authorized when running in "rt_mode", i.e. the current task in a CPU belongs to the RT/DL class. Signed-off-by: Patrick Bellasi Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Rafael J. Wysocki Cc: Viresh Kumar Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org --- kernel/sched/cpufreq_schedutil.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index df433f1..7b1dc7e 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -72,7 +72,8 @@ static DEFINE_PER_CPU(struct sugov_cpu, sugov_cpu); /************************ Governor internals ***********************/ -static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time) +static bool sugov_should_update_freq(struct sugov_policy *sg_policy, + u64 time, bool rt_mode) { s64 delta_ns; @@ -89,6 +90,10 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time) return true; } + /* Always update if a RT/DL task is running */ + if (rt_mode) + return true; + delta_ns = time - sg_policy->last_freq_update_time; return delta_ns >= sg_policy->freq_update_delay_ns; } @@ -226,11 +231,6 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, sugov_set_iowait_boost(sg_cpu, time, flags); sg_cpu->last_update = time; - if (!sugov_should_update_freq(sg_policy, time)) - return; - - busy = sugov_cpu_is_busy(sg_cpu); - /* * While RT/DL tasks are running we do not want FAIR tasks to * overvrite this CPU's flags, still we can update utilization and @@ -239,6 +239,11 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, rt_mode = task_has_dl_policy(current) || task_has_rt_policy(current) || (flags & SCHED_CPUFREQ_RT_DL); + if (!sugov_should_update_freq(sg_policy, time, rt_mode)) + return; + + busy = sugov_cpu_is_busy(sg_cpu); + if (rt_mode) { next_f = policy->cpuinfo.max_freq; } else { @@ -336,7 +341,7 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, sugov_set_iowait_boost(sg_cpu, time, flags); sg_cpu->last_update = time; - if (sugov_should_update_freq(sg_policy, time)) { + if (sugov_should_update_freq(sg_policy, time, rt_mode)) { next_f = rt_mode ? sg_policy->policy->cpuinfo.max_freq : sugov_next_freq_shared(sg_cpu, time);