mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	pengdonglin <pengdonglin@xiaomi.com>
Subject: [for-next][PATCH 2/9] tracing: Avoid BTF lookup in atomic context
Date: Mon, 19 Oct 2026 15:23:46 -0400	[thread overview]
Message-ID: <20261019192359.325485958@kernel.org> (raw)
In-Reply-To: <20261019192344.004592683@kernel.org>

From: pengdonglin <pengdonglin@xiaomi.com>

The function graph trace formatter can be called from ftrace_dump_one()
with interrupts disabled. When ftrace_dump_on_oops is enabled, the trace
panic notifier can reach ftrace_dump() from the panic path, including the
nmi_panic() path used by the hard lockup detector.

btf_find_func_proto() calls bpf_find_btf_id(), which may initialize vmlinux
BTF under a mutex. Skip the BTF lookup when running in an atomic context
or with interrupts disabled, and fall back to the existing return value
formatting.

Link: https://patch.msgid.link/20260916133218.1282590-2-dolinux.peng@gmail.com
Fixes: ebeed8d4a555 ("tracing/probes: Move finding func-proto API and getting func-param API to trace_btf")
Signed-off-by: pengdonglin <pengdonglin@xiaomi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_btf.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/trace/trace_btf.c b/kernel/trace/trace_btf.c
index ee7a04886bf6..b8370ae9bd54 100644
--- a/kernel/trace/trace_btf.c
+++ b/kernel/trace/trace_btf.c
@@ -15,6 +15,9 @@ const struct btf_type *btf_find_func_proto(const char *func_name, struct btf **b
 	const struct btf_type *t;
 	s32 id;
 
+	if (unlikely(in_atomic() || irqs_disabled()))
+		return NULL;
+
 	id = bpf_find_btf_id(func_name, BTF_KIND_FUNC, btf_p);
 	if (id < 0)
 		return NULL;
-- 
2.53.0

  parent reply	other threads:[~2026-10-19 19:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 19:23 [for-next][PATCH 0/9] tracing: Updates for 7.4 Steven Rostedt
2026-10-19 19:23 ` [for-next][PATCH 1/9] ftrace: Have stacktrace option work with func-args Steven Rostedt
2026-10-19 19:23 ` Steven Rostedt [this message]
2026-10-19 19:23 ` [for-next][PATCH 3/9] ftrace: Build trace_btf.c when CONFIG_DEBUG_INFO_BTF is enabled Steven Rostedt
2026-10-19 19:23 ` [for-next][PATCH 4/9] fgraph: Enhance funcgraph-retval with BTF-based type-aware output Steven Rostedt
2026-10-19 19:23 ` [for-next][PATCH 5/9] tracing: Update funcgraph-retval documentation Steven Rostedt
2026-10-19 19:23 ` [for-next][PATCH 6/9] ftrace: Add max field to function profiler stats Steven Rostedt
2026-10-19 19:23 ` [for-next][PATCH 7/9] ftrace: Do not leak a modules empty page group Steven Rostedt
2026-10-19 19:23 ` [for-next][PATCH 8/9] ftrace: Let ftrace_call_adjust() reject a patch site Steven Rostedt
2026-10-19 19:23 ` [for-next][PATCH 9/9] ftrace: Initialize modname and offset in print_rec() Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261019192359.325485958@kernel.org \
    --to=rostedt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=pengdonglin@xiaomi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®