Skip to content

Commit 3e85ba0

Browse files
dhowellstorvalds
authored andcommitted
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 f3cef7a. 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>
1 parent 297c5d9 commit 3e85ba0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎kernel/tsacct.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
2929
{
3030
struct timespec uptime, ts;
31-
s64 ac_etime;
31+
u64 ac_etime;
3232

3333
BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN);
3434

3535
/* calculate task elapsed time in timespec */
3636
do_posix_clock_monotonic_gettime(&uptime);
3737
ts = timespec_sub(uptime, tsk->start_time);
38-
/* rebase elapsed time to usec */
38+
/* rebase elapsed time to usec (should never be negative) */
3939
ac_etime = timespec_to_ns(&ts);
4040
do_div(ac_etime, NSEC_PER_USEC);
4141
stats->ac_etime = ac_etime;

0 commit comments

Comments
 (0)