1
0
Fork 0

psi: Fix a division error in psi poll()

[ Upstream commit c3466952ca ]

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 <hannes@cmpxchg.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Cc: Jingfeng Xie <xiejingfeng@linux.alibaba.com>
Link: https://lkml.kernel.org/r/20191203183524.41378-3-hannes@cmpxchg.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
5.4-rM2-2.2.x-imx-squashed
Johannes Weiner 2019-12-03 13:35:24 -05:00 committed by Greg Kroah-Hartman
parent 74e2bdcb7d
commit 4e38135180
1 changed files with 1 additions and 1 deletions

View File

@ -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;