linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qais Yousef <qyousef@layalina.io>
To: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	Lukasz Luba <lukasz.luba@arm.com>
Subject: Re: [RFC PATCH 2/7] sched/pelt: Add a new function to approximate runtime to reach given util
Date: Wed, 6 Sep 2023 22:38:31 +0100	[thread overview]
Message-ID: <20230906213831.jclswjplxeim2oy4@airbuntu> (raw)
In-Reply-To: <16dcf2b6-6921-10c7-ae75-a9f8015a9c85@arm.com>

On 09/06/23 22:44, Dietmar Eggemann wrote:
> On 06/09/2023 14:56, Dietmar Eggemann wrote:
> > On 28/08/2023 01:31, Qais Yousef wrote:
> >> It is basically the ramp-up time from 0 to a given value. Will be used
> >> later to implement new tunable to control response time  for schedutil.
> >>
> >> Signed-off-by: Qais Yousef (Google) <qyousef@layalina.io>
> >> ---
> >>  kernel/sched/pelt.c  | 21 +++++++++++++++++++++
> >>  kernel/sched/sched.h |  1 +
> >>  2 files changed, 22 insertions(+)
> >>
> >> diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c
> >> index 50322005a0ae..f673b9ab92dc 100644
> >> --- a/kernel/sched/pelt.c
> >> +++ b/kernel/sched/pelt.c
> >> @@ -487,3 +487,24 @@ unsigned long approximate_util_avg(unsigned long util, u64 delta)
> >>  
> >>  	return sa.util_avg;
> >>  }
> >> +
> >> +/*
> >> + * Approximate the required amount of runtime in ms required to reach @util.
> >> + */
> >> +u64 approximate_runtime(unsigned long util)
> >> +{
> >> +	struct sched_avg sa = {};
> >> +	u64 delta = 1024; // period = 1024 = ~1ms
> >> +	u64 runtime = 0;
> >> +
> >> +	if (unlikely(!util))
> >> +		return runtime;
> >> +
> >> +	while (sa.util_avg < util) {
> >> +		accumulate_sum(delta, &sa, 0, 0, 1);
> >> +		___update_load_avg(&sa, 0);
> >> +		runtime++;
> >> +	}
> >> +
> >> +	return runtime;
> >> +}
> > 
> > S_n = S_inv * (1 - 0.5^(t/hl))
> > 
> > t = hl * ln(1 - Sn/S_inv)/ln(0.5)
> > 
> > (1) for a little CPU (capacity_orig = 446)
> > 
> > t = 32ms * ln(1 - 446/1024)/ln(0.5)
> > 
> > t = 26ms
> > 
> > (2) for a big CPU (capacity = 1023 (*instead of 1024 since ln(0) not
> >     defined
> > 
> > t = 32ms * ln(1 - 1023/1024)/ln(0.5)
> > 
> > t = 320ms
> 
> Forgot half of what I wanted to ask:
> 
> And you want to be able to have a schedutil interface:
> 
> /sys/devices/system/cpu/cpufreq/policy*/schedutil/response_time_ms
> 
> in which by default we have 26ms for a CPU with the capacity_orig of 446.

Note that this *is* the default. I'm just exposing it not really changing it :)

It is actually much less than that if you take into account the current 25%
headroom.

> 
> I.e. you want to have a time-based interface there? Which the user can
> overwrite, say with 52ms and this then will lower the return value of
> get_next_freq() so the system will respond slower?
> 
> And the time based interface is more intuitive than staying in the
> capacity world of [0-1024]?

Yes this is exactly how I am defining the interface :-) I think this is generic
and will give users what they need and hopefully should stand the test of time.

The slow down aspect has a limitation though as I highlight in the cover
letter. I haven't figured out how to resolve it yet, or worth the effort.
If anyone has thoughts on that that'd be useful to learn about. It should be
fixable though.

Generally perf first is not always the desired outcome. Power and thermal play
bigger roles in a lot of systems today and I can see even sever market pays
more attention to them now.

Hence I didn't see why I should limit it to improving perf only and disregard
that there are situations where the system might be more concerned about power
or thermals and this could allow more fine tuning than limiting max frequencies
abruptly. They just get harder to reach so in average we get different
residencies (for same workload), but freqs are still reachable. There will be
a perf hit of course, but that's userspace problem to decide if it's worth it
or not.

Generally I am a big advocate of userspace to take the leap and be smarter
about what it needs and when. Fixing everything automagically has its appeal
but I don't think this is sustainable anymore.


Thanks!

--
Qais Yousef

  reply	other threads:[~2023-09-06 21:38 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-27 23:31 [RFC PATCH 0/7] sched: cpufreq: Remove magic margins Qais Yousef
2023-08-27 23:31 ` [RFC PATCH 1/7] sched/pelt: Add a new function to approximate the future util_avg value Qais Yousef
2023-09-06 12:56   ` Dietmar Eggemann
2023-09-06 21:19     ` Qais Yousef
2023-09-07 11:12       ` Dietmar Eggemann
2023-09-10 19:58         ` Qais Yousef
2023-09-13 17:22           ` Dietmar Eggemann
2023-09-16 19:49             ` Qais Yousef
2023-09-16 19:52               ` Qais Yousef
2023-08-27 23:31 ` [RFC PATCH 2/7] sched/pelt: Add a new function to approximate runtime to reach given util Qais Yousef
2023-09-06 12:56   ` Dietmar Eggemann
2023-09-06 20:44     ` Dietmar Eggemann
2023-09-06 21:38       ` Qais Yousef [this message]
2023-09-15  9:15   ` Hongyan Xia
2023-09-16 19:56     ` Qais Yousef
2023-08-27 23:31 ` [RFC PATCH 3/7] sched/fair: Remove magic margin in fits_capacity() Qais Yousef
2023-09-06 14:38   ` Dietmar Eggemann
2023-09-06 21:45     ` Qais Yousef
2023-08-27 23:32 ` [RFC PATCH 4/7] sched: cpufreq: Remove magic 1.25 headroom from apply_dvfs_headroom() Qais Yousef
2023-09-07 11:34   ` Peter Zijlstra
2023-09-10 19:23     ` Qais Yousef
2023-08-27 23:32 ` [RFC PATCH 5/7] sched/schedutil: Add a new tunable to dictate response time Qais Yousef
2023-09-06 21:13   ` Dietmar Eggemann
2023-09-06 21:52     ` Qais Yousef
2023-09-07 11:44   ` Peter Zijlstra
2023-09-10 19:25     ` Qais Yousef
2023-08-27 23:32 ` [RFC PATCH 6/7] sched/pelt: Introduce PELT multiplier Qais Yousef
2023-08-27 23:32 ` [RFC PATCH 7/7] cpufreq: Change default transition delay to 2ms Qais Yousef
2023-09-06  9:18 ` [RFC PATCH 0/7] sched: cpufreq: Remove magic margins Lukasz Luba
2023-09-06 21:18   ` Qais Yousef
2023-09-07  7:48     ` Lukasz Luba
2023-09-07 11:53       ` Peter Zijlstra
2023-09-07 13:06         ` Lukasz Luba
2023-09-07 13:29           ` Peter Zijlstra
2023-09-07 13:33             ` Lukasz Luba
2023-09-07 13:38               ` Peter Zijlstra
2023-09-07 13:45                 ` Lukasz Luba
2023-09-08 12:51                   ` Daniel Bristot de Oliveira
2023-09-12 11:57                     ` Lukasz Luba
2023-09-10 18:20         ` Qais Yousef
2023-09-10 18:14       ` Qais Yousef
2023-09-07 13:26     ` Peter Zijlstra
2023-09-07 13:57       ` Lukasz Luba
2023-09-07 14:29         ` Peter Zijlstra
2023-09-07 14:42           ` Lukasz Luba
2023-09-07 20:16             ` Peter Zijlstra
2023-09-12 11:51               ` Lukasz Luba
2023-09-12 14:01                 ` Vincent Guittot
2023-09-13  9:53                   ` Lukasz Luba
2023-09-12 14:28                 ` Peter Zijlstra
2023-09-10 19:06             ` Qais Yousef
2023-09-10 18:46       ` Qais Yousef
2023-09-07 13:08 ` Peter Zijlstra
2023-09-08  0:17   ` Qais Yousef
2023-09-08  7:40     ` Dietmar Eggemann
2023-09-08 14:07       ` Qais Yousef
2023-09-12 17:18         ` Dietmar Eggemann
2023-09-16 19:38           ` Qais Yousef
2023-09-08 10:25     ` Peter Zijlstra
2023-09-08 13:33       ` Qais Yousef
2023-09-08 13:58         ` Peter Zijlstra
2023-09-08 13:59         ` Peter Zijlstra
2023-09-08 14:11           ` Qais Yousef
2023-09-10 21:17         ` Qais Yousef

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=20230906213831.jclswjplxeim2oy4@airbuntu \
    --to=qyousef@layalina.io \
    --cc=dietmar.eggemann@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).