mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 06:02:05 +00:00
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 f3cef7a994
.
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>
This commit is contained in:
parent
297c5d9263
commit
3e85ba034d
@ -28,14 +28,14 @@
|
||||
void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
|
||||
{
|
||||
struct timespec uptime, ts;
|
||||
s64 ac_etime;
|
||||
u64 ac_etime;
|
||||
|
||||
BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN);
|
||||
|
||||
/* calculate task elapsed time in timespec */
|
||||
do_posix_clock_monotonic_gettime(&uptime);
|
||||
ts = timespec_sub(uptime, tsk->start_time);
|
||||
/* rebase elapsed time to usec */
|
||||
/* rebase elapsed time to usec (should never be negative) */
|
||||
ac_etime = timespec_to_ns(&ts);
|
||||
do_div(ac_etime, NSEC_PER_USEC);
|
||||
stats->ac_etime = ac_etime;
|
||||
|
Loading…
Reference in New Issue
Block a user