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: <20230906211936.yqejc25czc6tddm6@airbuntu>
Date:   Wed, 6 Sep 2023 22:19:36 +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/06/23 14:56, Dietmar Eggemann wrote:
> On 28/08/2023 01:31, Qais Yousef wrote:
> > Given a util_avg value, the new function will return the future one
> > given a runtime delta.
> > 
> > This will be useful in later patches to help replace some magic margins
> > with more deterministic behavior.
> > 
> > Signed-off-by: Qais Yousef (Google) <qyousef@...alina.io>
> > ---
> >  kernel/sched/pelt.c  | 22 +++++++++++++++++++++-
> >  kernel/sched/sched.h |  3 +++
> >  2 files changed, 24 insertions(+), 1 deletion(-)
> > 
> > diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c
> > index 0f310768260c..50322005a0ae 100644
> > --- a/kernel/sched/pelt.c
> > +++ b/kernel/sched/pelt.c
> > @@ -466,4 +466,24 @@ int update_irq_load_avg(struct rq *rq, u64 running)
> >  
> >  	return ret;
> >  }
> > -#endif
> > +#endif /* CONFIG_HAVE_SCHED_AVG_IRQ */
> > +
> > +/*
> > + * 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().

Yes. For some reason I got blank registered when I saw if this codepath can
impact util_avg..

> 
> > +	___update_load_avg(&sa, 0);
> > +
> > +	return sa.util_avg;
> > +}
> 
> We already discussed something similar like this in Nov 22, the so
> called UTIL_EST_FASTER thing.
> 
> https://lkml.kernel.org/r/Y2kLA8x40IiBEPYg@hirez.programming.kicks-ass.net
> 
> +/*
> + * Compute a pelt util_avg assuming no history and @delta runtime.
> + */
> +unsigned long faster_est_approx(u64 delta)
> +{
> +	unsigned long contrib = (unsigned long)delta; /* p == 0 -> delta < 1024 */
> +	u64 periods = delta / 1024;
> +
> +	if (periods) {
> +		delta %= 1024;
> +		contrib = __accumulate_pelt_segments(periods, 1024, delta);
> +	}
> +
> +	return (contrib << SCHED_CAPACITY_SHIFT) / PELT_MIN_DIVIDER;
> +}
> +

I could look at using this version instead. This misses the decay part though?


Thanks!

--
Qais Yousef

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ