Skip to content

Commit

Permalink
Merge tag 'trace-fixes-v3.10-rc3' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/kernel/git/rostedt/linux-trace

Pull tracing fixes from Steven Rostedt:
 "Two more fixes:

  The first one was reported by Mauro Carvalho Chehab, where if a poll()
  is done against a trace buffer for a CPU that has never been online,
  it will crash the kernel, as buffers are only created when a CPU comes
  on line, but the trace files are for all possible CPUs.

  This fix is to check if the buffer was allocated and if not return
  -EINVAL.

  That was the simple fix, the real fix is a bit more complex and not
  for a -rc release.  We could have the files created when the CPUs come
  online.  That would require some design changes.

  The second one was reported by Peter Zijlstra.  If the kernel command
  line has ftrace=nop, it will lock up the system on boot up.  This is
  because the new design for 3.10 has the nop tracer bootstrap the
  tracing subsystem.  When ftrace=<trace> is defined, when a that tracer
  is registered, it starts the tracing, but uses the nop tracer to clear
  things out.  What happened here was that ftrace=nop caused the
  registering of nop to start it and use nop before it was initialized.

  The only thing nop needs to have done to initialize it is to have the
  tracer point its current_tracer structure member to the nop tracer.
  Doing that before registering the nop tracer makes everything work."

* tag 'trace-fixes-v3.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  ring-buffer: Do not poll non allocated cpu buffers
  tracing: Fix crash when ftrace=nop on the kernel command line
  • Loading branch information
Linus Torvalds committed May 28, 2013
2 parents 3c48dd4 + 6721cb6 commit e3bf756
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions kernel/trace/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,9 @@ int ring_buffer_poll_wait(struct ring_buffer *buffer, int cpu,
if (cpu == RING_BUFFER_ALL_CPUS)
work = &buffer->irq_work;
else {
if (!cpumask_test_cpu(cpu, buffer->cpumask))
return -EINVAL;

cpu_buffer = buffer->buffers[cpu];
work = &cpu_buffer->irq_work;
}
Expand Down
9 changes: 7 additions & 2 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -6216,10 +6216,15 @@ __init static int tracer_alloc_buffers(void)

trace_init_cmdlines();

register_tracer(&nop_trace);

/*
* register_tracer() might reference current_trace, so it
* needs to be set before we register anything. This is
* just a bootstrap of current_trace anyway.
*/
global_trace.current_trace = &nop_trace;

register_tracer(&nop_trace);

/* All seems OK, enable tracing */
tracing_disabled = 0;

Expand Down

0 comments on commit e3bf756

Please sign in to comment.