diff options
-rw-r--r-- | Documentation/trace/kprobetrace.txt | 34 | ||||
-rw-r--r-- | kernel/trace/Kconfig | 19 | ||||
-rw-r--r-- | kernel/trace/Makefile | 2 | ||||
-rw-r--r-- | kernel/trace/trace_kprobe.c | 6 |
4 files changed, 31 insertions, 30 deletions
diff --git a/Documentation/trace/kprobetrace.txt b/Documentation/trace/kprobetrace.txt index 15415243a9a3..47aabeebbdf6 100644 --- a/Documentation/trace/kprobetrace.txt +++ b/Documentation/trace/kprobetrace.txt | |||
@@ -1,26 +1,23 @@ | |||
1 | Kprobe-based Event Tracer | 1 | Kprobe-based Event Tracing |
2 | ========================= | 2 | ========================== |
3 | 3 | ||
4 | Documentation is written by Masami Hiramatsu | 4 | Documentation is written by Masami Hiramatsu |
5 | 5 | ||
6 | 6 | ||
7 | Overview | 7 | Overview |
8 | -------- | 8 | -------- |
9 | This tracer is similar to the events tracer which is based on Tracepoint | 9 | These events are similar to tracepoint based events. Instead of Tracepoint, |
10 | infrastructure. Instead of Tracepoint, this tracer is based on kprobes(kprobe | 10 | this is based on kprobes (kprobe and kretprobe). So it can probe wherever |
11 | and kretprobe). It probes anywhere where kprobes can probe(this means, all | 11 | kprobes can probe (this means, all functions body except for __kprobes |
12 | functions body except for __kprobes functions). | 12 | functions). Unlike the Tracepoint based event, this can be added and removed |
13 | dynamically, on the fly. | ||
13 | 14 | ||
14 | Unlike the function tracer, this tracer can probe instructions inside of | 15 | To enable this feature, build your kernel with CONFIG_KPROBE_TRACING=y. |
15 | kernel functions. It allows you to check which instruction has been executed. | ||
16 | 16 | ||
17 | Unlike the Tracepoint based events tracer, this tracer can add and remove | 17 | Similar to the events tracer, this doesn't need to be activated via |
18 | probe points on the fly. | 18 | current_tracer. Instead of that, add probe points via |
19 | 19 | /sys/kernel/debug/tracing/kprobe_events, and enable it via | |
20 | Similar to the events tracer, this tracer doesn't need to be activated via | 20 | /sys/kernel/debug/tracing/events/kprobes/<EVENT>/enabled. |
21 | current_tracer, instead of that, just set probe points via | ||
22 | /sys/kernel/debug/tracing/kprobe_events. And you can set filters on each | ||
23 | probe events via /sys/kernel/debug/tracing/events/kprobes/<EVENT>/filter. | ||
24 | 21 | ||
25 | 22 | ||
26 | Synopsis of kprobe_events | 23 | Synopsis of kprobe_events |
@@ -55,9 +52,9 @@ Per-Probe Event Filtering | |||
55 | ------------------------- | 52 | ------------------------- |
56 | Per-probe event filtering feature allows you to set different filter on each | 53 | Per-probe event filtering feature allows you to set different filter on each |
57 | probe and gives you what arguments will be shown in trace buffer. If an event | 54 | probe and gives you what arguments will be shown in trace buffer. If an event |
58 | name is specified right after 'p:' or 'r:' in kprobe_events, the tracer adds | 55 | name is specified right after 'p:' or 'r:' in kprobe_events, it adds an event |
59 | an event under tracing/events/kprobes/<EVENT>, at the directory you can see | 56 | under tracing/events/kprobes/<EVENT>, at the directory you can see 'id', |
60 | 'id', 'enabled', 'format' and 'filter'. | 57 | 'enabled', 'format' and 'filter'. |
61 | 58 | ||
62 | enabled: | 59 | enabled: |
63 | You can enable/disable the probe by writing 1 or 0 on it. | 60 | You can enable/disable the probe by writing 1 or 0 on it. |
@@ -71,6 +68,7 @@ filter: | |||
71 | id: | 68 | id: |
72 | This shows the id of this probe event. | 69 | This shows the id of this probe event. |
73 | 70 | ||
71 | |||
74 | Event Profiling | 72 | Event Profiling |
75 | --------------- | 73 | --------------- |
76 | You can check the total number of probe hits and probe miss-hits via | 74 | You can check the total number of probe hits and probe miss-hits via |
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index 15372a9f2399..f05671609a89 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig | |||
@@ -428,17 +428,22 @@ config BLK_DEV_IO_TRACE | |||
428 | 428 | ||
429 | If unsure, say N. | 429 | If unsure, say N. |
430 | 430 | ||
431 | config KPROBE_TRACER | 431 | config KPROBE_EVENT |
432 | depends on KPROBES | 432 | depends on KPROBES |
433 | depends on X86 | 433 | depends on X86 |
434 | bool "Trace kprobes" | 434 | bool "Enable kprobes-based dynamic events" |
435 | select TRACING | 435 | select TRACING |
436 | select GENERIC_TRACER | 436 | default y |
437 | help | 437 | help |
438 | This tracer probes everywhere where kprobes can probe it, and | 438 | This allows the user to add tracing events (similar to tracepoints) on the fly |
439 | records various registers and memories specified by user. | 439 | via the ftrace interface. See Documentation/trace/kprobetrace.txt |
440 | This also allows you to trace kprobe probe points as a dynamic | 440 | for more details. |
441 | defined events. It provides per-probe event filtering interface. | 441 | |
442 | Those events can be inserted wherever kprobes can probe, and record | ||
443 | various register and memory values. | ||
444 | |||
445 | This option is also required by perf-probe subcommand of perf tools. If | ||
446 | you want to use perf tools, this option is strongly recommended. | ||
442 | 447 | ||
443 | config DYNAMIC_FTRACE | 448 | config DYNAMIC_FTRACE |
444 | bool "enable/disable ftrace tracepoints dynamically" | 449 | bool "enable/disable ftrace tracepoints dynamically" |
diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile index c8cb75d7f280..edc3a3cca1a1 100644 --- a/kernel/trace/Makefile +++ b/kernel/trace/Makefile | |||
@@ -53,7 +53,7 @@ obj-$(CONFIG_EVENT_TRACING) += trace_export.o | |||
53 | obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o | 53 | obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o |
54 | obj-$(CONFIG_EVENT_PROFILE) += trace_event_profile.o | 54 | obj-$(CONFIG_EVENT_PROFILE) += trace_event_profile.o |
55 | obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o | 55 | obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o |
56 | obj-$(CONFIG_KPROBE_TRACER) += trace_kprobe.o | 56 | obj-$(CONFIG_KPROBE_EVENT) += trace_kprobe.o |
57 | obj-$(CONFIG_EVENT_TRACING) += power-traces.o | 57 | obj-$(CONFIG_EVENT_TRACING) += power-traces.o |
58 | 58 | ||
59 | libftrace-y := ftrace.o | 59 | libftrace-y := ftrace.o |
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index a86c3ac0df21..cf17a6694f32 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * kprobe based kernel tracer | 2 | * Kprobes-based tracing events |
3 | * | 3 | * |
4 | * Created by Masami Hiramatsu <mhiramat@redhat.com> | 4 | * Created by Masami Hiramatsu <mhiramat@redhat.com> |
5 | * | 5 | * |
@@ -57,8 +57,6 @@ const char *reserved_field_names[] = { | |||
57 | FIELD_STRING_FUNC, | 57 | FIELD_STRING_FUNC, |
58 | }; | 58 | }; |
59 | 59 | ||
60 | /* currently, trace_kprobe only supports X86. */ | ||
61 | |||
62 | struct fetch_func { | 60 | struct fetch_func { |
63 | unsigned long (*func)(struct pt_regs *, void *); | 61 | unsigned long (*func)(struct pt_regs *, void *); |
64 | void *data; | 62 | void *data; |
@@ -191,7 +189,7 @@ static __kprobes void free_indirect_fetch_data(struct indirect_fetch_data *data) | |||
191 | } | 189 | } |
192 | 190 | ||
193 | /** | 191 | /** |
194 | * Kprobe tracer core functions | 192 | * Kprobe event core functions |
195 | */ | 193 | */ |
196 | 194 | ||
197 | struct probe_arg { | 195 | struct probe_arg { |