Skip to content

Commit 8520ded

Browse files
Daniel Thompsonrostedt
authored andcommitted
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: Daniel Thompson <daniel.thompson@linaro.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent c270cc7 commit 8520ded

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎kernel/trace/trace_kdb.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@ static void ftrace_dump_buf(int skip_lines, long cpu_file)
5959
ring_buffer_read_start(iter.buffer_iter[cpu_file]);
6060
tracing_iter_reset(&iter, cpu_file);
6161
}
62-
if (!trace_empty(&iter))
63-
trace_find_next_entry_inc(&iter);
64-
while (!trace_empty(&iter)) {
62+
63+
while (trace_find_next_entry_inc(&iter)) {
6564
if (!cnt)
6665
kdb_printf("---------------------------------\n");
6766
cnt++;
6867

69-
if (trace_find_next_entry_inc(&iter) != NULL && !skip_lines)
68+
if (!skip_lines) {
7069
print_trace_line(&iter);
71-
if (!skip_lines)
7270
trace_printk_seq(&iter.seq);
73-
else
71+
} else {
7472
skip_lines--;
73+
}
74+
7575
if (KDB_FLAG(CMD_INTERRUPT))
7676
goto out;
7777
}

0 commit comments

Comments
 (0)