From patchwork Thu Nov 30 11:47:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Bellasi X-Patchwork-Id: 120147 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp558954qgn; Thu, 30 Nov 2017 03:48:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMaWgoH3aisVpk+WwsgiL59Ts1IRZ8zBh8bi0lyKpx0H8EeASEyLOYdiG3K4xJW6fYeRe7Vl X-Received: by 10.99.98.194 with SMTP id w185mr2130630pgb.396.1512042489617; Thu, 30 Nov 2017 03:48:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512042489; cv=none; d=google.com; s=arc-20160816; b=eQGfdhDhR+AXdpw08DO5sPUl2A81oCPuP4LvH7R2wQVyGgt8x0MweoKDBIo72DPtNr KqRmR7dDES/1gTVphq5wjex5qqLhjFSS6S5w6ZCcIaQ0W+UpmU6viUbv2UfnwAAE/m9a Oxxb14O7u59pF+VHmV2Rl1PsMwIhkrU/1ZZMyog3MUL9LmAEmPzsJY6Lbct/eT/HCQ3T RnXjMHLW6u1ZDOQZZr4sZNhOUjL3texWBfOjZPtq9PCVcB0UL79WuuRKP0tdlMYFtiSG Ri9xsmFLNx+B8JsPNXFF1tCK7apW9PNK9tLaZtUPd8y9EbvDDv+a3RAaxqDZ2priWFdJ AS5g== 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=BjJ8oB3JRB/NIRazP3uG8YmC0FTuQg55RQQyDhFyESY=; b=TdVo+QEPvKmLiYxo3IEfIiCM39wdCu+fIb82uwO0ghxZAakhWaAn3WSBXD6gK3ebjy yHMV9jLEdnJ5npwqAqaCiq616QlcIvKzGZ6wPJoXLKg2r4barYLXCGJgFmJRvPe4rKGk nWm/6S30y52EOR7FX3jG6aSoCu3h/vC4XqbVIdpYJgvGWB5sLMEwbrKyLzaAuJrr+cE3 Y6tVarUqUqUobYqaCctmkr1vFPLlde+4WzUzph763JWVupdGBdxPpWa4a+EIPqhcTmcA zQQDu97SL41gJemtf6nLt2xTfawUppsaqg3QmPBvVn6AKtFwrDT1w7X8G4u4UDE2IVwi OaWQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y16si2890133pgc.589.2017.11.30.03.48.09; Thu, 30 Nov 2017 03:48:09 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752726AbdK3LsH (ORCPT + 26 others); Thu, 30 Nov 2017 06:48:07 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:51314 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752659AbdK3LsD (ORCPT ); Thu, 30 Nov 2017 06:48:03 -0500 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 D0114164F; Thu, 30 Nov 2017 03:48:02 -0800 (PST) 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 998893F236; Thu, 30 Nov 2017 03:48:00 -0800 (PST) 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 , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes Subject: [PATCH v3 5/6] cpufreq: schedutil: relax rate-limiting while running RT/DL tasks Date: Thu, 30 Nov 2017 11:47:22 +0000 Message-Id: <20171130114723.29210-6-patrick.bellasi@arm.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171130114723.29210-1-patrick.bellasi@arm.com> References: <20171130114723.29210-1-patrick.bellasi@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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_util(). 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 Reviewed-by: Dietmar Eggemann 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 --- Changes from v2: - rebased on v4.15-rc1 Change-Id: I733d47b9e265cebb2e3e5e71a3cd468e9be002d1 --- kernel/sched/cpufreq_schedutil.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) -- 2.14.1 Reviewed-by: Juri Lelli diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 40521d59630b..3eea8884e61b 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -74,7 +74,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; @@ -111,6 +112,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; } @@ -268,11 +273,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 @@ -281,6 +281,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 { @@ -379,7 +384,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);