All of lore.kernel.org
 help / color / mirror / Atom feed
From: Claudio Scordino <claudio@evidence.eu.com>
To: Patrick Bellasi <patrick.bellasi@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	Ingo Molnar <mingo@redhat.com>,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Morten Rasmussen <morten.rasmussen@arm.com>,
	Juri Lelli <juri.lelli@redhat.com>, Todd Kjos <tkjos@android.com>,
	Joel Fernandes <joelaf@google.com>
Subject: Re: [PATCH v3 0/6] cpufreq: schedutil: fixes for flags updates
Date: Tue, 6 Feb 2018 19:14:28 +0100	[thread overview]
Message-ID: <68afaf84-893e-6770-b9f1-619cd2b6dc9c@evidence.eu.com> (raw)
In-Reply-To: <20180206154319.GF5739@e110439-lin>

Hi Patrick,

Il 06/02/2018 16:43, Patrick Bellasi ha scritto:
> Hi Claudio,
> 
> On 06-Feb 11:55, Claudio Scordino wrote:
>> Hi Peter,
>>
>> Il 20/12/2017 16:30, Peter Zijlstra ha scritto:
>>>
>>> So I ended up with the below (on top of Juri's cpufreq-dl patches).
>>>
>>> It compiles, but that's about all the testing it had.
>>>
>>> --- a/include/linux/sched/cpufreq.h
>>> +++ b/include/linux/sched/cpufreq.h
> 
> [..]
> 
>>> @@ -188,17 +187,23 @@ static void sugov_get_util(struct sugov_
>>>   static unsigned long sugov_aggregate_util(struct sugov_cpu *sg_cpu)
>>>   {
>>> +	unsigned long util = sg_cpu->util_cfs + sg_cpu->util_dl;
>>> +	struct rq *rq = cpu_rq(sg_cpu->cpu);
>>> +
>>> +	if (rq->rt.rt_nr_running)
>>> +		util = sg_cpu->max;
>>> +
>>>   	/*
>>>   	 * Ideally we would like to set util_dl as min/guaranteed freq and
>>>   	 * util_cfs + util_dl as requested freq. However, cpufreq is not yet
>>>   	 * ready for such an interface. So, we only do the latter for now.
>>>   	 */
>>> -	return min(sg_cpu->util_cfs + sg_cpu->util_dl, sg_cpu->max);
>>> +	return min(util, sg_cpu->max);
>>>   }
> 
> [...]
> 
>>
>> What is the status of this patch ? I couldn't find it on the
>> tip/queue repositories.
>>
>> BTW, I wonder if we actually want to remove also the information
>> about the scheduling class who triggered the frequency change.
> 
> Removing flags was the main goal of the patch, since they represents
> mainly duplicated information which scheduling classes already know.
> 
> This was making flags update error prone and difficult to keep
> aligned with existing scheduling classes info.
> 
>> This prevents us from adopting class-specific behaviors.
> 
> In Peter's proposal he replaces flags with checks like:
> 
>     if (rq->rt.rt_nr_running)
> 
>> For example, we might want to skip the rate limits when deadline
>> asks for an increase of frequency, as shown in the patch below.
>> In this case, we could just remove the flags from sugov_cpu, but
>> leave the defines and the argument for sugov_update_*()
> 
> At first glance, your proposal below makes to make sense.
> 
> However, I'm wondering if we cannot get it working using
> rq->dl's provided information instead of flags?

Yes, we can use the value of rq->dl to check if there has been an increase of the deadline utilization.
Even if schedutil might have been triggered by a different scheduling class, the effect should be almost the same.

Below a potential patch. I've kept all frequency update decisions in a single point (i.e. sugov_should_update_freq).
Not yet tested (waiting for further comments).

Thanks,

                Claudio




 From 49a6eec60574ae93297406d40155e6ce4113e442 Mon Sep 17 00:00:00 2001
From: Claudio Scordino <claudio@evidence.eu.com>
Date: Tue, 6 Feb 2018 18:42:23 +0100
Subject: [PATCH] cpufreq: schedutil: rate limits for SCHED_DEADLINE

When the SCHED_DEADLINE scheduling class asks to increase the CPU
frequency, we should not wait the rate limit, otherwise we may miss some
deadline.

This patch moves all frequency update decisions to a single point:
sugov_should_update_freq(). In addition, it ignores the rate limit
whenever there is an increase of the CPU frequency given by an increase
of the deadline utilization.

Signed-off-by: Claudio Scordino <claudio@evidence.eu.com>
---
  kernel/sched/cpufreq_schedutil.c | 27 +++++++++++++++++++--------
  1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index b0bd77d..e8504f5 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -74,7 +74,11 @@ 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,
+				     struct sugov_cpu *sg_cpu_old,
+				     struct sugov_cpu *sg_cpu_new,
+				     unsigned int next_freq)
  {
  	s64 delta_ns;
  
@@ -111,6 +115,14 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time)
  		return true;
  	}
  
+	/*
+	 * Ignore rate limit when DL asked to increase the CPU frequency,
+	 * otherwise we may miss some deadline.
+	 */
+	if ((next_freq > sg_policy->next_freq) &&
+			(sg_cpu_new->util_dl > sg_cpu_old->util_dl))
+		return true;
+
  	delta_ns = time - sg_policy->last_freq_update_time;
  	return delta_ns >= sg_policy->freq_update_delay_ns;
  }
@@ -271,6 +283,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
  				unsigned int flags)
  {
  	struct sugov_cpu *sg_cpu = container_of(hook, struct sugov_cpu, update_util);
+	struct sugov_cpu sg_cpu_old = *sg_cpu;
  	struct sugov_policy *sg_policy = sg_cpu->sg_policy;
  	unsigned long util, max;
  	unsigned int next_f;
@@ -279,9 +292,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);
  
  	sugov_get_util(sg_cpu);
@@ -300,7 +310,8 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
  		sg_policy->cached_raw_freq = 0;
  	}
  
-	sugov_update_commit(sg_policy, time, next_f);
+	if (sugov_should_update_freq(sg_policy, time, &sg_cpu_old, sg_cpu, next_f))
+		sugov_update_commit(sg_policy, time, next_f);
  }
  
  static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time)
@@ -350,6 +361,7 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time,
  				unsigned int flags)
  {
  	struct sugov_cpu *sg_cpu = container_of(hook, struct sugov_cpu, update_util);
+	struct sugov_cpu sg_cpu_old = *sg_cpu;
  	struct sugov_policy *sg_policy = sg_cpu->sg_policy;
  	unsigned int next_f;
  
@@ -359,10 +371,9 @@ 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)) {
-		next_f = sugov_next_freq_shared(sg_cpu, time);
+	next_f = sugov_next_freq_shared(sg_cpu, time);
+	if (sugov_should_update_freq(sg_policy, time, &sg_cpu_old, sg_cpu, next_f))
  		sugov_update_commit(sg_policy, time, next_f);
-	}
  
  	raw_spin_unlock(&sg_policy->update_lock);
  }
-- 
2.7.4

  reply	other threads:[~2018-02-06 18:14 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-30 11:47 [PATCH v3 0/6] cpufreq: schedutil: fixes for flags updates Patrick Bellasi
2017-11-30 11:47 ` [PATCH v3 1/6] cpufreq: schedutil: reset sg_cpus's flags at IDLE enter Patrick Bellasi
2017-11-30 13:12   ` Juri Lelli
2017-11-30 15:41     ` Patrick Bellasi
2017-11-30 16:02       ` Juri Lelli
2017-11-30 16:19         ` Patrick Bellasi
2017-11-30 16:45           ` Juri Lelli
2017-12-07  5:01   ` Viresh Kumar
2017-12-07 12:45     ` Patrick Bellasi
2017-12-07 15:55       ` Dietmar Eggemann
2017-12-12 11:37       ` Viresh Kumar
2017-12-12 13:38         ` Juri Lelli
2017-12-12 14:40           ` Viresh Kumar
2017-12-12 14:56             ` Juri Lelli
2017-12-12 15:18               ` Patrick Bellasi
2017-12-12 15:16         ` Patrick Bellasi
2017-12-13  9:06           ` Viresh Kumar
2017-12-20 14:33   ` Peter Zijlstra
2017-12-20 14:51     ` Patrick Bellasi
2017-11-30 11:47 ` [PATCH v3 2/6] cpufreq: schedutil: ensure max frequency while running RT/DL tasks Patrick Bellasi
2017-11-30 13:17   ` Juri Lelli
2017-11-30 15:45     ` Patrick Bellasi
2017-11-30 16:03       ` Juri Lelli
2017-12-07  5:05   ` Viresh Kumar
2017-12-07 14:18     ` Patrick Bellasi
2017-11-30 11:47 ` [PATCH v3 3/6] cpufreq: schedutil: update CFS util only if used Patrick Bellasi
2017-11-30 13:22   ` Juri Lelli
2017-11-30 15:57     ` Patrick Bellasi
2017-12-07  5:15       ` Viresh Kumar
2017-12-07 14:19         ` Patrick Bellasi
2017-12-14  4:45           ` Viresh Kumar
2017-11-30 11:47 ` [PATCH v3 4/6] sched/rt: fast switch to maximum frequency when RT tasks are scheduled Patrick Bellasi
2017-11-30 13:28   ` Juri Lelli
2017-12-06  9:39   ` Vincent Guittot
2017-12-06 11:38     ` Patrick Bellasi
2017-12-06 12:36       ` Vincent Guittot
2017-11-30 11:47 ` [PATCH v3 5/6] cpufreq: schedutil: relax rate-limiting while running RT/DL tasks Patrick Bellasi
2017-11-30 13:36   ` Juri Lelli
2017-11-30 15:54     ` Patrick Bellasi
2017-11-30 16:06       ` Juri Lelli
2017-11-30 11:47 ` [PATCH v3 6/6] cpufreq: schedutil: ignore sugov kthreads Patrick Bellasi
2017-11-30 13:41   ` Juri Lelli
2017-11-30 16:02     ` Patrick Bellasi
2017-11-30 16:12       ` Juri Lelli
2017-11-30 16:42         ` Patrick Bellasi
2017-12-07  9:24           ` Viresh Kumar
2017-12-07 15:47             ` Patrick Bellasi
2017-12-20 15:30 ` [PATCH v3 0/6] cpufreq: schedutil: fixes for flags updates Peter Zijlstra
2017-12-20 15:43   ` Peter Zijlstra
2017-12-21  9:15     ` Viresh Kumar
2017-12-21 10:25       ` Peter Zijlstra
2017-12-21 10:30         ` Viresh Kumar
2017-12-21 10:39           ` Peter Zijlstra
2017-12-21 10:43             ` Viresh Kumar
2017-12-22  8:30               ` Peter Zijlstra
2017-12-20 15:56   ` Peter Zijlstra
2017-12-31  9:43     ` Claudio Scordino
2018-01-02 13:31       ` Claudio Scordino
2017-12-20 17:38   ` Juri Lelli
2017-12-20 18:16     ` Peter Zijlstra
2017-12-22 10:06     ` Peter Zijlstra
2017-12-22 11:02       ` Patrick Bellasi
2017-12-22 11:46         ` Peter Zijlstra
2017-12-22 12:07           ` Juri Lelli
2017-12-22 12:14             ` Patrick Bellasi
2017-12-22 12:22               ` Peter Zijlstra
2017-12-22 12:07           ` Patrick Bellasi
2017-12-22 12:19             ` Peter Zijlstra
2017-12-22 12:27               ` Juri Lelli
2017-12-22 12:38               ` Patrick Bellasi
2017-12-22 12:43                 ` Juri Lelli
2017-12-22 12:50                   ` Patrick Bellasi
2017-12-22 13:01                     ` Juri Lelli
2017-12-22 12:10           ` Peter Zijlstra
2017-12-22 12:25             ` Patrick Bellasi
2017-12-21  7:34   ` Viresh Kumar
2018-02-06 10:55   ` Claudio Scordino
2018-02-06 15:43     ` Patrick Bellasi
2018-02-06 18:14       ` Claudio Scordino [this message]
2018-02-06 18:36         ` Patrick Bellasi
2018-02-08 16:14           ` Claudio Scordino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=68afaf84-893e-6770-b9f1-619cd2b6dc9c@evidence.eu.com \
    --to=claudio@evidence.eu.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=joelaf@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=morten.rasmussen@arm.com \
    --cc=patrick.bellasi@arm.com \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=tkjos@android.com \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.