Re: [PATCH v2] sched/eevdf: Prevent vlag from going out of bounds when reweight_eevdf
From: Peter Zijlstra
Date: Mon Apr 22 2024 - 12:00:03 EST
On Mon, Apr 22, 2024 at 09:12:12PM +0800, Xuewen Yan wrote:
> By adding a log to observe weight changes in reweight_entity, I found
> that calc_group_shares() often causes new_weight to become very small:
Yes, cgroups do that. But over-all that should not matter no?
Specifically, the whole re-weight thing turns into a series like:
w_0 w_1 w_n-1 w_0
S = --- * --- * ... * ----- = ---
w_1 w_2 w_n w_n
Where S is our ultimate scale factor.
So even if w_m (0 < m < n) is 2, it completely disappears. But yes, it
will create a big term, which is why the initial vlag should be limited.
Notably, nice should not exceed 88761*1024 / 2, but I'm not sure I
remember the limits (if there are any on the cgrou pmuck).
But if roughly 27 bits go to weight, then vlag should not exceed 36,
which should be well within the slice limit iirc.
Also, as said before, due to integer division being truncating, the
actual S should be smaller than the expected S due to error
accumulation.
Anyway, the things to verify are:
- the S series is complete -- missing terms will mess things up right
quick;
- the limits on both the weight and vlag part, their sum exceeding
63bit (plut 1 for sign) will also mess things up.