* [PATCH] fgraph: Format error pointers as signed errno values
@ 2026-10-20 10:47 Donglin Peng
0 siblings, 0 replies; only message in thread
From: Donglin Peng @ 2026-10-20 10:47 UTC (permalink / raw)
To: rostedt; +Cc: mhiramat, linux-trace-kernel, linux-kernel, pengdonglin
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-20 10:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-20 10:47 [PATCH] fgraph: Format error pointers as signed errno values Donglin Peng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox