Linus,
Please pull the latest perf-probes-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git perf-probes-for-linus
This tree introduces the kprobes "jump optimization", which optimizes certain
types of (not all) kprobes. The performance advantage is significant:
x86-32 x86-64
kprobe: 0.80us 0.99us
kprobe+booster: 0.33us 0.43us
kprobe+optimized: 0.05us 0.06us
'perf probe' (based on CONFIG_KPROBES_TRACER) makes use of this optimization
by default - but AFAIK the SystemTap folks are also interested in this
optimization.
The tree also includes a number of further 'perf probe' improvements.
Thanks,
Ingo
------------------>
Masami Hiramatsu (18):
kprobes/x86: Cleanup RELATIVEJUMP_INSTRUCTION to RELATIVEJUMP_OPCODE
kprobes: Introduce generic insn_slot framework
kprobes: Introduce kprobes jump optimization
kprobes: Jump optimization sysctl interface
kprobes/x86: Boost probes when reentering
kprobes/x86: Cleanup save/restore registers
x86: Add text_poke_smp for SMP cross modifying code
kprobes/x86: Support kprobes jump optimization on x86
kprobes: Add documents of jump optimization
perf probe: Do not show --line option without dwarf support
perf probe: Update perf probe document
perf probe: Fix bugs in line range finder
perf probe: Rename probe finder functions
perf probe: Use elfutils-libdw for analyzing debuginfo
perf probe: Use libdw callback routines
perf probe: Check function address range strictly in line finder
perf probe: Show more lines after last line
perf probe: Add lazy line matching support
Documentation/kprobes.txt | 207 ++++++-
arch/Kconfig | 13 +
arch/x86/Kconfig | 1 +
arch/x86/include/asm/alternative.h | 4 +-
arch/x86/include/asm/kprobes.h ...Since this went in I'm seeing: kernel/kprobes.c:719: warning: ‘arm_kprobe’ defined but not used from the arch/ia64/configs/zx1_defconfig build on ia64 Looks to be because that config ends up with: CONFIG_KPROBES=y together with # CONFIG_DEBUG_FS is not set -Tony --
Hi Tony, Ah, thank you for reporting! Hmm, it seems that the place of definitions of enable_kprobe/disable_kprobe which call arm_kprobe/disarm_kprobe, are incorrect, because those functions are just API and don't depend on debugfs. I'll fix that. -- Masami Hiramatsu e-mail: mhiramat@redhat.com --
Move enable/disable_kprobe() API out from debugfs related code,
because these interfaces are not related to debugfs interface.
Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Reported-by: Tony Luck <tony.luck@intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
---
kernel/kprobes.c | 132 +++++++++++++++++++++++++++---------------------------
1 files changed, 66 insertions(+), 66 deletions(-)
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 0ed46f3..282035f 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1588,6 +1588,72 @@ static void __kprobes kill_kprobe(struct kprobe *p)
arch_remove_kprobe(p);
}
+/* Disable one kprobe */
+int __kprobes disable_kprobe(struct kprobe *kp)
+{
+ int ret = 0;
+ struct kprobe *p;
+
+ mutex_lock(&kprobe_mutex);
+
+ /* Check whether specified probe is valid. */
+ p = __get_valid_kprobe(kp);
+ if (unlikely(p == NULL)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ /* If the probe is already disabled (or gone), just return */
+ if (kprobe_disabled(kp))
+ goto out;
+
+ kp->flags |= KPROBE_FLAG_DISABLED;
+ if (p != kp)
+ /* When kp != p, p is always enabled. */
+ try_to_disable_aggr_kprobe(p);
+
+ if (!kprobes_all_disarmed && kprobe_disabled(p))
+ disarm_kprobe(p);
+out:
+ mutex_unlock(&kprobe_mutex);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(disable_kprobe);
+
+/* Enable one kprobe */
+int __kprobes enable_kprobe(struct kprobe *kp)
+{
+ int ret = 0;
+ struct kprobe *p;
+
+ mutex_lock(&kprobe_mutex);
+
+ /* Check whether specified probe is valid. */
+ p = __get_valid_kprobe(kp);
+ if (unlikely(p == NULL)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (kprobe_gone(kp)) {
+ /* This kprobe has gone, we couldn't enable it. */
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (p != kp)
+ kp->flags &= ~KPROBE_FLAG_DISABLED;
+
+ if (!kprobes_all_disarmed && kprobe_disabled(p)) {
+ p->flags &= ...Acked-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com> --
Fixes my build warnings. Acked-by: Tony Luck <tony.luck@intel.com> --
