Messages in this thread | | | Subject | Re: [PATCH] sched/fair: Use 'unsigned long' for group_shares,group_runnable | From | "chengjian (D)" <> | Date | Mon, 15 Apr 2019 23:50:49 +0800 |
| |
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
| |