* [PATCH v2] sched: fix user time incorrectly accounted as system time on 32 bit
@ 2010-09-14 14:35 Stanislaw Gruszka
2010-09-14 14:37 ` Peter Zijlstra
2010-09-15 10:01 ` [tip:sched/urgent] sched: Fix user time incorrectly accounted as system time on 32-bit tip-bot for Stanislaw Gruszka
0 siblings, 2 replies; 3+ messages in thread
From: Stanislaw Gruszka @ 2010-09-14 14:35 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Hidetoshi Seto, Peter Zijlstra, stable,
Michael Chapman, Ciriaco Garcia de Celis
We have 32 bit variable overflow possibility when multiply in
task_times() and thread_group_times() functions. If overflow happens
calculated scaled utime value become wrongly small and scaled stime
wrongly 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>
Cc: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: <stable@kernel.org> # 2.6.32.19+ (partially) and 2.6.33+
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
v1 -> v2
Fix mail recipients.
kernel/sched.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index 09b574e..eee9470 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3507,9 +3507,9 @@ void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
rtime = nsecs_to_cputime(p->se.sum_exec_runtime);
if (total) {
- u64 temp;
+ u64 temp = rtime;
- temp = (u64)(rtime * utime);
+ temp *= utime;
do_div(temp, total);
utime = (cputime_t)temp;
} else
@@ -3540,9 +3540,9 @@ void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
rtime = nsecs_to_cputime(cputime.sum_exec_runtime);
if (total) {
- u64 temp;
+ u64 temp = rtime;
- temp = (u64)(rtime * cputime.utime);
+ temp *= cputime.utime;
do_div(temp, total);
utime = (cputime_t)temp;
} else
--
1.7.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] sched: fix user time incorrectly accounted as system time on 32 bit
2010-09-14 14:35 [PATCH v2] sched: fix user time incorrectly accounted as system time on 32 bit Stanislaw Gruszka
@ 2010-09-14 14:37 ` Peter Zijlstra
2010-09-15 10:01 ` [tip:sched/urgent] sched: Fix user time incorrectly accounted as system time on 32-bit tip-bot for Stanislaw Gruszka
1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2010-09-14 14:37 UTC (permalink / raw)
To: Stanislaw Gruszka
Cc: Ingo Molnar, linux-kernel, Hidetoshi Seto, stable,
Michael Chapman, Ciriaco Garcia de Celis
On Tue, 2010-09-14 at 16:35 +0200, Stanislaw Gruszka wrote:
> We have 32 bit variable overflow possibility when multiply in
> task_times() and thread_group_times() functions. If overflow happens
> calculated scaled utime value become wrongly small and scaled stime
> wrongly big.
Ah, right, (u64)foo * bar would have worked too I guess, but yeah, the
used (u64)(foo * bar) is wrong.
> 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>
> Cc: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: <stable@kernel.org> # 2.6.32.19+ (partially) and 2.6.33+
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Thanks, got it.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip:sched/urgent] sched: Fix user time incorrectly accounted as system time on 32-bit
2010-09-14 14:35 [PATCH v2] sched: fix user time incorrectly accounted as system time on 32 bit Stanislaw Gruszka
2010-09-14 14:37 ` Peter Zijlstra
@ 2010-09-15 10:01 ` tip-bot for Stanislaw Gruszka
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Stanislaw Gruszka @ 2010-09-15 10:01 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, seto.hidetoshi, a.p.zijlstra,
redhat-bugzilla, sysman, tglx, sgruszka, mingo
Commit-ID: e75e863dd5c7d96b91ebbd241da5328fc38a78cc
Gitweb: http://git.kernel.org/tip/e75e863dd5c7d96b91ebbd241da5328fc38a78cc
Author: Stanislaw Gruszka <sgruszka@redhat.com>
AuthorDate: Tue, 14 Sep 2010 16:35:14 +0200
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 15 Sep 2010 10:41:36 +0200
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>
---
kernel/sched.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index ed09d4f..dc85ceb 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3513,9 +3513,9 @@ void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
rtime = nsecs_to_cputime(p->se.sum_exec_runtime);
if (total) {
- u64 temp;
+ u64 temp = rtime;
- temp = (u64)(rtime * utime);
+ temp *= utime;
do_div(temp, total);
utime = (cputime_t)temp;
} else
@@ -3546,9 +3546,9 @@ void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
rtime = nsecs_to_cputime(cputime.sum_exec_runtime);
if (total) {
- u64 temp;
+ u64 temp = rtime;
- temp = (u64)(rtime * cputime.utime);
+ temp *= cputime.utime;
do_div(temp, total);
utime = (cputime_t)temp;
} else
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-09-15 10:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-14 14:35 [PATCH v2] sched: fix user time incorrectly accounted as system time on 32 bit Stanislaw Gruszka
2010-09-14 14:37 ` Peter Zijlstra
2010-09-15 10:01 ` [tip:sched/urgent] sched: Fix user time incorrectly accounted as system time on 32-bit tip-bot for Stanislaw Gruszka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome