From: tim <xiejingfeng@linux.alibaba.com>
To: Johannes Weiner <hannes@cmpxchg.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH] psi:fix divide by zero in psi_update_stats
Date: Fri, 08 Nov 2019 15:33:24 +0800 [thread overview]
Message-ID: <C377A5F1-F86F-4A27-966F-0285EC6EA934@linux.alibaba.com> (raw)
In psi_update_stats, it is possible that period has value like
0xXXXXXXXX00000000 where the lower 32 bit is 0, then it calls div_u64 which
truncates u64 period to u32, results in zero divisor.
Use div64_u64() instead of div_u64() if the divisor is u64 to avoid
truncation to 32-bit on 64-bit platforms.
Signed-off-by: xiejingfeng <xiejingfeng@linux.alibaba.com>
---
kernel/sched/psi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 517e3719027e..399d6f106de5 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -291,7 +291,7 @@ static void calc_avgs(unsigned long avg[3], int missed_periods,
}
/* Sample the most recent active period */
- pct = div_u64(time * 100, period);
+ pct = div64_u64(time * 100, period);
pct *= FIXED_1;
avg[0] = calc_load(avg[0], EXP_10s, pct);
avg[1] = calc_load(avg[1], EXP_60s, pct);
--
2.14.4.44.g2045bb
next reply other threads:[~2019-11-08 7:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 7:33 tim [this message]
2019-11-08 9:31 ` Peter Zijlstra
2019-11-08 9:49 ` Jingfeng Xie
2019-11-08 10:05 ` Peter Zijlstra
2019-11-12 15:41 ` Johannes Weiner
2019-11-12 15:48 ` Johannes Weiner
2019-11-12 16:08 ` Johannes Weiner
2019-11-12 17:27 ` Suren Baghdasaryan
2019-11-29 6:37 ` Jingfeng Xie
2019-11-30 1:41 ` Suren Baghdasaryan
2019-11-12 18:33 ` Suren Baghdasaryan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C377A5F1-F86F-4A27-966F-0285EC6EA934@linux.alibaba.com \
--to=xiejingfeng@linux.alibaba.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®