Linux Trace Kernel
 help / color / mirror / Atom feed
* [PATCH] fgraph: Format error pointers as signed errno values
@ 2026-10-20 10:47 Donglin Peng
  2026-11-24 11:07 ` Donglin Peng
  0 siblings, 1 reply; 3+ messages 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] 3+ messages in thread

* Re: [PATCH] fgraph: Format error pointers as signed errno values
  2026-10-20 10:47 [PATCH] fgraph: Format error pointers as signed errno values Donglin Peng
@ 2026-11-24 11:07 ` Donglin Peng
  2026-11-24 14:34   ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Donglin Peng @ 2026-11-24 11:07 UTC (permalink / raw)
  To: rostedt; +Cc: mhiramat, linux-trace-kernel, linux-kernel, pengdonglin

Just a quick ping on this patch.

Thanks,
Donglin

On Tue, Oct 20, 2026 at 6:47 PM Donglin Peng <dolinux.peng@gmail.com> wrote:
>
> 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	[flat|nested] 3+ messages in thread

* Re: [PATCH] fgraph: Format error pointers as signed errno values
  2026-11-24 11:07 ` Donglin Peng
@ 2026-11-24 14:34   ` Steven Rostedt
  0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2026-11-24 14:34 UTC (permalink / raw)
  To: Donglin Peng; +Cc: mhiramat, linux-trace-kernel, linux-kernel, pengdonglin

On Tue, 24 Nov 2026 19:07:55 +0800
Donglin Peng <dolinux.peng@gmail.com> wrote:

> Just a quick ping on this patch.
> 

It's in queue. I have 153 patches in my todo list and unfortunately, fixes
always preempt enhancements. This patch is more of an enhancement than a
fix. But I'll get to it.

-- Steve

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-24 14:34 UTC | newest]

Thread overview: 3+ messages (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
2026-11-24 11:07 ` Donglin Peng
2026-11-24 14:34   ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox