Skip to content

Commit

Permalink
psi: Fix a division error in psi poll()
Browse files Browse the repository at this point in the history
The psi window size is a u64 an can be up to 10 seconds right now,
which exceeds the lower 32 bits of the variable. We currently use
div_u64 for it, which is meant only for 32-bit divisors. The result is
garbage pressure sampling values and even potential div0 crashes.

Use div64_u64.

Signed-off-by: Johannes Weiner <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Reviewed-by: Suren Baghdasaryan <[email protected]>
Cc: Jingfeng Xie <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
  • Loading branch information
hnaz authored and Peter Zijlstra committed Dec 17, 2019
1 parent 3dfbe25 commit c346695
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/sched/psi.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ static u64 window_update(struct psi_window *win, u64 now, u64 value)
u32 remaining;

remaining = win->size - elapsed;
growth += div_u64(win->prev_growth * remaining, win->size);
growth += div64_u64(win->prev_growth * remaining, win->size);
}

return growth;
Expand Down

0 comments on commit c346695

Please sign in to comment.