public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH][delayacct] Use portable cputime API in __delayacct_add_tsk()
@ 2006-05-10 12:06 Balbir Singh
  0 siblings, 0 replies; only message in thread
From: Balbir Singh @ 2006-05-10 12:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: lse-tech, akpm

Hi, Andrew,

While testing on ppc64, I found that taskstats could return incorrect data.
The same code worked fine on x86.

	Thanks,
	Balbir Singh,
	Linux Technology Center,
	IBM Software Labs


Description of the patch
------------------------

tsk->utime and tsk->stime are of type cputime_t. Explicitly converting from
cputime to nanoseconds does not work on all platforms. Use the cputime
API for conversion. This makes the code more portable and returns correct data
on ppc64.

This patch has been tested on x86 and ppc64.

Signed-off-by: Balbir Singh <balbir@in.ibm.com>
---

 kernel/delayacct.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)

diff -puN kernel/delayacct.c~taskstats-use-cputime-api-for-cpu_run_real_time kernel/delayacct.c
--- linux-2.6.17-rc3/kernel/delayacct.c~taskstats-use-cputime-api-for-cpu_run_real_time	2006-05-10 17:04:22.000000000 +0530
+++ linux-2.6.17-rc3-balbir/kernel/delayacct.c	2006-05-10 17:05:45.000000000 +0530
@@ -112,7 +112,8 @@ int __delayacct_add_tsk(struct taskstats
 	unsigned long t1,t2,t3;
 
 	tmp = (s64)d->cpu_run_real_total;
-	tmp += (u64)(tsk->utime + tsk->stime) * TICK_NSEC;
+	cputime_to_timespec(tsk->utime + tsk->stime, &ts);
+	tmp += timespec_to_ns(&ts);
 	d->cpu_run_real_total = (tmp < (s64)d->cpu_run_real_total) ? 0 : tmp;
 
 	/*
_

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-05-10 12:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-10 12:06 [PATCH][delayacct] Use portable cputime API in __delayacct_add_tsk() Balbir Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox