[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20060916202939.GA4520@elte.hu>
Date: Sat, 16 Sep 2006 22:29:39 +0200
From: Ingo Molnar <mingo@...e.hu>
To: Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
Cc: Jes Sorensen <jes@....com>, Roman Zippel <zippel@...ux-m68k.org>,
Andrew Morton <akpm@...l.org>, tglx@...utronix.de,
karim@...rsys.com, Paul Mundt <lethal@...ux-sh.org>,
linux-kernel@...r.kernel.org,
Christoph Hellwig <hch@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Greg Kroah-Hartman <gregkh@...e.de>,
Tom Zanussi <zanussi@...ibm.com>, ltt-dev@...fik.org,
Michel Dagenais <michel.dagenais@...ymtl.ca>
Subject: [patch] kprobes: optimize branch placement
* Ingo Molnar <mingo@...e.hu> wrote:
> * Ingo Molnar <mingo@...e.hu> wrote:
>
> > and have measured the overhead of an unmodified, kprobes-probed and
> > djprobes-probed sys_getpid() system-call:
> >
> > sys_getpid() unmodified latency: 317 cycles [ 0.146 usecs ]
> > sys_getpid() kprobes latency: 815 cycles [ 0.377 usecs ]
> > sys_getpid() djprobes latency: 380 cycles [ 0.176 usecs ]
>
> i have taken a look at the kprobes fastpath, and there are a few things
> we can do to speed it up. The patch below shaves off 75 cycles from the
> kprobes overhead:
>
> sys_getpid() kprobes-speedup: 740 cycles [ 0.342 usecs ]
>
> that reduces the kprobes overhead to 423 cycles.
the patch below brings the overhead down to 420 cycles:
sys_getpid() kprobes-speedup: 737 cycles [ 0.341 usecs ]
Ingo
---------->
Subject: [patch] kprobes: optimize branch placement
From: Ingo Molnar <mingo@...e.hu>
optimize gcc's code generation by hinting branch probabilities.
Signed-off-by: Ingo Molnar <mingo@...e.hu>
---
arch/i386/kernel/kprobes.c | 2 +-
arch/i386/kernel/traps.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
Index: linux/arch/i386/kernel/kprobes.c
===================================================================
--- linux.orig/arch/i386/kernel/kprobes.c
+++ linux/arch/i386/kernel/kprobes.c
@@ -220,7 +220,7 @@ int __kprobes kprobe_handler(struct pt_r
kcb = get_kprobe_ctlblk();
/* Check we're not actually recursing */
- if (kprobe_running()) {
+ if (unlikely(kprobe_running())) {
p = get_kprobe(addr);
if (p) {
if (kcb->kprobe_status == KPROBE_HIT_SS &&
Index: linux/arch/i386/kernel/traps.c
===================================================================
--- linux.orig/arch/i386/kernel/traps.c
+++ linux/arch/i386/kernel/traps.c
@@ -806,7 +806,7 @@ fastcall void __kprobes do_int3(struct p
* kernel-mode INT3s are likely kprobes:
*/
if (!user_mode(regs)) {
- if (kprobe_handler(regs))
+ if (likely(kprobe_handler(regs)))
return;
/* This is an interrupt gate, because kprobes wants interrupts
disabled. Normal trap handlers don't. */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists