From: Peter Zijlstra <peterz@infradead.org>
To: riel@redhat.com
Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de,
mingo@kernel.org, luto@amacapital.net, fweisbec@gmail.com
Subject: Re: [PATCH 1/2] sched,time: remove pointless divides from __acct_update_integrals
Date: Sat, 30 Jan 2016 00:10:18 +0100 [thread overview]
Message-ID: <20160129231018.GK6357@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1454106180-20918-2-git-send-email-riel@redhat.com>
On Fri, Jan 29, 2016 at 05:22:59PM -0500, riel@redhat.com wrote:
> From: Rik van Riel <riel@redhat.com>
>
> When running a microbenchmark calling an invalid syscall number
> in a loop, on a nohz_full CPU, we spend a full 9% of our CPU
> time in __acct_update_integrals.
>
> This function converts cputime_t to jiffies, to a timeval, only to
> convert the timeval back to microseconds before discarding it.
>
> This patch leaves __acct_update_integrals functionally equivalent,
> but speeds things up by about 11%, with 10 million calls to an
> invalid syscall number dropping from 3.7 to 3.3 seconds.
WTH is this taskstat crap anyway? Who uses it and can't we kill it?
There seems to be an endless reserve of accounting crap.
> +++ b/kernel/tsacct.c
> @@ -125,22 +125,22 @@ static void __acct_update_integrals(struct task_struct *tsk,
> {
> if (likely(tsk->mm)) {
> cputime_t time, dtime;
> unsigned long flags;
> + u64 delta, usecs;
>
> local_irq_save(flags);
> time = stime + utime;
> dtime = time - tsk->acct_timexpd;
> + delta = cputime_to_jiffies(dtime);
>
> if (delta == 0)
> goto out;
> +
> + usecs = jiffies_to_usecs(delta);
> +
> tsk->acct_timexpd = time;
> + tsk->acct_rss_mem1 += usecs * get_mm_rss(tsk->mm);
> + tsk->acct_vm_mem1 += usecs * tsk->mm->total_vm;
> out:
> local_irq_restore(flags);
> }
Hurch, what horrible code.
Can't you at least drop the pointless indent level while you're there
anyway?
Also, it looks like the callpath through acct_account_cputime() should
already guarantee IRQs are disabled, so if you move the irq_save /
irq_restore business into acct_update_integrals() you can remove them
too from the fast path.
And I think you can kill that last divide too, if you do something like:
nsecs = cputime_to_nsecs(dtime);
if (nsecs < TICK_NSEC)
goto out;
usecs = nsecs >> 10;
...
And if people really care, you can correct the 1024 != 1000 thing in
xacct_add_tsk() which seems to be the consumer side and thus should be
exceedingly rare.
next prev parent reply other threads:[~2016-01-29 23:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-29 22:22 [PATCH 0/2] sched,time: reduce nohz_full syscall overhead 40% riel
2016-01-29 22:22 ` [PATCH 1/2] sched,time: remove pointless divides from __acct_update_integrals riel
2016-01-29 23:10 ` Peter Zijlstra [this message]
2016-01-30 3:36 ` Frederic Weisbecker
2016-01-30 3:47 ` Rik van Riel
2016-01-29 22:23 ` [PATCH 2/2] sched,time: call __acct_update_integrals once a jiffy riel
2016-01-29 22:43 ` Rik van Riel
2016-01-30 14:20 ` Frederic Weisbecker
2016-01-30 17:53 ` Mike Galbraith
2016-01-30 20:36 ` Frederic Weisbecker
2016-01-31 2:52 ` Mike Galbraith
2016-01-31 5:37 ` Mike Galbraith
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160129231018.GK6357@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=riel@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.