Skip to content

Commit

Permalink
ftrace: ftrace_dump_on_oops=[tracer]
Browse files Browse the repository at this point in the history
Impact: add new (optional) debug boot option

In order to facilitate early boot trouble, allow one to specify a tracer
on the kernel boot line.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Nov 3, 2008
1 parent 3660946 commit d9e5407
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 20 deletions.
8 changes: 8 additions & 0 deletions Documentation/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,14 @@ and is between 256 and 4096 characters. It is defined in the file
parameter will force ia64_sal_cache_flush to call
ia64_pal_cache_flush instead of SAL_CACHE_FLUSH.

ftrace=[tracer]
[ftrace] will set and start the specified tracer
as early as possible in order to facilitate early
boot debugging.

ftrace_dump_on_oops
[ftrace] will dump the trace buffers on oops.

gamecon.map[2|3]=
[HW,JOY] Multisystem joystick and NES/SNES/PSX pad
support via parallel port (up to 5 devices per port)
Expand Down
58 changes: 38 additions & 20 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ static int tracing_disabled = 1;
*/
int ftrace_dump_on_oops;

static int tracing_set_tracer(char *buf);

static int __init set_ftrace(char *str)
{
tracing_set_tracer(str);
return 1;
}
__setup("ftrace", set_ftrace);

static int __init set_ftrace_dump_on_oops(char *str)
{
ftrace_dump_on_oops = 1;
Expand Down Expand Up @@ -2394,29 +2403,11 @@ tracing_set_trace_read(struct file *filp, char __user *ubuf,
return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
}

static ssize_t
tracing_set_trace_write(struct file *filp, const char __user *ubuf,
size_t cnt, loff_t *ppos)
static int tracing_set_tracer(char *buf)
{
struct trace_array *tr = &global_trace;
struct tracer *t;
char buf[max_tracer_type_len+1];
int i;
size_t ret;

ret = cnt;

if (cnt > max_tracer_type_len)
cnt = max_tracer_type_len;

if (copy_from_user(&buf, ubuf, cnt))
return -EFAULT;

buf[cnt] = 0;

/* strip ending whitespace. */
for (i = cnt - 1; i > 0 && isspace(buf[i]); i--)
buf[i] = 0;
int ret = 0;

mutex_lock(&trace_types_lock);
for (t = trace_types; t; t = t->next) {
Expand All @@ -2440,6 +2431,33 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
out:
mutex_unlock(&trace_types_lock);

return ret;
}

static ssize_t
tracing_set_trace_write(struct file *filp, const char __user *ubuf,
size_t cnt, loff_t *ppos)
{
char buf[max_tracer_type_len+1];
int i;
size_t ret;

if (cnt > max_tracer_type_len)
cnt = max_tracer_type_len;

if (copy_from_user(&buf, ubuf, cnt))
return -EFAULT;

buf[cnt] = 0;

/* strip ending whitespace. */
for (i = cnt - 1; i > 0 && isspace(buf[i]); i--)
buf[i] = 0;

ret = tracing_set_tracer(buf);
if (!ret)
ret = cnt;

if (ret > 0)
filp->f_pos += ret;

Expand Down

0 comments on commit d9e5407

Please sign in to comment.