From: Johannes Weiner Date: Tue, 3 Dec 2019 18:35:24 +0000 (-0500) Subject: psi: Fix a division error in psi poll() X-Git-Tag: v5.5-rc3~12^2~2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c3466952ca1514158d7c16c9cfc48c27d5c5dc0f;p=users%2Fjedix%2Flinux-maple.git psi: Fix a division error in psi poll() 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 Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Suren Baghdasaryan Cc: Jingfeng Xie Link: https://lkml.kernel.org/r/20191203183524.41378-3-hannes@cmpxchg.org --- diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 970db4686dd44..ce8f6748678a2 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -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;