lkml.org 
[lkml]   [2006]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [PATCH 0/11] LTTng-core (basic tracing infrastructure) 0.5.108

    * Ingo Molnar <mingo@elte.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.

    Ingo

    --------------->
    Subject: [patch] kprobes: speed INT3 trap handling up on i386
    From: Ingo Molnar <mingo@elte.hu>

    speed up kprobes trap handling by special-casing kernel-space
    INT3 traps (which do not occur otherwise) and doing a kprobes
    handler check - instead of redirecting over the i386-die-notifier
    chain.

    Signed-off-by: Ingo Molnar <mingo@elte.hu>
    ---
    arch/i386/kernel/kprobes.c | 2 +-
    arch/i386/kernel/traps.c | 19 ++++++++++++-------
    include/asm-i386/kprobes.h | 2 ++
    3 files changed, 15 insertions(+), 8 deletions(-)

    Index: linux/arch/i386/kernel/kprobes.c
    ===================================================================
    --- linux.orig/arch/i386/kernel/kprobes.c
    +++ linux/arch/i386/kernel/kprobes.c
    @@ -200,7 +200,7 @@ void __kprobes arch_prepare_kretprobe(st
    * Interrupts are disabled on entry as trap3 is an interrupt gate and they
    * remain disabled thorough out this function.
    */
    -static int __kprobes kprobe_handler(struct pt_regs *regs)
    +int __kprobes kprobe_handler(struct pt_regs *regs)
    {
    struct kprobe *p;
    int ret = 0;
    Index: linux/arch/i386/kernel/traps.c
    ===================================================================
    --- linux.orig/arch/i386/kernel/traps.c
    +++ linux/arch/i386/kernel/traps.c
    @@ -802,13 +802,18 @@ EXPORT_SYMBOL_GPL(unset_nmi_callback);
    #ifdef CONFIG_KPROBES
    fastcall void __kprobes do_int3(struct pt_regs *regs, long error_code)
    {
    - if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
    - == NOTIFY_STOP)
    - return;
    - /* This is an interrupt gate, because kprobes wants interrupts
    - disabled. Normal trap handlers don't. */
    - restore_interrupts(regs);
    - do_trap(3, SIGTRAP, "int3", 1, regs, error_code, NULL);
    + /*
    + * kernel-mode INT3s are likely kprobes:
    + */
    + if (!user_mode(regs)) {
    + if (kprobe_handler(regs))
    + return;
    + /* This is an interrupt gate, because kprobes wants interrupts
    + disabled. Normal trap handlers don't. */
    + restore_interrupts(regs);
    + do_trap(3, SIGTRAP, "int3", 1, regs, error_code, NULL);
    + }
    + notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP);
    }
    #endif

    Index: linux/include/asm-i386/kprobes.h
    ===================================================================
    --- linux.orig/include/asm-i386/kprobes.h
    +++ linux/include/asm-i386/kprobes.h
    @@ -88,4 +88,6 @@ static inline void restore_interrupts(st

    extern int kprobe_exceptions_notify(struct notifier_block *self,
    unsigned long val, void *data);
    +extern int kprobe_handler(struct pt_regs *regs);
    +
    #endif /* _ASM_KPROBES_H */
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/
    \
     
     \ /
      Last update: 2006-09-16 21:49    [W:4.302 / U:0.068 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site