Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing: Pretty-print enum parameters in function arguments

Currently, print_function_args() prints enum parameter values
in decimal format, reducing trace log readability.

Use BTF information to resolve enum parameters and print their
symbolic names (where available). This improves readability by
showing meaningful identifiers instead of raw numbers.

Before:
mod_memcg_lruvec_state(lruvec=0xffff..., idx=5, val=320)

After:
mod_memcg_lruvec_state(lruvec=0xffff..., idx=5 [NR_SLAB_RECLAIMABLE_B], val=320)

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Link: https://patch.msgid.link/20260209071949.4040193-1-dolinux.peng@gmail.com
Signed-off-by: Donglin Peng <pengdonglin@xiaomi.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by

Donglin Peng and committed by
Steven Rostedt (Google)
6b0c7c28 f54f08b1

+11 -1
+11 -1
kernel/trace/trace_output.c
··· 719 719 { 720 720 const struct btf_param *param; 721 721 const struct btf_type *t; 722 + const struct btf_enum *enums; 722 723 const char *param_name; 723 724 char name[KSYM_NAME_LEN]; 724 725 unsigned long arg; 725 726 struct btf *btf; 726 727 s32 tid, nr = 0; 727 - int a, p, x; 728 + int a, p, x, i; 728 729 u16 encode; 729 730 730 731 trace_seq_printf(s, "("); ··· 779 778 break; 780 779 case BTF_KIND_ENUM: 781 780 trace_seq_printf(s, "%ld", arg); 781 + enums = btf_enum(t); 782 + for (i = 0; i < btf_vlen(t); i++) { 783 + if (arg == enums[i].val) { 784 + trace_seq_printf(s, " [%s]", 785 + btf_name_by_offset(btf, 786 + enums[i].name_off)); 787 + break; 788 + } 789 + } 782 790 break; 783 791 default: 784 792 /* This does not handle complex arguments */