All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qais Yousef <qyousef@layalina.io>
To: Li kunyu <likunyu@open-hieco.net>
Cc: Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	 Vincent Guittot <vincent.guittot@linaro.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	 Viresh Kumar <viresh.kumar@linaro.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	 Steven Rostedt <rostedt@goodmis.org>,
	John Stultz <jstultz@google.com>,
	 Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	 "Chen, Yu C" <yu.c.chen@intel.com>,
	Thomas Gleixner <tglx@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 03/10] sched/pelt: Add a new function to approximate runtime to reach given util
Date: Tue, 1 Dec 2026 00:35:45 +0000	[thread overview]
Message-ID: <aw4V75fQc1qAHb7s@aerith> (raw)
In-Reply-To: <e64956eb-393e-6fa7-3351-acffa4ee779e@open-hieco.net>

On 11/26/26 18:50, Li kunyu wrote:
> Hi Qais,
> 
> On 2026/11/26 13:14, Qais Yousef wrote:
> > +
> > +/*
> > + * Approximate the required amount of runtime in us required to reach @util.
> > + */
> > +u64 approximate_runtime(unsigned long util)
> > +{
> > +	struct sched_avg sa = {};
> > +	u64 delta = 1024; // period = 1024 = ~1ms
> 
> Would it be clearer to name this period as the base unit? A delta of 1024

Yeah period might be a better name. Delta is the usual input to
accumulate_sum().

> corresponds to one full period:
> 
> u64 period = 1024; /* one period = 1024 delta units */
> 
> > +	u64 runtime = 0;
> > +
> > +	if (unlikely(!util))
> > +		return runtime;
> > +
> > +	if (unlikely(WARN_ON_ONCE(util > SCHED_CAPACITY_SCALE)))
> > +		util = SCHED_CAPACITY_SCALE;
> > +
> > +	while (sa.util_avg < util) {
> > +		accumulate_sum(delta, &sa, 1, 0, 1);
> 
> accumulate_sum(period, &sa, 1, 0, 1);
> 
> > +		___update_load_avg(&sa, 0);
> > +		runtime++;
> > +	}
> > +
> > +	return runtime * 1024;
> 
> return runtime * period;

I kept it a literal so that compiler hopefully would turn this into << 10.

I guess it can still see the variable is constant and do that.

> 
> > +}
> 
> Would the overall effect be better this way? Or is my understanding somewhat off?

Valid suggestion. I'll take it into account.

Thanks!

  reply	other threads:[~2026-12-01  0:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  5:14 [PATCH v3 00/10] Better manage system response time Qais Yousef
2026-11-26  5:14 ` [PATCH v3 01/10] sched: cpufreq: Rename map_util_perf to sugov_apply_dvfs_headroom Qais Yousef
2026-11-26  5:14 ` [PATCH v3 02/10] sched/pelt: Add a new function to approximate the future util_avg value Qais Yousef
2026-11-26  5:14 ` [PATCH v3 03/10] sched/pelt: Add a new function to approximate runtime to reach given util Qais Yousef
2026-11-26 10:50   ` Li kunyu
2026-12-01  0:35     ` Qais Yousef [this message]
2026-11-26  5:14 ` [PATCH v3 04/10] sched/fair: Remove magic hardcoded margin in fits_capacity() Qais Yousef
2026-11-26  5:14 ` [PATCH v3 05/10] sched: cpufreq: Remove magic 1.25 headroom from sugov_apply_dvfs_headroom() Qais Yousef
2026-11-26  5:14 ` [PATCH v3 06/10] sched/fair: Extend util_est to improve rampup time Qais Yousef
2026-11-26  5:14 ` [PATCH v3 07/10] sched/fair: util_est: Take into account periodic tasks Qais Yousef
2026-11-26  5:14 ` [PATCH v3 08/10] sched/debugfs: Add rampup_multiplier to debugfs Qais Yousef
2026-11-26  5:14 ` [PATCH v3 09/10] sched/fair: Disable util_est when rampup_multiplier is 0 Qais Yousef
2026-11-26  5:14 ` [PATCH v3 10/10] sched/fair: Don't mess with util_avg post init 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=aw4V75fQc1qAHb7s@aerith \
    --to=qyousef@layalina.io \
    --cc=dietmar.eggemann@arm.com \
    --cc=jstultz@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=likunyu@open-hieco.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@kernel.org \
    --cc=tim.c.chen@linux.intel.com \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    --cc=yu.c.chen@intel.com \
    /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.