Received: by 10.192.165.148 with SMTP id m20csp3957861imm; Mon, 7 May 2018 23:56:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpdMA3RfxTLeMa5Nu34RLOp6jSgMynFCNNVeScz1+SqDG/7p5V7dpaesAjxWyVT6Jzz21bz X-Received: by 10.98.165.12 with SMTP id v12mr11110818pfm.237.1525762574046; Mon, 07 May 2018 23:56:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525762573; cv=none; d=google.com; s=arc-20160816; b=rmxxhZSA/JY/PIv/wuWt9vbjqIKrpph8FjPEcYqi8SVCTv5P9wEPV0xRfMkbX7aNR/ lwaPs4gLhNxct74y4GO55KkdrMOPrsF/dGkt62I8NbFLEv2BbiBLDxzLXNJMbZ6tl16p XoCwAZ42T3sqS9Ncs2PAMX/Z7iAsAs+K2NXxFt/DCeigTheCg5PtvaAa74zntvWGXXIU 0RmLVovYEEp3fPxOOuJ51xNypNtKZUlJ/LrFqrLNBsZ3i2SXMnJsyPjG+GASRoqRiDNi Sg1ZVVmzCCsPt8nU+/ep9iJkXw80c1aSYZLqjXTmbdfF99uIUnMB6NHHuD3w9S6DWCdB x/4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=x6BVWACeA5GvCVL/LrSXdAhJ+qjCxLmCXaxwAvj647I=; b=nqoZNn2kvuvAHmYGdJ2lGKu+XAlWrY+sk6Q/Lr/GZnahysK8xwZaur3M/Sd2jkyA46 0uJKlIeb5iOUAgQOcI3Q8LpnypNbZVUXCx8KPemSCbqE0XPRUuGkYVmoFGvYiuxQ1BSc wtm+Hzhmf/nkmFnO0IgLbe4eOt3Mg0ihPyVcDpFpE5lTMAadhtMebLbJmByB4sSbBmeA iXaoL8rEUfwJgLgUdwCrrkPuWTrnXFUygudbFRqLL88YryCH2A83w4nDheGQx9ZyzqXi FOyIOEBVHTYNOL1yWjG9QlIecRit1ADpsDV0rUS6kMQOz2GePhpQa6E+V8q59cTZXLIE JAFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ikfy1GxB; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t17si24100222pfj.10.2018.05.07.23.55.59; Mon, 07 May 2018 23:56:13 -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=@linaro.org header.s=google header.b=ikfy1GxB; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754423AbeEHGyl (ORCPT + 99 others); Tue, 8 May 2018 02:54:41 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:43608 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754257AbeEHGyj (ORCPT ); Tue, 8 May 2018 02:54:39 -0400 Received: by mail-pl0-f65.google.com with SMTP id a39-v6so1644632pla.10 for ; Mon, 07 May 2018 23:54:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=x6BVWACeA5GvCVL/LrSXdAhJ+qjCxLmCXaxwAvj647I=; b=ikfy1GxBmjDetCQCnKaTzxCCbDvgmRMirY2HUI91Y2K380OZe8vSidb1svmj7uK0Ho g0xo+FyDzVQV5vCvna9+mGM5mXyniJGX4ezQx5Q4F+MUl8L8JQPoooNck7DZrpMTsiCs DosO3tsVUobVry3tl14p54RoWLR0LJcBOBl5E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=x6BVWACeA5GvCVL/LrSXdAhJ+qjCxLmCXaxwAvj647I=; b=Bgy5bMS74K/BaH23ILnVt1E/AO2RXbrhGDJgVby11lmpjvrxYVdNPwIAZnbK+/PWaG yzQJ5WuoT2eixhIIop9oL+X3hhLxOIM5T3wi91QcFAAtJtRbio3/XAN0B6AU81OMZO12 vKIm5y22NMD/Qr9a3f2ZvTQ8LOB2urP0UUZaiUeRooSppuRXiWMfJk+LK8RPVA15x9hK Y08yyudeTibmT4kPNYplp4d9jREGc5cVyzYB02FbkzrCJM4B8vbr47g9Av3I+ME5rnJp LzSpFLWZexKXprCx2wLYNLSJpVR4erhucP25sW/flkxnOfdnPMLdvOtPSFgwvUg4qz12 1LRw== X-Gm-Message-State: ALQs6tBFEmRnNDO+MuJ0riiS7DcWRzzfLlZr3jIpB7Bl5fF/FRI7n3zk kDZ0n/NzTTkiCxiQnNKaFcjTgDwwKaY= X-Received: by 2002:a17:902:ab98:: with SMTP id f24-v6mr13578215plr.144.1525762478579; Mon, 07 May 2018 23:54:38 -0700 (PDT) Received: from localhost ([122.167.163.112]) by smtp.gmail.com with ESMTPSA id u188sm40767399pfb.84.2018.05.07.23.54.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 23:54:37 -0700 (PDT) Date: Tue, 8 May 2018 12:24:35 +0530 From: Viresh Kumar To: Claudio Scordino 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 Subject: Re: [RFC PATCH] sched/cpufreq/schedutil: handling urgent frequency requests Message-ID: <20180508065435.bcht6dyb3rpp6gk5@vireshk-i7> References: <1525704215-8683-1-git-send-email-claudio@evidence.eu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1525704215-8683-1-git-send-email-claudio@evidence.eu.com> User-Agent: NeoMutt/20180323-120-3dd1ac Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > + } while (sg_policy->urgent_freq_update); > mutex_unlock(&sg_policy->work_lock); > > sg_policy->work_in_progress = false; > @@ -673,6 +688,7 @@ static int sugov_start(struct cpufreq_policy *policy) > sg_policy->next_freq = UINT_MAX; > sg_policy->work_in_progress = false; > sg_policy->need_freq_update = false; > + sg_policy->urgent_freq_update = false; > sg_policy->cached_raw_freq = 0; > > for_each_cpu(cpu, policy->cpus) { > -- > 2.7.4 -- viresh