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]
Date:   Thu, 9 Mar 2023 17:43:56 +0800
From:   Zhang Qiao <zhangqiao22@...wei.com>
To:     Dietmar Eggemann <dietmar.eggemann@....com>
CC:     <mingo@...hat.com>, <peterz@...radead.org>,
        <juri.lelli@...hat.com>, <vincent.guittot@...aro.org>,
        <rostedt@...dmis.org>, <bsegall@...gle.com>, <mgorman@...e.de>,
        <bristot@...hat.com>, <vschneid@...hat.com>,
        <linux-kernel@...r.kernel.org>, <rkagan@...zon.de>
Subject: Re: [PATCH v2] sched/fair: sanitize vruntime of entity being migrated

Hi,

在 2023/3/7 20:45, Dietmar Eggemann 写道:
> On 06/03/2023 14:24, 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().
>>
>> Fixes: 829c1651e9c4 ("sched/fair: sanitize vruntime of entity being placed")
>> Suggested-by: Vincent Guittot <vincent.guittot@...aro.org>
>> Signed-off-by: Zhang Qiao <zhangqiao22@...wei.com>
> 
> [...]
> 
>> @@ -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
>> Isn't this the other way around? `vruntime += min_vruntime`

Yes, you're right, we can  refer to:

  enqueue_entity()

    ...
    if (renorm && !curr) {
      se->vruntime += cfs_rq->min_vruntime;
    ...


> 
>> +		 * enqueue, we only need to reset the se->vruntime of waking task
>> +		 * to a credit here.
> 
> You not reset it to credit, you subtract the credit from vruntime ?
> 
> I assume this is done to have sleeper credit accounted on both
> (se->vruntime and vruntime) for `se->vruntime =
> max_vruntime(se->vruntime, vruntime)` in place_entity() since
> entity_is_long_sleep(se)=false for a remove wakeup since `se->exec_start=0`.
> 
> 
>> +		 */
>> +		if (entity_is_long_sleep(se))
>> +			se->vruntime = -sched_sleeper_credit(se);

We subtract the credit here on the originating CPU since the long
sleeping task which migrates will go through:

  place_entity()

    else
      se->vruntime = max_vruntime(se->vruntime, vruntime (1));

and not the `if (entity_is_long_sleep(se))` path. And sleeper credit is
also subtracted from vruntime (1) before in place_entity().

IOW, We do the same thing in advance in migrate_task_rq_fair().
For the long sleeping task, se->vruntime is equal to vruntime(1) in place_entity().

Thanks.
ZhangQiao.


>> +		else
>> +			se->vruntime -= u64_u32_load(cfs_rq->min_vruntime);
> 
> Not sure I understand this part.
> Don't we have to do `vruntime -= min_vruntime` here for long sleeping
> task as well?
> 
> Since we always do the `vruntime += min_vruntime` on the new CPU for a
> remote wakeup.
> 
> [...]
> 
> .
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ