blob: 087b6cbf4ea53e37c007b588209846d7b498e76b [file] [log] [blame]
Steven Noonanfb1b6d82008-09-19 03:06:43 -07001/*
2 * nop tracer
3 *
4 * Copyright (C) 2008 Steven Noonan <steven@uplinklabs.net>
5 *
6 */
7
8#include <linux/module.h>
9#include <linux/fs.h>
10#include <linux/debugfs.h>
11#include <linux/ftrace.h>
12
13#include "trace.h"
14
Frederic Weisbecker0619faf2008-11-17 19:26:30 +010015/* Our two options */
16enum {
17 TRACE_NOP_OPT_ACCEPT = 0x1,
18 TRACE_NOP_OPT_REFUSE = 0x2
19};
20
21/* Options for the tracer (see trace_options file) */
22static struct tracer_opt nop_opts[] = {
23 /* Option that will be accepted by set_flag callback */
24 { TRACER_OPT(test_nop_accept, TRACE_NOP_OPT_ACCEPT) },
25 /* Option that will be refused by set_flag callback */
26 { TRACER_OPT(test_nop_refuse, TRACE_NOP_OPT_REFUSE) },
27 { } /* Always set a last empty entry */
28};
29
30static struct tracer_flags nop_flags = {
31 /* You can check your flags value here when you want. */
32 .val = 0, /* By default: all flags disabled */
33 .opts = nop_opts
34};
35
Steven Noonanfb1b6d82008-09-19 03:06:43 -070036static struct trace_array *ctx_trace;
37
38static void start_nop_trace(struct trace_array *tr)
39{
40 /* Nothing to do! */
41}
42
43static void stop_nop_trace(struct trace_array *tr)
44{
45 /* Nothing to do! */
46}
47
Frederic Weisbecker1c800252008-11-16 05:57:26 +010048static int nop_trace_init(struct trace_array *tr)
Steven Noonanfb1b6d82008-09-19 03:06:43 -070049{
50 ctx_trace = tr;
Arnaldo Carvalho de Melof04109b2009-01-28 13:02:12 -020051 tracing_reset_online_cpus(tr);
Steven Rostedtc76f0692008-11-07 22:36:02 -050052 start_nop_trace(tr);
Frederic Weisbecker1c800252008-11-16 05:57:26 +010053 return 0;
Steven Noonanfb1b6d82008-09-19 03:06:43 -070054}
55
56static void nop_trace_reset(struct trace_array *tr)
57{
Steven Rostedtc76f0692008-11-07 22:36:02 -050058 stop_nop_trace(tr);
Steven Noonanfb1b6d82008-09-19 03:06:43 -070059}
60
Frederic Weisbecker0619faf2008-11-17 19:26:30 +010061/* It only serves as a signal handler and a callback to
62 * accept or refuse tthe setting of a flag.
63 * If you don't implement it, then the flag setting will be
64 * automatically accepted.
65 */
66static int nop_set_flag(u32 old_flags, u32 bit, int set)
67{
68 /*
69 * Note that you don't need to update nop_flags.val yourself.
70 * The tracing Api will do it automatically if you return 0
71 */
72 if (bit == TRACE_NOP_OPT_ACCEPT) {
73 printk(KERN_DEBUG "nop_test_accept flag set to %d: we accept."
74 " Now cat trace_options to see the result\n",
75 set);
76 return 0;
77 }
78
79 if (bit == TRACE_NOP_OPT_REFUSE) {
80 printk(KERN_DEBUG "nop_test_refuse flag set to %d: we refuse."
81 "Now cat trace_options to see the result\n",
82 set);
83 return -EINVAL;
84 }
85
86 return 0;
87}
88
89
Frédéric Weisbecker43a15382008-09-21 20:16:30 +020090struct tracer nop_trace __read_mostly =
Steven Noonanfb1b6d82008-09-19 03:06:43 -070091{
92 .name = "nop",
93 .init = nop_trace_init,
94 .reset = nop_trace_reset,
Steven Noonanfb1b6d82008-09-19 03:06:43 -070095#ifdef CONFIG_FTRACE_SELFTEST
96 .selftest = trace_selftest_startup_nop,
97#endif
Frederic Weisbecker0619faf2008-11-17 19:26:30 +010098 .flags = &nop_flags,
99 .set_flag = nop_set_flag
Steven Noonanfb1b6d82008-09-19 03:06:43 -0700100};
101