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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKfTPtB1LFQF3kCQ67-5cu-eABbuWR19FC6sTnnPVane4D+EAA@mail.gmail.com>
Date: Tue, 3 Sep 2024 14:48:32 +0200
From: Vincent Guittot <vincent.guittot@...aro.org>
To: Qais Yousef <qyousef@...alina.io>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>, Viresh Kumar <viresh.kumar@...aro.org>, 
	Ingo Molnar <mingo@...nel.org>, Peter Zijlstra <peterz@...radead.org>, 
	Juri Lelli <juri.lelli@...hat.com>, Steven Rostedt <rostedt@...dmis.org>, 
	Dietmar Eggemann <dietmar.eggemann@....com>, Ben Segall <bsegall@...gle.com>, 
	Mel Gorman <mgorman@...e.de>, Valentin Schneider <vschneid@...hat.com>, 
	Christian Loehle <christian.loehle@....com>, Hongyan Xia <hongyan.xia2@....com>, 
	John Stultz <jstultz@...gle.com>, linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v7] sched: Consolidate cpufreq updates

On Sun, 1 Sept 2024 at 20:01, Qais Yousef <qyousef@...alina.io> wrote:
>
> On 08/13/24 12:02, Vincent Guittot wrote:
> > >  void wakeup_preempt(struct rq *rq, struct task_struct *p, int flags)
> > > @@ -4913,6 +4923,93 @@ static inline void __balance_callbacks(struct rq *rq)
> > >
> > >  #endif
> > >
> > > +static __always_inline void
> > > +__update_cpufreq_ctx_switch(struct rq *rq, struct task_struct *prev)
> > > +{
> > > +#ifdef CONFIG_CPU_FREQ
> > > +       if (prev && prev->dl.flags & SCHED_FLAG_SUGOV) {
> > > +               /* Sugov just did an update, don't be too aggressive */
> > > +               return;
> > > +       }
> > > +
> > > +       /*
> > > +        * RT and DL should always send a freq update. But we can do some
> > > +        * simple checks to avoid it when we know it's not necessary.
> > > +        *
> > > +        * iowait_boost will always trigger a freq update too.
> > > +        *
> > > +        * Fair tasks will only trigger an update if the root cfs_rq has
> > > +        * decayed.
> > > +        *
> > > +        * Everything else should do nothing.
> > > +        */
> > > +       switch (current->policy) {
> > > +       case SCHED_NORMAL:
> > > +       case SCHED_BATCH:
> > > +       case SCHED_IDLE:
> > > +               if (unlikely(current->in_iowait)) {
> > > +                       cpufreq_update_util(rq, SCHED_CPUFREQ_IOWAIT | SCHED_CPUFREQ_FORCE_UPDATE);
> > > +                       return;
> > > +               }
> > > +
> > > +#ifdef CONFIG_SMP
> > > +               /*
> > > +                * Send an update if we switched from RT or DL as they tend to
> > > +                * boost the CPU and we are likely able to reduce the freq now.
> > > +                */
> > > +               rq->cfs.decayed |= prev && (rt_policy(prev->policy) || dl_policy(prev->policy));
> > > +
> > > +               if (unlikely(rq->cfs.decayed)) {
> >
> > My previous use case of a task non preempting current with large
> > util_est is fixed with this version but I'm facing a new one a bit
> > similar because of waiting for the context switch and the decay to try
> > to update the frequency.
> >
> > When the task wakes up on an idle cpu, you wait for the decay to
> > update the freq but if the freq is low and the pelt has been updated
> > recently (less than 1024us) you can wait a long time before the next
> > decay and the freq update. This is a problem if the task's util_est is
> > large because you can stay several ms at low frequency before taking
> > into account task's util_est
>
> It is a symptom of the same problem. It seems we don't decay and we omit the
> cpufreq update.
>
> Why this was not a problem before? AFAICT we only send an update before my
> patch if we had a decay and I didn't change this condition. Were we just
> getting more lucky or did I change some behavior unwittingly?

I'm not able to reproduce this behavior with current code but I don't
know why the behavior is different to be honest

>
> The problem with my patch is that I do this unconditional only if we failed
> preemption check. But looks like I must enforce a cpufreq update after every
> enqueue. I think the overhead of not checking rq->cfs.decayed would be high if
> we always call a cpufreq update.
>
> I'll just set rq->cfs.decayaed in util_est_enqueue() which should address both
> use cases.
>
> Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ