Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 191098
b: refs/heads/master
c: e4713e9
h: refs/heads/master
v: v3
  • Loading branch information
Ingo Molnar committed Mar 17, 2010
1 parent bc10a30 commit 149082c
Show file tree
Hide file tree
Showing 37 changed files with 2,989 additions and 425 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a6b84574eed7e4fd8cb8dac2d0926fe2cf34b941
refs/heads/master: e4713e93b125497e9ba44d93de1bd9d8e5ad8946
10 changes: 2 additions & 8 deletions trunk/Documentation/kprobes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ the user entry_handler invocation is also skipped.

1.4 How Does Jump Optimization Work?

If you configured your kernel with CONFIG_OPTPROBES=y (currently
this option is supported on x86/x86-64, non-preemptive kernel) and
If your kernel is built with CONFIG_OPTPROBES=y (currently this flag
is automatically set 'y' on x86/x86-64, non-preemptive kernel) and
the "debug.kprobes_optimization" kernel parameter is set to 1 (see
sysctl(8)), Kprobes tries to reduce probe-hit overhead by using a jump
instruction instead of a breakpoint instruction at each probepoint.
Expand Down Expand Up @@ -271,8 +271,6 @@ tweak the kernel's execution path, you need to suppress optimization,
using one of the following techniques:
- Specify an empty function for the kprobe's post_handler or break_handler.
or
- Config CONFIG_OPTPROBES=n.
or
- Execute 'sysctl -w debug.kprobes_optimization=n'

2. Architectures Supported
Expand Down Expand Up @@ -307,10 +305,6 @@ it useful to "Compile the kernel with debug info" (CONFIG_DEBUG_INFO),
so you can use "objdump -d -l vmlinux" to see the source-to-object
code mapping.

If you want to reduce probing overhead, set "Kprobes jump optimization
support" (CONFIG_OPTPROBES) to "y". You can find this option under the
"Kprobes" line.

4. API Reference

The Kprobes API includes a "register" function and an "unregister"
Expand Down
9 changes: 2 additions & 7 deletions trunk/arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,10 @@ config KPROBES
If in doubt, say "N".

config OPTPROBES
bool "Kprobes jump optimization support (EXPERIMENTAL)"
default y
depends on KPROBES
def_bool y
depends on KPROBES && HAVE_OPTPROBES
depends on !PREEMPT
depends on HAVE_OPTPROBES
select KALLSYMS_ALL
help
This option will allow kprobes to optimize breakpoint to
a jump for reducing its overhead.

config HAVE_EFFICIENT_UNALIGNED_ACCESS
bool
Expand Down
3 changes: 3 additions & 0 deletions trunk/arch/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ config X86
select HAVE_ARCH_KMEMCHECK
select HAVE_USER_RETURN_NOTIFIER

config INSTRUCTION_DECODER
def_bool (KPROBES || PERF_EVENTS)

config OUTPUT_FORMAT
string
default "elf32-i386" if X86_32
Expand Down
2 changes: 2 additions & 0 deletions trunk/arch/x86/include/asm/insn.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ struct insn {
const insn_byte_t *next_byte;
};

#define MAX_INSN_SIZE 16

#define X86_MODRM_MOD(modrm) (((modrm) & 0xc0) >> 6)
#define X86_MODRM_REG(modrm) (((modrm) & 0x38) >> 3)
#define X86_MODRM_RM(modrm) ((modrm) & 0x07)
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/include/asm/kprobes.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/types.h>
#include <linux/ptrace.h>
#include <linux/percpu.h>
#include <asm/insn.h>

#define __ARCH_WANT_KPROBES_INSN_SLOT

Expand All @@ -36,7 +37,6 @@ typedef u8 kprobe_opcode_t;
#define RELATIVEJUMP_SIZE 5
#define RELATIVECALL_OPCODE 0xe8
#define RELATIVE_ADDR_SIZE 4
#define MAX_INSN_SIZE 16
#define MAX_STACK_SIZE 64
#define MIN_STACK_SIZE(ADDR) \
(((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
Expand Down
21 changes: 20 additions & 1 deletion trunk/arch/x86/include/asm/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Performance event hw details:
*/

#define X86_PMC_MAX_GENERIC 8
#define X86_PMC_MAX_GENERIC 32
#define X86_PMC_MAX_FIXED 3

#define X86_PMC_IDX_GENERIC 0
Expand Down Expand Up @@ -136,6 +136,25 @@ extern void perf_events_lapic_init(void);

#define PERF_EVENT_INDEX_OFFSET 0

/*
* Abuse bit 3 of the cpu eflags register to indicate proper PEBS IP fixups.
* This flag is otherwise unused and ABI specified to be 0, so nobody should
* care what we do with it.
*/
#define PERF_EFLAGS_EXACT (1UL << 3)

#define perf_misc_flags(regs) \
({ int misc = 0; \
if (user_mode(regs)) \
misc |= PERF_RECORD_MISC_USER; \
else \
misc |= PERF_RECORD_MISC_KERNEL; \
if (regs->flags & PERF_EFLAGS_EXACT) \
misc |= PERF_RECORD_MISC_EXACT; \
misc; })

#define perf_instruction_pointer(regs) ((regs)->ip)

#else
static inline void init_hw_perf_events(void) { }
static inline void perf_events_lapic_init(void) { }
Expand Down
Loading

0 comments on commit 149082c

Please sign in to comment.