Skip to content

Commit

Permalink
tracing/events: Add trace_event boot option
Browse files Browse the repository at this point in the history
We already have ftrace= boot option, and this adds a similar
boot option for trace events, so allow trace events to be
enabled at boot, for boot debugging purpose.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4A4ACE29.3010407@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Li Zefan authored and Ingo Molnar committed Jul 1, 2009
1 parent c5cb5a2 commit 020e5f8
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 6 deletions.
5 changes: 5 additions & 0 deletions Documentation/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2478,6 +2478,11 @@ and is between 256 and 4096 characters. It is defined in the file
trace_buf_size=nn[KMG]
[FTRACE] will set tracing buffer size.

trace_event=[event-list]
[FTRACE] Set and start specified trace events in order
to facilitate early boot debugging.
See also Documentation/trace/events.txt

trix= [HW,OSS] MediaTrix AudioTrix Pro
Format:
<io>,<irq>,<dma>,<dma2>,<sb_io>,<sb_irq>,<sb_dma>,<mpu_io>,<mpu_irq>
Expand Down
9 changes: 9 additions & 0 deletions Documentation/trace/events.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ When reading one of these enable files, there are four results:
X - there is a mixture of events enabled and disabled
? - this file does not affect any event

2.3 Boot option
---------------

In order to facilitate early boot debugging, use boot option:

trace_event=[event-list]

The format of this boot option is the same as described in section 2.1.

3. Defining an event-enabled tracepoint
=======================================

Expand Down
4 changes: 2 additions & 2 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ unsigned long __read_mostly tracing_thresh;
* On boot up, the ring buffer is set to the minimum size, so that
* we do not waste memory on systems that are not using tracing.
*/
static int ring_buffer_expanded;
int ring_buffer_expanded;

/*
* We need to change this state when a selftest is running.
Expand All @@ -63,7 +63,7 @@ static bool __read_mostly tracing_selftest_running;
/*
* If a tracer is running, we do not want to run SELFTEST.
*/
static bool __read_mostly tracing_selftest_disabled;
bool __read_mostly tracing_selftest_disabled;

/* For tracers that don't implement custom flags */
static struct tracer_opt dummy_tracer_opt[] = {
Expand Down
3 changes: 3 additions & 0 deletions kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,9 @@ extern unsigned long ftrace_update_tot_cnt;
extern int DYN_FTRACE_TEST_NAME(void);
#endif

extern int ring_buffer_expanded;
extern bool tracing_selftest_disabled;

#ifdef CONFIG_FTRACE_STARTUP_TEST
extern int trace_selftest_startup_function(struct tracer *trace,
struct trace_array *tr);
Expand Down
37 changes: 33 additions & 4 deletions kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <linux/ctype.h>
#include <linux/delay.h>

#include <asm/setup.h>

#include "trace_output.h"

#define TRACE_SYSTEM "TRACE_SYSTEM"
Expand Down Expand Up @@ -1133,13 +1135,27 @@ struct notifier_block trace_module_nb = {
extern struct ftrace_event_call __start_ftrace_events[];
extern struct ftrace_event_call __stop_ftrace_events[];

static char bootup_event_buf[COMMAND_LINE_SIZE] __initdata;

static __init int setup_trace_event(char *str)
{
strlcpy(bootup_event_buf, str, COMMAND_LINE_SIZE);
ring_buffer_expanded = 1;
tracing_selftest_disabled = 1;

return 1;
}
__setup("trace_event=", setup_trace_event);

static __init int event_trace_init(void)
{
struct ftrace_event_call *call;
struct dentry *d_tracer;
struct dentry *entry;
struct dentry *d_events;
int ret;
char *buf = bootup_event_buf;
char *token;

d_tracer = tracing_init_dentry();
if (!d_tracer)
Expand Down Expand Up @@ -1185,6 +1201,19 @@ static __init int event_trace_init(void)
&ftrace_event_format_fops);
}

while (true) {
token = strsep(&buf, ",");

if (!token)
break;
if (!*token)
continue;

ret = ftrace_set_clr_event(token, 1);
if (ret)
pr_warning("Failed to enable trace event: %s\n", token);
}

ret = register_module_notifier(&trace_module_nb);
if (ret)
pr_warning("Failed to register trace events module notifier\n");
Expand Down Expand Up @@ -1392,10 +1421,10 @@ static __init void event_trace_self_test_with_function(void)

static __init int event_trace_self_tests_init(void)
{

event_trace_self_tests();

event_trace_self_test_with_function();
if (!tracing_selftest_disabled) {
event_trace_self_tests();
event_trace_self_test_with_function();
}

return 0;
}
Expand Down

0 comments on commit 020e5f8

Please sign in to comment.