From 7cf5bdac6d1c4f048370aad33222414564680f4e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 7 Aug 2023 10:03:50 +0200 Subject: [PATCH] 5.10-stable patches added patches: tracing-fix-sleeping-while-atomic-in-kdb-ftdump.patch --- queue-5.10/series | 1 + ...-sleeping-while-atomic-in-kdb-ftdump.patch | 66 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 queue-5.10/tracing-fix-sleeping-while-atomic-in-kdb-ftdump.patch diff --git a/queue-5.10/series b/queue-5.10/series index aaa344e5c41..93ecc559f0e 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -174,3 +174,4 @@ bpf-disable-preemption-in-bpf_event_output.patch open-make-resolve_cached-correctly-test-for-o_tmpfile.patch drm-ttm-check-null-pointer-before-accessing-when-swapping.patch file-reinstate-f_pos-locking-optimization-for-regular-files.patch +tracing-fix-sleeping-while-atomic-in-kdb-ftdump.patch diff --git a/queue-5.10/tracing-fix-sleeping-while-atomic-in-kdb-ftdump.patch b/queue-5.10/tracing-fix-sleeping-while-atomic-in-kdb-ftdump.patch new file mode 100644 index 00000000000..0cc6e54f88a --- /dev/null +++ b/queue-5.10/tracing-fix-sleeping-while-atomic-in-kdb-ftdump.patch @@ -0,0 +1,66 @@ +From 495fcec8648cdfb483b5b9ab310f3839f07cb3b8 Mon Sep 17 00:00:00 2001 +From: Douglas Anderson +Date: Fri, 8 Jul 2022 17:09:52 -0700 +Subject: tracing: Fix sleeping while atomic in kdb ftdump + +From: Douglas Anderson + +commit 495fcec8648cdfb483b5b9ab310f3839f07cb3b8 upstream. + +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 ff895103a84a ("tracing: +Save off entry when peeking at next entry"), which added the +allocation in that path. The problematic commit was already fixed by +commit 8e99cf91b99b ("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 efbbdaa22bb7 ("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: ff895103a84a ("tracing: Save off entry when peeking at next entry") +Fixes: efbbdaa22bb7 ("tracing: Show real address for trace event arguments") +Signed-off-by: Douglas Anderson +Signed-off-by: Steven Rostedt (Google) +Signed-off-by: Greg Kroah-Hartman +--- + kernel/trace/trace.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +--- a/kernel/trace/trace.c ++++ b/kernel/trace/trace.c +@@ -9416,6 +9416,12 @@ void trace_init_global_iter(struct trace + /* Output in nanoseconds only if we are using a clock in nanoseconds. */ + if (trace_clocks[iter->tr->clock_id].in_ns) + iter->iter_flags |= TRACE_FILE_TIME_IN_NS; ++ ++ /* Can not use kmalloc for iter.temp and iter.fmt */ ++ iter->temp = static_temp_buf; ++ iter->temp_size = STATIC_TEMP_BUF_SIZE; ++ iter->fmt = static_fmt_buf; ++ iter->fmt_size = STATIC_FMT_BUF_SIZE; + } + + void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) +@@ -9449,11 +9455,6 @@ void ftrace_dump(enum ftrace_dump_mode o + + /* Simulate the iterator */ + trace_init_global_iter(&iter); +- /* Can not use kmalloc for iter.temp and iter.fmt */ +- iter.temp = static_temp_buf; +- iter.temp_size = STATIC_TEMP_BUF_SIZE; +- iter.fmt = static_fmt_buf; +- iter.fmt_size = STATIC_FMT_BUF_SIZE; + + for_each_tracing_cpu(cpu) { + atomic_inc(&per_cpu_ptr(iter.array_buffer->data, cpu)->disabled); -- 2.47.3