From: Donglin Peng <dolinux.peng@gmail.com>
To: rostedt@goodmis.org
Cc: mhiramat@kernel.org, dolinux.peng@gmai.com,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
pengdonglin <pengdonglin@xiaomi.com>
Subject: [PATCH v6 1/4] tracing: Avoid BTF lookup in atomic context
Date: Wed, 16 Sep 2026 21:32:15 +0800 [thread overview]
Message-ID: <20260916133218.1282590-2-dolinux.peng@gmail.com> (raw)
In-Reply-To: <20260916133218.1282590-1-dolinux.peng@gmail.com>
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.
Fixes: ebeed8d4a555 ("tracing/probes: Move finding func-proto API and getting func-param API to trace_btf")
Signed-off-by: pengdonglin <pengdonglin@xiaomi.com>
---
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 00172f301f25..ae562192b619 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.34.1
next prev parent reply other threads:[~2026-09-16 13:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 13:32 [PATCH v6 0/4] Use BTF to trim return values Donglin Peng
2026-09-16 13:32 ` Donglin Peng [this message]
2026-09-16 13:32 ` [PATCH v6 2/4] ftrace: Build trace_btf.c when CONFIG_DEBUG_INFO_BTF is enabled Donglin Peng
2026-09-16 13:32 ` [PATCH v6 3/4] fgraph: Enhance funcgraph-retval with BTF-based type-aware output Donglin Peng
2026-09-16 13:32 ` [PATCH v6 4/4] tracing: Update funcgraph-retval documentation Donglin Peng
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=20260916133218.1282590-2-dolinux.peng@gmail.com \
--to=dolinux.peng@gmail.com \
--cc=dolinux.peng@gmai.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=pengdonglin@xiaomi.com \
--cc=rostedt@goodmis.org \
/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®