diff options
author | David Howells <dhowells@redhat.com> | 2008-07-25 04:48:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-25 13:53:47 -0400 |
commit | 3e85ba034deec351f02cb55ff225bbd616463841 (patch) | |
tree | 104931bdb095bd9f7cb987e50800a036b0c2dcb4 | |
parent | 297c5d92634c809cef23d73e7b2556f2528ff7e2 (diff) |
tsacct: fix bacct_add_tsk()'s use of do_div()
Fix bacct_add_tsk()'s use of do_div() on an s64 by making ac_etime a u64
instead and dividing that.
Possibly this should be guarded lest the interval calculation turn up
negative, but the possible negativity of the result of the division is
cast away, and it shouldn't end up negative anyway.
This was introduced by patch f3cef7a99469afc159fec3a61b42dc7ca5b6824f.
Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Jay Lan <jlan@engr.sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | kernel/tsacct.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/tsacct.c b/kernel/tsacct.c index 1da6990af8e0..3da47ccdc5e5 100644 --- a/kernel/tsacct.c +++ b/kernel/tsacct.c | |||
@@ -28,14 +28,14 @@ | |||
28 | void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk) | 28 | void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk) |
29 | { | 29 | { |
30 | struct timespec uptime, ts; | 30 | struct timespec uptime, ts; |
31 | s64 ac_etime; | 31 | u64 ac_etime; |
32 | 32 | ||
33 | BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN); | 33 | BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN); |
34 | 34 | ||
35 | /* calculate task elapsed time in timespec */ | 35 | /* calculate task elapsed time in timespec */ |
36 | do_posix_clock_monotonic_gettime(&uptime); | 36 | do_posix_clock_monotonic_gettime(&uptime); |
37 | ts = timespec_sub(uptime, tsk->start_time); | 37 | ts = timespec_sub(uptime, tsk->start_time); |
38 | /* rebase elapsed time to usec */ | 38 | /* rebase elapsed time to usec (should never be negative) */ |
39 | ac_etime = timespec_to_ns(&ts); | 39 | ac_etime = timespec_to_ns(&ts); |
40 | do_div(ac_etime, NSEC_PER_USEC); | 40 | do_div(ac_etime, NSEC_PER_USEC); |
41 | stats->ac_etime = ac_etime; | 41 | stats->ac_etime = ac_etime; |