tracing: Add trace_options kernel command line parameter
Add trace_options to the kernel command line parameter to be able to set options at early boot. For example, to enable stack dumps of events, add the following: trace_options=stacktrace This along with the trace_event option, you can get not only traces of the events but also the stack dumps with them. Requested-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
parent
0d5c6e1c19
commit
7bcfaf54f5
|
@ -2859,6 +2859,22 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
|
||||||
to facilitate early boot debugging.
|
to facilitate early boot debugging.
|
||||||
See also Documentation/trace/events.txt
|
See also Documentation/trace/events.txt
|
||||||
|
|
||||||
|
trace_options=[option-list]
|
||||||
|
[FTRACE] Enable or disable tracer options at boot.
|
||||||
|
The option-list is a comma delimited list of options
|
||||||
|
that can be enabled or disabled just as if you were
|
||||||
|
to echo the option name into
|
||||||
|
|
||||||
|
/sys/kernel/debug/tracing/trace_options
|
||||||
|
|
||||||
|
For example, to enable stacktrace option (to dump the
|
||||||
|
stack trace of each event), add to the command line:
|
||||||
|
|
||||||
|
trace_options=stacktrace
|
||||||
|
|
||||||
|
See also Documentation/trace/ftrace.txt "trace options"
|
||||||
|
section.
|
||||||
|
|
||||||
transparent_hugepage=
|
transparent_hugepage=
|
||||||
[KNL]
|
[KNL]
|
||||||
Format: [always|madvise|never]
|
Format: [always|madvise|never]
|
||||||
|
|
|
@ -155,6 +155,18 @@ static int __init set_ftrace_dump_on_oops(char *str)
|
||||||
}
|
}
|
||||||
__setup("ftrace_dump_on_oops", set_ftrace_dump_on_oops);
|
__setup("ftrace_dump_on_oops", set_ftrace_dump_on_oops);
|
||||||
|
|
||||||
|
|
||||||
|
static char trace_boot_options_buf[MAX_TRACER_SIZE] __initdata;
|
||||||
|
static char *trace_boot_options __initdata;
|
||||||
|
|
||||||
|
static int __init set_trace_boot_options(char *str)
|
||||||
|
{
|
||||||
|
strncpy(trace_boot_options_buf, str, MAX_TRACER_SIZE);
|
||||||
|
trace_boot_options = trace_boot_options_buf;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
__setup("trace_options=", set_trace_boot_options);
|
||||||
|
|
||||||
unsigned long long ns2usecs(cycle_t nsec)
|
unsigned long long ns2usecs(cycle_t nsec)
|
||||||
{
|
{
|
||||||
nsec += 500;
|
nsec += 500;
|
||||||
|
@ -2838,24 +2850,14 @@ static void set_tracer_flags(unsigned int mask, int enabled)
|
||||||
trace_printk_start_stop_comm(enabled);
|
trace_printk_start_stop_comm(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static int trace_set_options(char *option)
|
||||||
tracing_trace_options_write(struct file *filp, const char __user *ubuf,
|
|
||||||
size_t cnt, loff_t *ppos)
|
|
||||||
{
|
{
|
||||||
char buf[64];
|
|
||||||
char *cmp;
|
char *cmp;
|
||||||
int neg = 0;
|
int neg = 0;
|
||||||
int ret;
|
int ret = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (cnt >= sizeof(buf))
|
cmp = strstrip(option);
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (copy_from_user(&buf, ubuf, cnt))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
buf[cnt] = 0;
|
|
||||||
cmp = strstrip(buf);
|
|
||||||
|
|
||||||
if (strncmp(cmp, "no", 2) == 0) {
|
if (strncmp(cmp, "no", 2) == 0) {
|
||||||
neg = 1;
|
neg = 1;
|
||||||
|
@ -2874,10 +2876,25 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
|
||||||
mutex_lock(&trace_types_lock);
|
mutex_lock(&trace_types_lock);
|
||||||
ret = set_tracer_option(current_trace, cmp, neg);
|
ret = set_tracer_option(current_trace, cmp, neg);
|
||||||
mutex_unlock(&trace_types_lock);
|
mutex_unlock(&trace_types_lock);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t
|
||||||
|
tracing_trace_options_write(struct file *filp, const char __user *ubuf,
|
||||||
|
size_t cnt, loff_t *ppos)
|
||||||
|
{
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
|
if (cnt >= sizeof(buf))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (copy_from_user(&buf, ubuf, cnt))
|
||||||
|
return -EFAULT;
|
||||||
|
|
||||||
|
trace_set_options(buf);
|
||||||
|
|
||||||
*ppos += cnt;
|
*ppos += cnt;
|
||||||
|
|
||||||
return cnt;
|
return cnt;
|
||||||
|
@ -5133,6 +5150,13 @@ __init static int tracer_alloc_buffers(void)
|
||||||
|
|
||||||
register_die_notifier(&trace_die_notifier);
|
register_die_notifier(&trace_die_notifier);
|
||||||
|
|
||||||
|
while (trace_boot_options) {
|
||||||
|
char *option;
|
||||||
|
|
||||||
|
option = strsep(&trace_boot_options, ",");
|
||||||
|
trace_set_options(option);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_free_cpumask:
|
out_free_cpumask:
|
||||||
|
|
Loading…
Reference in New Issue