lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230910195832.pncjsqmkepichly6@airbuntu>
Date:   Sun, 10 Sep 2023 20:58:32 +0100
From:   Qais Yousef <qyousef@...alina.io>
To:     Dietmar Eggemann <dietmar.eggemann@....com>
Cc:     Ingo Molnar <mingo@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Viresh Kumar <viresh.kumar@...aro.org>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org,
        Lukasz Luba <lukasz.luba@....com>
Subject: Re: [RFC PATCH 1/7] sched/pelt: Add a new function to approximate
 the future util_avg value

On 09/07/23 13:12, Dietmar Eggemann wrote:
> On 06/09/2023 23:19, Qais Yousef wrote:
> > On 09/06/23 14:56, Dietmar Eggemann wrote:
> >> On 28/08/2023 01:31, Qais Yousef wrote:
> 
> [...]
> 
> >>> +/*
> >>> + * Approximate the new util_avg value assuming an entity has continued to run
> >>> + * for @delta us.
> >>> + */
> >>> +unsigned long approximate_util_avg(unsigned long util, u64 delta)
> >>> +{
> >>> +	struct sched_avg sa = {
> >>> +		.util_sum = util * PELT_MIN_DIVIDER,
> >>> +		.util_avg = util,
> >>> +	};
> >>> +
> >>> +	if (unlikely(!delta))
> >>> +		return util;
> >>> +
> >>> +	accumulate_sum(delta, &sa, 0, 0, 1);
> >>
> >> IMHO, you miss the handling of `periods != 0`. load = 0 eclipses this
> >> code in accumulate_sum().
> 
> You could call accumulate_sum(delta, &sa, 1, 0, 1);

Yes. I initially thought the load is not necessary, but good catch. I didn't
get a chance to rerun to see the numbers, but hopefully this should fix the
wrong numbers I was seeing. Thanks!

> 
> > 
> > Yes. For some reason I got blank registered when I saw if this codepath can
> > impact util_avg..
> 
> Another thing ... I guess if you call accumulate_sum with delta the PELT
> machinery assumes `delta = now - sa->last_update_time` which means you
> would have to use `clock_pelt + TICK_USEC` as delta.

Right.

The way I understood it is that at TICK we should do update_load_avg() which
would call __update_load_sum() which uses

	delta = now - sa->last_update_time

which passes this delta to accumulate_sum()

I can see we are not very accurate since there will be a small additional time
besides TICK_USEC that we are not accounting for. But I can't see how this can
cause a big error.

	predicted (assumed) tick time/delta

		sa->last_update_time = now
		tick_time = TICK_USEC + now

		delta = tick_time - sa->last_update_time
		delta = TICK_USEC + now - now
		delta = TICK_USEC

	but actual tick time/delta

		sa->last_update_time = now - x
		tick_time = TICK_USEC + now

		delta = tick_time - sa->last_update_time
		delta = TICK_USEC + now - (now - x)
		delta = TICK_USEC + x

So the delta I am using might be slightly shorter than it should be.

IIUC, what you're saying that the `x` in my equation above is clock_pelt,
right?


Thanks!

--
Qais Yousef

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ