• Douglas Anderson's avatar
    tracing: kdb: Fix ftdump to not sleep · 043a4400
    Douglas Anderson authored
    [ Upstream commit 31b265b3 ]
    
    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.orgReported-by: 's avatarBrian Norris <briannorris@chromium.org>
    Signed-off-by: 's avatarDouglas Anderson <dianders@chromium.org>
    Signed-off-by: 's avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: 's avatarSasha Levin <sashal@kernel.org>
    043a4400
Name
Last commit
Last update
..
Kconfig Loading commit data...
Makefile Loading commit data...
blktrace.c Loading commit data...
bpf_trace.c Loading commit data...
fgraph.c Loading commit data...
ftrace.c Loading commit data...
ftrace_internal.h Loading commit data...
power-traces.c Loading commit data...
preemptirq_delay_test.c Loading commit data...
ring_buffer.c Loading commit data...
ring_buffer_benchmark.c Loading commit data...
rpm-traces.c Loading commit data...
trace.c Loading commit data...
trace.h Loading commit data...
trace_benchmark.c Loading commit data...
trace_benchmark.h Loading commit data...
trace_branch.c Loading commit data...
trace_clock.c Loading commit data...
trace_dynevent.c Loading commit data...
trace_dynevent.h Loading commit data...
trace_entries.h Loading commit data...
trace_event_perf.c Loading commit data...
trace_events.c Loading commit data...
trace_events_filter.c Loading commit data...
trace_events_filter_test.h Loading commit data...
trace_events_hist.c Loading commit data...
trace_events_trigger.c Loading commit data...
trace_export.c Loading commit data...
trace_functions.c Loading commit data...
trace_functions_graph.c Loading commit data...
trace_hwlat.c Loading commit data...
trace_irqsoff.c Loading commit data...
trace_kdb.c Loading commit data...
trace_kprobe.c Loading commit data...
trace_kprobe_selftest.c Loading commit data...
trace_kprobe_selftest.h Loading commit data...
trace_mmiotrace.c Loading commit data...
trace_nop.c Loading commit data...
trace_output.c Loading commit data...
trace_output.h Loading commit data...
trace_preemptirq.c Loading commit data...
trace_printk.c Loading commit data...
trace_probe.c Loading commit data...
trace_probe.h Loading commit data...
trace_probe_tmpl.h Loading commit data...
trace_sched_switch.c Loading commit data...
trace_sched_wakeup.c Loading commit data...
trace_selftest.c Loading commit data...
trace_selftest_dynamic.c Loading commit data...
trace_seq.c Loading commit data...
trace_stack.c Loading commit data...
trace_stat.c Loading commit data...
trace_stat.h Loading commit data...
trace_syscalls.c Loading commit data...
trace_uprobe.c Loading commit data...
tracing_map.c Loading commit data...
tracing_map.h Loading commit data...