diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index af7952f12e6cf19ac9b953fbbf54df823372f497..b453f8a6a7c76473ae8bdfb1b4ee668b3d110244 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -595,6 +595,12 @@ void cputime_adjust(struct task_cputime *curr, struct prev_cputime *prev, } stime = mul_u64_u64_div_u64(stime, rtime, stime + utime); + /* + * Because mul_u64_u64_div_u64() can approximate on some + * achitectures; enforce the constraint that: a*b/(b+c) <= a. + */ + if (unlikely(stime > rtime)) + stime = rtime; update: /*