Received: by 10.192.165.148 with SMTP id m20csp4246286imm; Tue, 8 May 2018 05:33:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZohwBaHPmfmeTNCZ8mQmSFLfKoIb18gzyzHqv9FU867tp2yPlbhyhfsvIVsAPpjCfKN1K8U X-Received: by 10.98.13.151 with SMTP id 23mr40223289pfn.231.1525782791121; Tue, 08 May 2018 05:33:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525782791; cv=none; d=google.com; s=arc-20160816; b=EjNKSeEQvkGhn9gJ4Pcsx1BzHkmQQSgzbbqfud2VGVrZKopJmAOWemGGk7BeimyQre wjt9gEoZU9HK6jCTQrfJsneibU4d5Wt4Nkl5zrkGMVMpKYTluhEZBCV1cuYLQeB88tuk fDmBihG1C3C1D4SoTMDezmn5rt/6R54amnZ+QnH+rijs1Pn5L9+L+tA3ivqfgYIGC/hv 0tCJosq/qR79d19RnY2D7arOYhC2n22XVAOj7+Sjfiu03z3YtsWsZcveT2CEuHhe/TNs nBaFtMzhQK3luGLw5h68MPo9v6h/d5o6wL3Mk7QQK7Ok/R3K86yOfbTVzYJpA+FyXz6y zs9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=tz3ZQBhpETWvEW1lpF7J6Ap/uRs8k2c7CZWNJeXtFio=; b=nYsFsf8fBNyoHTCJsw8dar4ZU/6bCDNEd1WL13xvTZpPBZJBVPVEYYzOYPglnR27PH kiDCIiovRv1JogSxcy6Ykpx817hKMUx82kY9m1l6AKZbZF+aEal9opFTAHAScbaKgFrn HA1/YiM8P9If36iXtBzENN4kCCd1P7Kpgf6dSdSYTVIO7xQxcnhWXakNmqYlvd5+6BXw oXxxwpTaIPpO2+Cz43gxuXpMs/5UU3tj/KUpi8kUeS2PP0Q81PB/tF9Ate4Ce85wKIrz QI/EL3bhW0XBXqVDBs2ZvFAruH3qVvq4Kc3hEVlqNNKFvoTI9OLMMRBK85j6XrLnSWHQ YLgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@evidence-eu-com.20150623.gappssmtp.com header.s=20150623 header.b=S3EFKYhA; 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 x4-v6si19015117pgc.411.2018.05.08.05.32.55; Tue, 08 May 2018 05:33:11 -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=@evidence-eu-com.20150623.gappssmtp.com header.s=20150623 header.b=S3EFKYhA; 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 S1754815AbeEHMcZ (ORCPT + 99 others); Tue, 8 May 2018 08:32:25 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:39794 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751917AbeEHMcX (ORCPT ); Tue, 8 May 2018 08:32:23 -0400 Received: by mail-wr0-f193.google.com with SMTP id q3-v6so32123811wrj.6 for ; Tue, 08 May 2018 05:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=evidence-eu-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=tz3ZQBhpETWvEW1lpF7J6Ap/uRs8k2c7CZWNJeXtFio=; b=S3EFKYhAi39ouhI0IezFZmQyO5FfZQaGl9yHBZ2w+Pc+edcekOlYw6lrB9q+rndN2J Q/k5Es8Bo/Wstx50a5vLTb9b1bOWahINdTp6OKcBZbysu1jWctISGkR+4talEozUU6na 1LWFCCPqCVCgdh4EDB6Kc8IvDYAHvV1JwCRF+CLkIL/lKltzU4VR/LjsVJYYMc9wHYE2 Uo294JDNx6jAVSQ60QyVAy0Npb3p3zyhcb5OgvWqD3x1ji/CevZfAGLRjZrjXVAMhxRg bwteqyi3XQFD6mOEWFgAynkToz6ro8iseHxFXWTb68XrtBYV1Su/NY5tieYyAaWQLbCb 5OoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=tz3ZQBhpETWvEW1lpF7J6Ap/uRs8k2c7CZWNJeXtFio=; b=ooySM7lsM5sxZn02bVTltgcd9cUsVInGSfkUjRfvRCVwSxvw+13MOaJ55COResUG/2 Cu5ljWbOX54ue1itH1vztGPwPimILAdEuamPJ2IaLJp0i9Cm1+7BWF0zxkBR/ImW/0tj CcAe9+bvnhInokUMxfslrRMt68NJw+Z4+pLTMhwumW8ICKOC0neSyKQWdxSl4UMgbfOH Lt2ZbEBqheaMlJZyDi8m58OgMUI+fIh3aG7zt2w8t/Jlnj/56FdJLLZ5UicyjuiwD6KD Q4lEHpk6M702Hhzh3DFkYlwymsbk7tgF10tLvX7II47F8KjwJZGzUQ9oxkTv8oksLjIP cfBw== X-Gm-Message-State: ALQs6tCX3Tg/ZPztGKNRBM8MoQFfbdQMREWr++pbusnrQOVXjklKH3LC exAxyc8unSHlwP0i/SWuhgt5pw== X-Received: by 2002:adf:9814:: with SMTP id v20-v6mr34167599wrb.93.1525782741686; Tue, 08 May 2018 05:32:21 -0700 (PDT) Received: from [192.168.10.158] (host92-93-static.8-79-b.business.telecomitalia.it. [79.8.93.92]) by smtp.gmail.com with ESMTPSA id x63sm14459887wma.25.2018.05.08.05.32.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 05:32:21 -0700 (PDT) Subject: Re: [RFC PATCH] sched/cpufreq/schedutil: handling urgent frequency requests To: Viresh Kumar Cc: linux-kernel@vger.kernel.org, "Rafael J . Wysocki" , Peter Zijlstra , Ingo Molnar , Patrick Bellasi , Juri Lelli , Luca Abeni , Joel Fernandes , linux-pm@vger.kernel.org References: <1525704215-8683-1-git-send-email-claudio@evidence.eu.com> <20180508065435.bcht6dyb3rpp6gk5@vireshk-i7> From: Claudio Scordino Message-ID: Date: Tue, 8 May 2018 14:32:27 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180508065435.bcht6dyb3rpp6gk5@vireshk-i7> Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ? Thanks, Claudio