From: Donglin Peng <dolinux.peng@gmail.com>
To: rostedt@goodmis.org
Cc: mhiramat@kernel.org, linux-trace-kernel@vger.kernel.org,
linux-kernel@vger.kernel.org,
pengdonglin <pengdonglin@xiaomi.com>
Subject: [PATCH] fgraph: Format error pointers as signed errno values
Date: Tue, 20 Oct 2026 18:47:10 +0800 [thread overview]
Message-ID: <20261020104710.2366146-1-dolinux.peng@gmail.com> (raw)
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 */
Signed-off-by: pengdonglin <pengdonglin@xiaomi.com>
---
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 bcf65fec7bb1..1201105aa48b 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>
@@ -197,6 +198,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.34.1
reply other threads:[~2026-10-20 10:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261020104710.2366146-1-dolinux.peng@gmail.com \
--to=dolinux.peng@gmail.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®