All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Donglin Peng <dolinux.peng@gmail.com>
Cc: rostedt@goodmis.org, ast@kernel.org, mhiramat@kernel.org,
	andrii.nakryiko@gmail.com, linux-kernel@vger.kernel.org,
	Donglin Peng <pengdonglin@xiaomi.com>,
	linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] tracing: resolve enum names for function arguments via BTF
Date: Fri, 6 Feb 2026 09:12:10 +0900	[thread overview]
Message-ID: <20260206091210.923917c8ff1f52fbdb3907ed@kernel.org> (raw)
In-Reply-To: <20260202111548.3555306-3-dolinux.peng@gmail.com>

On Mon,  2 Feb 2026 19:15:48 +0800
Donglin Peng <dolinux.peng@gmail.com> wrote:

> From: Donglin Peng <pengdonglin@xiaomi.com>
> 
> Use BTF to print symbolic names for enum-type function arguments,
> improving trace readability.
> 
> Before:
> count_memcg_events(memcg=0xffff..., idx=20, count=0x1) {
> 
> After:
> count_memcg_events(memcg=0xffff..., idx=20 [PGFAULT], count=0x1) {

Hmm, it is interesting idea. Maybe I can also introduce the same
feature to fetcharg for fprobe/kprobes as a new type.
Since the enum type should be solved in parsing the event definition,
for fprobe/kprobes the performance will not be a performance problem.

Thanks,

> 
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Cc: linux-trace-kernel@vger.kernel.org
> Signed-off-by: Donglin Peng <pengdonglin@xiaomi.com>
> ---
>  kernel/trace/trace_output.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
> index cc2d3306bb60..c395f768c3b8 100644
> --- a/kernel/trace/trace_output.c
> +++ b/kernel/trace/trace_output.c
> @@ -695,12 +695,13 @@ void print_function_args(struct trace_seq *s, unsigned long *args,
>  {
>  	const struct btf_param *param;
>  	const struct btf_type *t;
> +	const struct btf_enum *enump;
>  	const char *param_name;
>  	char name[KSYM_NAME_LEN];
>  	unsigned long arg;
>  	struct btf *btf;
>  	s32 tid, nr = 0;
> -	int a, p, x;
> +	int a, p, x, i;
>  	u16 encode;
>  
>  	trace_seq_printf(s, "(");
> @@ -754,6 +755,14 @@ void print_function_args(struct trace_seq *s, unsigned long *args,
>  			break;
>  		case BTF_KIND_ENUM:
>  			trace_seq_printf(s, "%ld", arg);
> +			for_each_enum(i, t, enump) {
> +				if (arg == enump->val) {
> +					trace_seq_printf(s, " [%s]",
> +							 btf_name_by_offset(btf,
> +							 enump->name_off));
> +					break;
> +				}
> +			}
>  			break;
>  		default:
>  			/* This does not handle complex arguments */
> -- 
> 2.34.1
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

      parent reply	other threads:[~2026-02-06  0:12 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-02 11:15 [PATCH 0/2] tracing: resolve enum names for function arguments via BTF Donglin Peng
2026-02-02 11:15 ` [PATCH 1/2] btf: Add for_each_enum and for_each_enum64 helper macros Donglin Peng
2026-02-06  0:29   ` Masami Hiramatsu
2026-02-02 11:15 ` [PATCH 2/2] tracing: resolve enum names for function arguments via BTF Donglin Peng
2026-02-02 16:12   ` Steven Rostedt
2026-02-03  2:17     ` Donglin Peng
2026-02-03 13:50       ` Donglin Peng
2026-02-03 15:17         ` Steven Rostedt
2026-02-03 16:00           ` Alexei Starovoitov
2026-02-04 14:52             ` Donglin Peng
2026-02-05  9:21               ` Donglin Peng
2026-02-05 15:56                 ` Alexei Starovoitov
2026-02-06  4:09                   ` Donglin Peng
2026-02-06 16:04                     ` Alexei Starovoitov
2026-02-08 13:08                       ` Donglin Peng
2026-02-05 18:04               ` Steven Rostedt
2026-02-06  4:04                 ` Donglin Peng
2026-02-08 13:07                 ` Donglin Peng
2026-02-08 15:27                   ` Steven Rostedt
2026-02-08 15:42                     ` Donglin Peng
2026-02-08 16:47                       ` Steven Rostedt
2026-02-04 14:16           ` Donglin Peng
2026-02-06  0:12   ` Masami Hiramatsu [this message]

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=20260206091210.923917c8ff1f52fbdb3907ed@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=dolinux.peng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.