diff options
author | Pekka Paalanen <pq@iki.fi> | 2008-05-12 15:20:57 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2008-05-24 05:22:43 -0400 |
commit | f984b51e0779a6dd30feedc41404013ca54e5d05 (patch) | |
tree | ae7e80f53707e9069a9607072a554b51c660075b /kernel | |
parent | d61fc44853f46fb002228b18aa5f30db21fcd4ac (diff) |
ftrace: add mmiotrace plugin
On Sat, 22 Mar 2008 13:07:47 +0100
Ingo Molnar <mingo@elte.hu> wrote:
> > > i'd suggest the following: pull x86.git and sched-devel.git into a
> > > single tree [the two will combine without rejects]. Then try to add a
> > > kernel/tracing/trace_mmiotrace.c ftrace plugin. The trace_sysprof.c
> > > plugin might be a good example.
> >
> > I did this and now I have mmiotrace enabled/disabled via the tracing
> > framework (what do we call this, since ftrace is one of the tracers?).
>
> cool! could you send the patches for that? (even if they are not fully
> functional yet)
Patch attached in the end. Nice to see how much code disappeared. I tried
to mark all the features I had to break with XXX-comments.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/Makefile | 1 | ||||
-rw-r--r-- | kernel/trace/trace_mmiotrace.c | 84 |
2 files changed, 85 insertions, 0 deletions
diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile index d9efbbfa2bdf..c44a7dce9086 100644 --- a/kernel/trace/Makefile +++ b/kernel/trace/Makefile | |||
@@ -18,5 +18,6 @@ obj-$(CONFIG_FTRACE) += trace_functions.o | |||
18 | obj-$(CONFIG_IRQSOFF_TRACER) += trace_irqsoff.o | 18 | obj-$(CONFIG_IRQSOFF_TRACER) += trace_irqsoff.o |
19 | obj-$(CONFIG_PREEMPT_TRACER) += trace_irqsoff.o | 19 | obj-$(CONFIG_PREEMPT_TRACER) += trace_irqsoff.o |
20 | obj-$(CONFIG_SCHED_TRACER) += trace_sched_wakeup.o | 20 | obj-$(CONFIG_SCHED_TRACER) += trace_sched_wakeup.o |
21 | obj-$(CONFIG_MMIOTRACE) += trace_mmiotrace.o | ||
21 | 22 | ||
22 | libftrace-y := ftrace.o | 23 | libftrace-y := ftrace.o |
diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c new file mode 100644 index 000000000000..e4dd03cc5aa6 --- /dev/null +++ b/kernel/trace/trace_mmiotrace.c | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * Memory mapped I/O tracing | ||
3 | * | ||
4 | * Copyright (C) 2008 Pekka Paalanen <pq@iki.fi> | ||
5 | */ | ||
6 | |||
7 | #define DEBUG 1 | ||
8 | |||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/mmiotrace.h> | ||
11 | |||
12 | #include "trace.h" | ||
13 | |||
14 | extern void | ||
15 | __trace_special(void *__tr, void *__data, | ||
16 | unsigned long arg1, unsigned long arg2, unsigned long arg3); | ||
17 | |||
18 | static struct trace_array *mmio_trace_array; | ||
19 | |||
20 | |||
21 | static void mmio_trace_init(struct trace_array *tr) | ||
22 | { | ||
23 | pr_debug("in %s\n", __func__); | ||
24 | mmio_trace_array = tr; | ||
25 | if (tr->ctrl) | ||
26 | enable_mmiotrace(); | ||
27 | } | ||
28 | |||
29 | static void mmio_trace_reset(struct trace_array *tr) | ||
30 | { | ||
31 | pr_debug("in %s\n", __func__); | ||
32 | if (tr->ctrl) | ||
33 | disable_mmiotrace(); | ||
34 | } | ||
35 | |||
36 | static void mmio_trace_ctrl_update(struct trace_array *tr) | ||
37 | { | ||
38 | pr_debug("in %s\n", __func__); | ||
39 | if (tr->ctrl) | ||
40 | enable_mmiotrace(); | ||
41 | else | ||
42 | disable_mmiotrace(); | ||
43 | } | ||
44 | |||
45 | static struct tracer mmio_tracer __read_mostly = | ||
46 | { | ||
47 | .name = "mmiotrace", | ||
48 | .init = mmio_trace_init, | ||
49 | .reset = mmio_trace_reset, | ||
50 | .ctrl_update = mmio_trace_ctrl_update, | ||
51 | }; | ||
52 | |||
53 | __init static int init_mmio_trace(void) | ||
54 | { | ||
55 | int ret = init_mmiotrace(); | ||
56 | if (ret) | ||
57 | return ret; | ||
58 | return register_tracer(&mmio_tracer); | ||
59 | } | ||
60 | device_initcall(init_mmio_trace); | ||
61 | |||
62 | void mmio_trace_record(u32 type, unsigned long addr, unsigned long arg) | ||
63 | { | ||
64 | struct trace_array *tr = mmio_trace_array; | ||
65 | struct trace_array_cpu *data = tr->data[smp_processor_id()]; | ||
66 | |||
67 | if (!current || current->pid == 0) { | ||
68 | /* | ||
69 | * XXX: This is a problem. We need to able to record, no | ||
70 | * matter what. tracing_generic_entry_update() would crash. | ||
71 | */ | ||
72 | static unsigned limit; | ||
73 | if (limit++ < 12) | ||
74 | pr_err("Error in %s: no current.\n", __func__); | ||
75 | return; | ||
76 | } | ||
77 | if (!tr || !data) { | ||
78 | static unsigned limit; | ||
79 | if (limit++ < 12) | ||
80 | pr_err("%s: no tr or data\n", __func__); | ||
81 | return; | ||
82 | } | ||
83 | __trace_special(tr, data, type, addr, arg); | ||
84 | } | ||