From nobody Sun Oct 5 16:15:50 2025 Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4CC8288C13; Thu, 31 Jul 2025 23:31:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754004674; cv=none; b=UMOcp9tM91Bfzbs8aRWz5czirVyZbbU8y2rK6n9i0GEt8maAaBRlGxwjooPcR4buZ7TpiGjp++L4DsfBhYysmxglvX8O5gihsfpwDwz41NdX6YQbS9wCorGXPld9ugCsslikRJZDDFvARobxZeif8PHvopBN1viBXxQGDrUQmQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754004674; c=relaxed/simple; bh=X6ag863tsAMX72vxVmuzaAl3aNsCRnexcpmqmW3S/bw=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=TgJeAeXmmojF9VvrJN34wteNuVRQzOxWPNfLnel18NoT4DJPsUr0XXLbkwadlVeoTq7Ipo9stMIp2KspnPM8gSIVPuYUFHLxTAAraGTl1y4j4+nHlm0bi1rsxVrpOadGjOGy+hVc1nDLIAMVNIjr0T0Q4YaXr2I/HwVV6f1p2CY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org; spf=pass smtp.mailfrom=goodmis.org; arc=none smtp.client-ip=216.40.44.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=goodmis.org Received: from omf09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 348081A0B32; Thu, 31 Jul 2025 23:31:09 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: rostedt@goodmis.org) by omf09.hostedemail.com (Postfix) with ESMTPA id 8082B20025; Thu, 31 Jul 2025 23:31:07 +0000 (UTC) Date: Thu, 31 Jul 2025 19:31:26 -0400 From: Steven Rostedt To: LKML , Linux Trace Kernel Cc: Masami Hiramatsu , Mathieu Desnoyers , bpf@vger.kernel.org, Douglas Raillard Subject: [PATCH] tracing: Have unsigned int function args displayed as hexadecimal Message-ID: <20250731193126.2eeb21c6@gandalf.local.home> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Stat-Signature: afjqzmu6nzyhwkeonr138bmxsjxupxw3 X-Rspamd-Server: rspamout08 X-Rspamd-Queue-Id: 8082B20025 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Session-ID: U2FsdGVkX1/YeDc0ItVMUA3mLMe0onyOkUEa2serYZM= X-HE-Tag: 1754004667-959313 X-HE-Meta: U2FsdGVkX1+z+Dq5IE/EHdZLBzL2QtoUEsiLkpqrXCweM9zvEJ9RW3b7LYH5RoEWW4wV8oerCSaWKgX4HFYmGFtJSAtXaCdwOoRibagsLWbukgTeUY623Ue9piuaZkRJmCuuPkduW528/ME/qIOceA/NZ3GDmW+wssgNvwjpS2HDurBz3VG/rVN9ZlbN8nr4rtWZ4lU1nBO1YMXwqjSsMX3FdKpAPa3qEq51DdiBwXP22xpabwLns5Pwc0s4wbRHebj9NTGbuNaocvEvO9ZCUCvns9ZW4z3ZVG4Ow+yXmaofZ7AfuCu4pePE4GsNEPOPaBwOiEvIzdfmAhQTadIhnQluSBHuziRJJVkOx64yARTdh2zmgpO0vX0ShDIqOkHs Content-Type: text/plain; charset="utf-8" From: Steven Rostedt Most function arguments that are passed in as unsigned int or unsigned long are better displayed as hexadecimal than normal integer. For example, the functions: static void __create_object(unsigned long ptr, size_t size, int min_count, gfp_t gfp, unsigned int objflags); static bool stack_access_ok(struct unwind_state *state, unsigned long _addr, size_t len); void __local_bh_disable_ip(unsigned long ip, unsigned int cnt); Show up in the trace as: __create_object(ptr=3D-131387050520576, size=3D4096, min_count=3D1, gfp= =3D3264, objflags=3D0) <-kmem_cache_alloc_noprof stack_access_ok(state=3D0xffffc9000233fc98, _addr=3D-60473102566256, le= n=3D8) <-unwind_next_frame __local_bh_disable_ip(ip=3D-2127311112, cnt=3D256) <-handle_softirqs Instead, by displaying unsigned as hexadecimal, they look more like this: __create_object(ptr=3D0xffff8881028d2080, size=3D0x280, min_count=3D1, = gfp=3D0x82820, objflags=3D0x0) <-kmem_cache_alloc_node_noprof stack_access_ok(state=3D0xffffc90000003938, _addr=3D0xffffc90000003930,= len=3D0x8) <-unwind_next_frame __local_bh_disable_ip(ip=3D0xffffffff8133cef8, cnt=3D0x100) <-handle_so= ftirqs Which is much easier to understand as most unsigned longs are usually just pointers. Even the "unsigned int cnt" in __local_bh_disable_ip() looks better as hexadecimal as a lot of flags are passed as unsigned. Signed-off-by: Steven Rostedt (Google) Acked-by: Masami Hiramatsu (Google) Acked-by: Yonghong Song --- kernel/trace/trace_output.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index 0b3db02030a7..b18393d66a7f 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c @@ -690,6 +690,12 @@ int trace_print_lat_context(struct trace_iterator *ite= r) } =20 #ifdef CONFIG_FUNCTION_TRACE_ARGS + +static u32 btf_type_int(const struct btf_type *t) +{ + return *(u32 *)(t + 1); +} + void print_function_args(struct trace_seq *s, unsigned long *args, unsigned long func) { @@ -701,6 +707,8 @@ void print_function_args(struct trace_seq *s, unsigned = long *args, struct btf *btf; s32 tid, nr =3D 0; int a, p, x; + int int_data; + u16 encode; =20 trace_seq_printf(s, "("); =20 @@ -744,7 +752,14 @@ void print_function_args(struct trace_seq *s, unsigned= long *args, trace_seq_printf(s, "0x%lx", arg); break; case BTF_KIND_INT: - trace_seq_printf(s, "%ld", arg); + /* Get the INT encodoing */ + int_data =3D btf_type_int(t); + encode =3D BTF_INT_ENCODING(int_data); + /* Print unsigned ints as hex */ + if (encode & BTF_INT_SIGNED) + trace_seq_printf(s, "%ld", arg); + else + trace_seq_printf(s, "0x%lx", arg); break; case BTF_KIND_ENUM: trace_seq_printf(s, "%ld", arg); --=20 2.47.2