Received: by 10.192.165.148 with SMTP id m20csp4745708imm; Tue, 8 May 2018 13:41:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrfkriM4NdJg17qVbP+Ate8HuFskZ0BVja9z1UY9uZcAe7KqDz6KvL4B9DSUGTW4LKgP/wq X-Received: by 2002:a17:902:7446:: with SMTP id e6-v6mr23733263plt.369.1525812112844; Tue, 08 May 2018 13:41:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525812112; cv=none; d=google.com; s=arc-20160816; b=X9BW4iqDJvybTNhq4cohXDo2RazcwNDdBufjfm7JDpAEoitgnjJ1NWSjYpKGtB1MGV d1hVfaonmr4xaWj5ZdfF7TQBd8VDyyUHn2r/iRjHtdua8Wj3pzUxzMASqUsKa9PUQyT+ wBaTD3ulLb6IUpakiqEL/Cr/SthNoC9RNXQO7y8ujDiREtg1mZqf85uLSGWIZ4z3YK83 eoGCzjk3AHf20Q3ekw975cJsrcm1RvT+KDWAfJh8r2k1f0pdpV99V8ocViRAF46i4OF0 NQVNNm6UxRqsocY2OP2oxbeWmHgjy32zS0m5fblXU73S4Y5t9iv99zwMV5Brnm+e5aMv x09w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=/YDul42p3khrSc9BmPH50w/3WmWLV5FzPAG7lS7fnk0=; b=ax+I3JN7oerU/N69tAPSe+SURV1hwqWq77j4eUBpgbsx6L0hOPr80KigNp2//W7hqS taQtq+emKfVsTypmn9w354/Vmg3m8DhER18whL0mCxMMASAWIo1ukcxwvzW24JGrzCwp 95ZeGj+6qs+BXE92Bq7uUxsxaTQLJChz/hWhU53g6O5wIgZxPuNJE1wGiT+W0yfUVqAw 8L3CbaAqswn8Q+RiUtiN2wRncYhQzyeGTxnMxaXB8HXbjZNt6N+vm06HZKLmr3bvNuAg 42oj9+KtBjRFR8RhQG4qD1i4YzavTAH/ziHiw/9dzkuGLQuae+UUZ3kJ510pGUBC7XJW Rs9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XIm1eXkn; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z24-v6si19787654pgn.55.2018.05.08.13.41.37; Tue, 08 May 2018 13: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=fail header.i=@gmail.com header.s=20161025 header.b=XIm1eXkn; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755661AbeEHUkG (ORCPT + 99 others); Tue, 8 May 2018 16:40:06 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:36881 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755029AbeEHUkE (ORCPT ); Tue, 8 May 2018 16:40:04 -0400 Received: by mail-oi0-f66.google.com with SMTP id w123-v6so20600329oia.4; Tue, 08 May 2018 13:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=/YDul42p3khrSc9BmPH50w/3WmWLV5FzPAG7lS7fnk0=; b=XIm1eXknKfg+Orf59HQCBiHIZ00qrm2hRMmPPYbgPGgsM6KKZlW8ys6skkBoXHk9jT S+fVHCST8Dj4N19kCh8+Dj4Cwsb+q7cyXKxi5mvosVTrsSY/Ob/FQb+MYNm/d3zyOjc2 xhnh/I0oBT/hQ3Uv6l0GJANZjG50YB6OR1macw8aaA/RFyL2tixv/ZccpVI7qYRPOBcQ WKLe2oEVh1hb0Fbg72MfAREmX1SSsR/FNtvWQPQ/Kse8jBCCDkTiWVq0xgTsYIvlD17s 10kQM9tufoPKwYsM1+cR8zsFpZU3cNEjc/dKdKRrEgl+16jko0jywi7QTWGqVHkDr5Sg ykUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=/YDul42p3khrSc9BmPH50w/3WmWLV5FzPAG7lS7fnk0=; b=ssi1ceDkjATmVSRynvBez1mjt6ZsdIOfuS4RgUx5meb8wUYbi4nUV3IRIe2GtP+HqT ehi7cLblvTxts6jPdgq3+HNUe5nnhOOujW9o0wqMBlyBJ45BwjFkg9PSzl3WE2b2xAvu YLk7B+gvnhVPfQqPuXxb9tBTW2g1A2ERrMQgKox0dkdRjVjZvwNeIMPMCePPb0ULSWNt jjCG3Iljr1unhDIoydADysuqIo1luAxXJlaIxXxmHrhMIF0ghoTdtqizlusBvLAmn1jK jI48JuMuszcYZhKBGfvu3/XwgOF7DFIlR40gU04Grmdv/E+jrxK9VkKWq9KwqAfetFGG ZC1w== X-Gm-Message-State: ALQs6tB9YbQKZt1PSVV4x6T9gYXJhb8bAJieOPte42DA5cYwSTSuOu/x bENpS/vcMVqfE7YdEfGvtgKfKSCJX3NZN+XYmxk= X-Received: by 2002:aca:1107:: with SMTP id 7-v6mr28191570oir.116.1525812004191; Tue, 08 May 2018 13:40:04 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:1468:0:0:0:0:0 with HTTP; Tue, 8 May 2018 13:40:03 -0700 (PDT) In-Reply-To: References: <1525704215-8683-1-git-send-email-claudio@evidence.eu.com> <20180508065435.bcht6dyb3rpp6gk5@vireshk-i7> From: "Rafael J. Wysocki" Date: Tue, 8 May 2018 22:40:03 +0200 X-Google-Sender-Auth: fqCsWhLKfu2avRnyaQbZnVSekTs Message-ID: Subject: Re: [RFC PATCH] sched/cpufreq/schedutil: handling urgent frequency requests To: Claudio Scordino Cc: Viresh Kumar , Linux Kernel Mailing List , "Rafael J . Wysocki" , Peter Zijlstra , Ingo Molnar , Patrick Bellasi , Juri Lelli , Luca Abeni , Joel Fernandes , Linux PM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 8, 2018 at 2:32 PM, Claudio Scordino wrote: > > > Il 08/05/2018 08:54, Viresh Kumar ha scritto: >> >> On 07-05-18, 16:43, Claudio Scordino wrote: >>> >>> At OSPM, it was mentioned the issue about urgent CPU frequency requests >>> arriving when a frequency switch is already in progress. >>> >>> Besides the various issues (physical time for switching frequency, >>> on-going kthread activity, etc.) one (minor) issue is the kernel >>> "forgetting" such request, thus waiting the next switch time for >>> recomputing the needed frequency and behaving accordingly. >>> >>> This patch makes the kthread serve any urgent request occurred during >>> the previous frequency switch. It introduces a specific flag, only set >>> when the SCHED_DEADLINE scheduling class increases the CPU utilization, >>> aiming at decreasing the likelihood of a deadline miss. >>> >>> Indeed, some preliminary tests in critical conditions (i.e. >>> SCHED_DEADLINE tasks with short periods) have shown reductions of more >>> than 10% of the average number of deadline misses. On the other hand, >>> the increase in terms of energy consumption when running SCHED_DEADLINE >>> tasks (not yet measured) is likely to be not negligible (especially in >>> case of critical scenarios like "ramp up" utilizations). >>> >>> The patch is meant as follow-up discussion after OSPM. >>> >>> Signed-off-by: Claudio Scordino >>> CC: Viresh Kumar >>> CC: Rafael J. Wysocki >>> CC: Peter Zijlstra >>> CC: Ingo Molnar >>> CC: Patrick Bellasi >>> CC: Juri Lelli >>> Cc: Luca Abeni >>> CC: Joel Fernandes >>> CC: linux-pm@vger.kernel.org >>> --- >>> kernel/sched/cpufreq_schedutil.c | 20 ++++++++++++++++++-- >>> 1 file changed, 18 insertions(+), 2 deletions(-) >>> >>> diff --git a/kernel/sched/cpufreq_schedutil.c >>> b/kernel/sched/cpufreq_schedutil.c >>> index d2c6083..4de06b0 100644 >>> --- a/kernel/sched/cpufreq_schedutil.c >>> +++ b/kernel/sched/cpufreq_schedutil.c >>> @@ -41,6 +41,7 @@ struct sugov_policy { >>> bool work_in_progress; >>> bool need_freq_update; >>> + bool urgent_freq_update; >>> }; >>> struct sugov_cpu { >>> @@ -92,6 +93,14 @@ static bool sugov_should_update_freq(struct >>> sugov_policy *sg_policy, u64 time) >>> !cpufreq_can_do_remote_dvfs(sg_policy->policy)) >>> return false; >>> + /* >>> + * Continue computing the new frequency. In case of >>> work_in_progress, >>> + * the kthread will resched a change once the current transition >>> is >>> + * finished. >>> + */ >>> + if (sg_policy->urgent_freq_update) >>> + return true; >>> + >>> if (sg_policy->work_in_progress) >>> return false; >>> @@ -121,6 +130,9 @@ static void sugov_update_commit(struct sugov_policy >>> *sg_policy, u64 time, >>> sg_policy->next_freq = next_freq; >>> sg_policy->last_freq_update_time = time; >>> + if (sg_policy->work_in_progress) >>> + return; >>> + >>> if (policy->fast_switch_enabled) { >>> next_freq = cpufreq_driver_fast_switch(policy, >>> next_freq); >>> if (!next_freq) >>> @@ -274,7 +286,7 @@ static inline bool sugov_cpu_is_busy(struct sugov_cpu >>> *sg_cpu) { return false; } >>> static inline void ignore_dl_rate_limit(struct sugov_cpu *sg_cpu, >>> struct sugov_policy *sg_policy) >>> { >>> if (cpu_util_dl(cpu_rq(sg_cpu->cpu)) > sg_cpu->util_dl) >>> - sg_policy->need_freq_update = true; >>> + sg_policy->urgent_freq_update = true; >>> } >>> static void sugov_update_single(struct update_util_data *hook, u64 >>> time, >>> @@ -383,8 +395,11 @@ static void sugov_work(struct kthread_work *work) >>> struct sugov_policy *sg_policy = container_of(work, struct >>> sugov_policy, work); >>> mutex_lock(&sg_policy->work_lock); >>> - __cpufreq_driver_target(sg_policy->policy, sg_policy->next_freq, >>> + do { >>> + sg_policy->urgent_freq_update = false; >>> + __cpufreq_driver_target(sg_policy->policy, >>> sg_policy->next_freq, >>> CPUFREQ_RELATION_L); >> >> >> If we are going to solve this problem, then maybe instead of the added >> complexity and a new flag we can look for need_freq_update flag at this >> location >> and re-calculate the next frequency if required. > > > I agree. > Indeed, I've been in doubt if adding a new flag or relying on the existing > need_freq_update flag (whose name, however, didn't seem to reflect any sense > of urgency). > Maybe we can use need_freq_update but change its name to a more meaningful > string ? Implicitly, it means "as soon as reasonably possible".