Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Commit 495fcec

Browse files
diandersrostedt
authored andcommitted
tracing: Fix sleeping while atomic in kdb ftdump
If you drop into kdb and type "ftdump" you'll get a sleeping while atomic warning from memory allocation in trace_find_next_entry(). This appears to have been caused by commit ff89510 ("tracing: Save off entry when peeking at next entry"), which added the allocation in that path. The problematic commit was already fixed by commit 8e99cf9 ("tracing: Do not allocate buffer in trace_find_next_entry() in atomic") but that fix missed the kdb case. The fix here is easy: just move the assignment of the static buffer to the place where it should have been to begin with: trace_init_global_iter(). That function is called in two places, once is right before the assignment of the static buffer added by the previous fix and once is in kdb. Note that it appears that there's a second static buffer that we need to assign that was added in commit efbbdaa ("tracing: Show real address for trace event arguments"), so we'll move that too. Link: https://lkml.kernel.org/r/20220708170919.1.I75844e5038d9425add2ad853a608cb44bb39df40@changeid Fixes: ff89510 ("tracing: Save off entry when peeking at next entry") Fixes: efbbdaa ("tracing: Show real address for trace event arguments") Signed-off-by: Douglas Anderson <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 7edc394 commit 495fcec

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

kernel/trace/trace.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -9864,6 +9864,12 @@ void trace_init_global_iter(struct trace_iterator *iter)
98649864
/* Output in nanoseconds only if we are using a clock in nanoseconds. */
98659865
if (trace_clocks[iter->tr->clock_id].in_ns)
98669866
iter->iter_flags |= TRACE_FILE_TIME_IN_NS;
9867+
9868+
/* Can not use kmalloc for iter.temp and iter.fmt */
9869+
iter->temp = static_temp_buf;
9870+
iter->temp_size = STATIC_TEMP_BUF_SIZE;
9871+
iter->fmt = static_fmt_buf;
9872+
iter->fmt_size = STATIC_FMT_BUF_SIZE;
98679873
}
98689874

98699875
void ftrace_dump(enum ftrace_dump_mode oops_dump_mode)
@@ -9896,11 +9902,6 @@ void ftrace_dump(enum ftrace_dump_mode oops_dump_mode)
98969902

98979903
/* Simulate the iterator */
98989904
trace_init_global_iter(&iter);
9899-
/* Can not use kmalloc for iter.temp and iter.fmt */
9900-
iter.temp = static_temp_buf;
9901-
iter.temp_size = STATIC_TEMP_BUF_SIZE;
9902-
iter.fmt = static_fmt_buf;
9903-
iter.fmt_size = STATIC_FMT_BUF_SIZE;
99049905

99059906
for_each_tracing_cpu(cpu) {
99069907
atomic_inc(&per_cpu_ptr(iter.array_buffer->data, cpu)->disabled);

0 commit comments

Comments
 (0)