Commit e75e863dd5c7d96b91ebbd241da5328fc38a78cc
Committed by
Ingo Molnar
1 parent
9c03f1622a
Exists in
master
and in
39 other branches
sched: Fix user time incorrectly accounted as system time on 32-bit
We have 32-bit variable overflow possibility when multiply in task_times() and thread_group_times() functions. When the overflow happens then the scaled utime value becomes erroneously small and the scaled stime becomes i erroneously big. Reported here: https://bugzilla.redhat.com/show_bug.cgi?id=633037 https://bugzilla.kernel.org/show_bug.cgi?id=16559 Reported-by: Michael Chapman <redhat-bugzilla@very.puzzling.org> Reported-by: Ciriaco Garcia de Celis <sysman@etherpilot.com> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> Cc: <stable@kernel.org> # 2.6.32.19+ (partially) and 2.6.33+ LKML-Reference: <20100914143513.GB8415@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Showing 1 changed file with 4 additions and 4 deletions Side-by-side Diff
kernel/sched.c
... | ... | @@ -3513,9 +3513,9 @@ |
3513 | 3513 | rtime = nsecs_to_cputime(p->se.sum_exec_runtime); |
3514 | 3514 | |
3515 | 3515 | if (total) { |
3516 | - u64 temp; | |
3516 | + u64 temp = rtime; | |
3517 | 3517 | |
3518 | - temp = (u64)(rtime * utime); | |
3518 | + temp *= utime; | |
3519 | 3519 | do_div(temp, total); |
3520 | 3520 | utime = (cputime_t)temp; |
3521 | 3521 | } else |
3522 | 3522 | |
... | ... | @@ -3546,9 +3546,9 @@ |
3546 | 3546 | rtime = nsecs_to_cputime(cputime.sum_exec_runtime); |
3547 | 3547 | |
3548 | 3548 | if (total) { |
3549 | - u64 temp; | |
3549 | + u64 temp = rtime; | |
3550 | 3550 | |
3551 | - temp = (u64)(rtime * cputime.utime); | |
3551 | + temp *= cputime.utime; | |
3552 | 3552 | do_div(temp, total); |
3553 | 3553 | utime = (cputime_t)temp; |
3554 | 3554 | } else |