[PATCH] tsacct: optimize acct_update_integrals

From: Martin Schwidefsky
Date: Wed Jul 03 2013 - 04:53:06 EST


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 <schwidefsky@xxxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/