2013-07-03 08:52:13

by Martin Schwidefsky

[permalink] [raw]
Subject: [PATCH] tsacct: optimize acct_update_integrals

The conversion of a cputime to micro seconds can be done without the
detour via jiffies. This avoids unnecessary and costly calculations,
e.g. on s390 a 64-bit division and a multiplication can be replaced
with a simple shift.

Signed-off-by: Martin Schwidefsky <[email protected]>
---
kernel/tsacct.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index a1dd9a1..bf09be1 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -126,16 +126,13 @@ static void __acct_update_integrals(struct task_struct *tsk,
{
if (likely(tsk->mm)) {
cputime_t time, dtime;
- struct timeval value;
unsigned long flags;
u64 delta;

local_irq_save(flags);
time = stime + utime;
dtime = time - tsk->acct_timexpd;
- jiffies_to_timeval(cputime_to_jiffies(dtime), &value);
- delta = value.tv_sec;
- delta = delta * USEC_PER_SEC + value.tv_usec;
+ delta = cputime_to_usecs(dtime);

if (delta == 0)
goto out;
--
1.7.9.5