On Tue, 1 Sep 2026 21:46:01 +0800 Donglin Peng <[email protected]> wrote:
> From: pengdonglin <[email protected]> > > The funcgraph-retval option currently records one machine-word return > value without considering the function's declared return type. As a > result, void-returning functions can produce meaningless output, and > return values narrower than a general-purpose register can include > undefined high bits. > > This series uses kernel BTF to identify the return type of traced > functions and to improve funcgraph-retval output: > > - Do not print a return value for functions with a void return type. > - Trim integer, enum, struct, and union values to the available return > value width when the BTF type provides suitable size information. > - Format integer, enum, and boolean values according to their BTF > encoding. > - Mark values as "(trunc)" when the return type is wider than the > value captured by the function graph tracer. Hmm, I really don't like the "(trunc)" If it's the real return type, then it should just print what the real size is. No need to state it was truncated. -- Steve > > Here is an output comparison: > > Before: > # perf ftrace -G vfs_read --graph-opts retval > ... > 1) | touch_atime() { > 1) | atime_needs_update() { > 1) 0.069 us | make_vfsuid(); /* ret=0x0 */ > 1) 0.067 us | make_vfsgid(); /* ret=0x0 */ > 1) | current_time() { > 1) 0.197 us | ktime_get_coarse_real_ts64_mg(); /* > ret=0x187f886aec3ed6f5 */ > 1) 0.352 us | } /* current_time ret=0x69380753 */ > 1) 0.792 us | } /* atime_needs_update ret=0x0 */ > 1) 0.937 us | } /* touch_atime ret=0x0 */ > > After: > # perf ftrace -G vfs_read --graph-opts retval > ... > 2) | touch_atime() { > 2) | atime_needs_update() { > 2) 0.070 us | make_vfsuid(); /* ret=0x0 */ > 2) 0.070 us | make_vfsgid(); /* ret=0x0 */ > 2) | current_time() { > 2) 0.162 us | ktime_get_coarse_real_ts64_mg(); > 2) 0.312 us | } /* current_time ret=0x69380649(trunc) */ > 2) 0.753 us | } /* atime_needs_update ret=false */ > 2) 0.899 us | } /* touch_atime */
