Commit 8520dedb authored by Daniel Thompson's avatar Daniel Thompson Committed by Steven Rostedt

tracing: kdb: Fix kernel livelock with empty buffers

Currently kdb's ftdump command will livelock by constantly printk'ing
the empty string at KERN_EMERG level if it run when the ftrace system is
not in use. This occurs because trace_empty() never returns false when
the ring buffers are left at the start of a non-consuming read [launched
by ring_buffer_read_start()].

This patch changes the loop exit condition to use the result of
trace_find_next_entry_inc(). Effectively this switches the non-consuming
kdb dumper to follow the approach of the non-consuming userspace
interface [s_next()] rather than the consuming ftrace_dump().

Link: http://lkml.kernel.org/r/1415277716-19419-3-git-send-email-daniel.thompson@linaro.org

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent c270cc75
...@@ -59,19 +59,19 @@ static void ftrace_dump_buf(int skip_lines, long cpu_file) ...@@ -59,19 +59,19 @@ static void ftrace_dump_buf(int skip_lines, long cpu_file)
ring_buffer_read_start(iter.buffer_iter[cpu_file]); ring_buffer_read_start(iter.buffer_iter[cpu_file]);
tracing_iter_reset(&iter, cpu_file); tracing_iter_reset(&iter, cpu_file);
} }
if (!trace_empty(&iter))
trace_find_next_entry_inc(&iter); while (trace_find_next_entry_inc(&iter)) {
while (!trace_empty(&iter)) {
if (!cnt) if (!cnt)
kdb_printf("---------------------------------\n"); kdb_printf("---------------------------------\n");
cnt++; cnt++;
if (trace_find_next_entry_inc(&iter) != NULL && !skip_lines) if (!skip_lines) {
print_trace_line(&iter); print_trace_line(&iter);
if (!skip_lines)
trace_printk_seq(&iter.seq); trace_printk_seq(&iter.seq);
else } else {
skip_lines--; skip_lines--;
}
if (KDB_FLAG(CMD_INTERRUPT)) if (KDB_FLAG(CMD_INTERRUPT))
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment