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: <CAKfTPtAf5RrzZRSHtfK+r3QvnFQ-oM3+rJ-z5SB8T4+nUv1aQw@mail.gmail.com>
Date:   Thu, 9 Mar 2023 14:34:05 +0100
From:   Vincent Guittot <vincent.guittot@...aro.org>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Zhang Qiao <zhangqiao22@...wei.com>, linux-kernel@...r.kernel.org,
        mingo@...hat.com, juri.lelli@...hat.com, dietmar.eggemann@....com,
        rostedt@...dmis.org, bsegall@...gle.com, mgorman@...e.de,
        bristot@...hat.com, vschneid@...hat.com, rkagan@...zon.de
Subject: Re: [PATCH v2] sched/fair: sanitize vruntime of entity being migrated

On Thu, 9 Mar 2023 at 14:05, Peter Zijlstra <peterz@...radead.org> wrote:
>
> On Mon, Mar 06, 2023 at 09:24:18PM +0800, Zhang Qiao wrote:
> > Commit 829c1651e9c4 ("sched/fair: sanitize vruntime of
> > entity being placed") fix an overflowing bug, but ignore
> > a case that se->exec_start is reset after a migration.
> >
> > For fixing this case, we reset the vruntime of a long
> > sleeping task in migrate_task_rq_fair().
> >
>
> > @@ -7635,7 +7653,23 @@ static void migrate_task_rq_fair(struct task_struct *p, int new_cpu)
> >       if (READ_ONCE(p->__state) == TASK_WAKING) {
> >               struct cfs_rq *cfs_rq = cfs_rq_of(se);
> >
> > -             se->vruntime -= u64_u32_load(cfs_rq->min_vruntime);
> > +             /*
> > +              * We determine whether a task sleeps for long by checking
> > +              * se->exec_start, and if it is, we sanitize its vruntime at
> > +              * place_entity(). However, after a migration, this detection
> > +              * method fails due to se->exec_start being reset.
> > +              *
> > +              * For fixing this case, we add the same check here. For a task
> > +              * which has slept for a long time, its vruntime should be reset
> > +              * to cfs_rq->min_vruntime with a sleep credit. Because waking
> > +              * task's vruntime will be added to cfs_rq->min_vruntime when
> > +              * enqueue, we only need to reset the se->vruntime of waking task
> > +              * to a credit here.
> > +              */
> > +             if (entity_is_long_sleep(se))
> > +                     se->vruntime = -sched_sleeper_credit(se);
> > +             else
> > +                     se->vruntime -= u64_u32_load(cfs_rq->min_vruntime);
> >       }
>
> *groan*, that again...
>
> Can't we simply do:
>
> https://lkml.kernel.org/r/68832dfbb60fda030540b5f4e39c5801942689b1.1648228023.git.tim.c.chen@linux.intel.com

I'm not sure this would help here, exec_start == 0 can be easily
managed in place_entity

The problem stands for task about to be migrated out of taking prev_cpu lock

Then, even if we don't clear exec_start before migrating and keep
current value to be used in place_entity on the new cpu, we can't
compare the rq_clock_task(rq_of(cfs_rq)) of 2 different rqs AFAICT

side note, why do we reset exec_start ? Is it only to make task_hot
returns false ?

>
> ?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ