linux-stable/kernel/trace
Douglas Anderson 31b265b3ba tracing: kdb: Fix ftdump to not sleep
As reported back in 2016-11 [1], the "ftdump" kdb command triggers a
BUG for "sleeping function called from invalid context".

kdb's "ftdump" command wants to call ring_buffer_read_prepare() in
atomic context.  A very simple solution for this is to add allocation
flags to ring_buffer_read_prepare() so kdb can call it without
triggering the allocation error.  This patch does that.

Note that in the original email thread about this, it was suggested
that perhaps the solution for kdb was to either preallocate the buffer
ahead of time or create our own iterator.  I'm hoping that this
alternative of adding allocation flags to ring_buffer_read_prepare()
can be considered since it means I don't need to duplicate more of the
core trace code into "trace_kdb.c" (for either creating my own
iterator or re-preparing a ring allocator whose memory was already
allocated).

NOTE: another option for kdb is to actually figure out how to make it
reuse the existing ftrace_dump() function and totally eliminate the
duplication.  This sounds very appealing and actually works (the "sr
z" command can be seen to properly dump the ftrace buffer).  The
downside here is that ftrace_dump() fully consumes the trace buffer.
Unless that is changed I'd rather not use it because it means "ftdump
| grep xyz" won't be very useful to search the ftrace buffer since it
will throw away the whole trace on the first grep.  A future patch to
dump only the last few lines of the buffer will also be hard to
implement.

[1] https://lkml.kernel.org/r/20161117191605.GA21459@google.com

Link: http://lkml.kernel.org/r/20190308193205.213659-1-dianders@chromium.org

Reported-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
2019-03-13 09:46:10 -04:00
..
blktrace.c blkcg: remove bio->bi_css and instead use bio->bi_blkg 2018-12-07 22:26:37 -07:00
bpf_trace.c Remove 'type' argument from access_ok() function 2019-01-03 18:57:57 -08:00
fgraph.c tracing: Fix ftrace_graph_get_ret_stack() to use task and not current 2018-12-22 08:21:03 -05:00
ftrace.c ftrace: Allow enabling of filters via index of available_filter_functions 2019-02-15 13:10:09 -05:00
ftrace_internal.h ftrace: Create new ftrace_internal.h header 2018-12-08 20:54:06 -05:00
Kconfig tracing: Use dyn_event framework for synthetic events 2018-12-08 20:54:10 -05:00
Makefile tracing: Add unified dynamic event framework 2018-12-08 20:54:09 -05:00
power-traces.c
preemptirq_delay_test.c
ring_buffer.c tracing: kdb: Fix ftdump to not sleep 2019-03-13 09:46:10 -04:00
ring_buffer_benchmark.c
rpm-traces.c
trace.c tracing: kdb: Fix ftdump to not sleep 2019-03-13 09:46:10 -04:00
trace.h tracing: Add conditional snapshot 2019-02-20 13:51:06 -05:00
trace_benchmark.c
trace_benchmark.h
trace_branch.c
trace_clock.c
trace_dynevent.c tracing: Add generic event-name based remove event method 2018-12-10 12:22:44 -05:00
trace_dynevent.h tracing: Add unified dynamic event framework 2018-12-08 20:54:09 -05:00
trace_entries.h tracing: Change the function format to display function names by perf 2019-02-11 14:53:43 -05:00
trace_event_perf.c tracing/perf: Use strndup_user() instead of buggy open-coded version 2019-02-21 10:35:10 -05:00
trace_events.c tracing: Use str_has_prefix() instead of using fixed sizes 2018-12-22 22:51:54 -05:00
trace_events_filter.c ftrace: Allow enabling of filters via index of available_filter_functions 2019-02-15 13:10:09 -05:00
trace_events_filter_test.h
trace_events_hist.c tracing: Use strncpy instead of memcpy when copying comm for hist triggers 2019-03-05 12:14:28 -05:00
trace_events_trigger.c tracing: Fix memory leak in set_trigger_filter() 2018-12-11 13:50:19 -05:00
trace_export.c
trace_functions.c
trace_functions_graph.c tracing: Put a margin between flags and duration for wakeup tracers 2019-02-06 11:56:19 -05:00
trace_hwlat.c
trace_irqsoff.c function_graph: Support displaying relative timestamp 2019-02-06 11:56:18 -05:00
trace_kdb.c tracing: kdb: Fix ftdump to not sleep 2019-03-13 09:46:10 -04:00
trace_kprobe.c trace/probes: Remove kernel doc style from non kernel doc comment 2019-03-12 11:23:52 -04:00
trace_kprobe_selftest.c
trace_kprobe_selftest.h
trace_mmiotrace.c
trace_nop.c
trace_output.c tracing: Simplify printf'ing in seq_print_sym 2018-12-22 08:21:06 -05:00
trace_output.h
trace_preemptirq.c
trace_printk.c
trace_probe.c tracing/probes: Make reserved_field_names static 2019-03-12 10:59:51 -04:00
trace_probe.h tracing/kprobes: Use dyn_event framework for kprobe events 2018-12-08 20:54:09 -05:00
trace_probe_tmpl.h
trace_sched_switch.c
trace_sched_wakeup.c tracing: Add conditional snapshot 2019-02-20 13:51:06 -05:00
trace_selftest.c fgraph: Add new fgraph_ops structure to enable function graph hooks 2018-12-08 20:54:07 -05:00
trace_selftest_dynamic.c
trace_seq.c
trace_stack.c tracing: Use the return of str_has_prefix() to remove open coded numbers 2018-12-22 22:52:30 -05:00
trace_stat.c
trace_stat.h
trace_syscalls.c
trace_uprobe.c tracing: Consolidate trace_add/remove_event_call back to the nolock functions 2018-12-10 12:22:10 -05:00
tracing_map.c
tracing_map.h