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 1/2] fgraph: Format error pointers as signed errno values
Date: Wed, 25 Nov 2026 13:19:53 -0500 [thread overview]
Message-ID: <20261125182022.946937059@kernel.org> (raw)
In-Reply-To: <20261125181952.861853319@kernel.org>
From: pengdonglin <pengdonglin@xiaomi.com>
The BTF-aware funcgraph-retval formatter currently treats all pointer
returns as hexadecimal values. Error pointers returned with ERR_PTR()
therefore appear as high unsigned addresses in smart mode, obscuring the
underlying errno.
Recognize error-pointer values for pointer return types in
btf_trim_retval() and select signed decimal formatting.
Before:
trim_retval_ptr_error(); /* ret=0xffffffffffffffea */
After:
trim_retval_ptr_error(); /* ret=-22 */
Users who need to inspect the raw encoded value can enable
funcgraph-retval-hex, which produces:
trim_retval_ptr_error(); /* ret=0xffffffffffffffea */
Link: https://patch.msgid.link/20261020104710.2366146-1-dolinux.peng@gmail.com
Signed-off-by: pengdonglin <pengdonglin@xiaomi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace_btf.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/trace/trace_btf.c b/kernel/trace/trace_btf.c
index f0e0c04d58d9..301024d3f2e9 100644
--- a/kernel/trace/trace_btf.c
+++ b/kernel/trace/trace_btf.c
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/btf.h>
+#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/kallsyms.h>
@@ -214,6 +215,12 @@ void btf_trim_retval(unsigned long func, unsigned long *retval, bool *print_retv
if (signed_type && !hex)
*retval = sign_extend64(*retval, msb);
break;
+ case BTF_KIND_PTR:
+ if (!hex && IS_ERR_VALUE(*retval))
+ *fmt = RETVAL_FMT_DEC;
+ else
+ *fmt = RETVAL_FMT_HEX;
+ break;
default:
*fmt = RETVAL_FMT_HEX;
break;
--
2.53.0
next prev parent reply other threads:[~2026-11-25 18:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 18:19 [for-next][PATCH 0/2] ftrace: Updates for 7.5 Steven Rostedt
2026-11-25 18:19 ` Steven Rostedt [this message]
2026-11-25 18:19 ` [for-next][PATCH 2/2] ftrace: Speed up module enable by binary searching module symbols 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=20261125182022.946937059@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®