lkml.org 
[lkml]   [2019]   [Apr]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] sched/fair: Use 'unsigned long' for group_shares,group_runnable
From
Date

On 2019/4/15 23:25, Peter Zijlstra wrote:
> On Mon, Apr 15, 2019 at 11:20:31PM +0800, chengjian (D) wrote:
>> Hi, Peter
>>
>>
>> On 2019/4/15 20:46, Peter Zijlstra wrote:
>>
>> I write a demo about this, which I described it as overflow.
> I'm not saying there's no overflow, I'm saying there's nothing UB about
> it.
>

Yeah. I got it.

This may not be an undefined behavior,

but rather a bug or logic error caused by overflow.


```cpp


static long calc_group_shares(struct cfs_rq *cfs_rq)
{

    // ......

    shares = (tg_shares * load);   // 1048576 * 9144968455305  =
-8857549630719655936 (OVERFLOW)
    if (tg_weight)                         // assume tg_weight is 3
        shares /= tg_weight;         //  0xd7068dd8c2daaaab shoule be
0x2c5be32e18300000
}

```


It will cause `se->runnable_weight` to have an incorrect value in
reweight_entity().


Thanks.

CHENG Jian


\
 
 \ /
  Last update: 2019-04-15 17:51    [W:0.042 / U:0.708 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site