From: Donglin Peng <dolinux.peng@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
pengdonglin <pengdonglin@xiaomi.com>
Subject: [PATCH v2 0/2] Use BTF to trim return values
Date: Mon, 8 Dec 2025 21:19:15 +0800 [thread overview]
Message-ID: <20251208131917.2444620-1-dolinux.peng@gmail.com> (raw)
From: pengdonglin <pengdonglin@xiaomi.com>
This patch series addresses two limitations of the funcgraph-retval feature:
1. Previously, return values were printed even for void functions.
2. For return types narrower than a register, high-bit corruption could
lead to incorrect values.
By leveraging BTF to obtain precise return type information, we now:
1. Suppress output for void functions (eliminating noise)
2. Properly truncate values to match the actual return type width (ensuring
correctness)
These improvements make funcgraph-retval more accurate and useful.
Before:
# perf ftrace -G vfs_read --graph-opts retval
...
1) | _raw_spin_unlock() {
1) 0.074 us | do_raw_spin_unlock(); /* ret=0x1 */
1) 0.072 us | preempt_count_sub(); /* ret=0x0 */
1) 0.373 us | } /* _raw_spin_unlock ret=0x80000000 */
1) | down_read() {
1) 0.070 us | __cond_resched(); /* ret=0x0 */
1) 0.069 us | preempt_count_add(); /* ret=0x0 */
1) 0.071 us | preempt_count_sub(); /* ret=0x0 */
1) 0.612 us | } /* down_read ret=0x80000000 */
1) | down_write() {
1) 0.070 us | __cond_resched(); /* ret=0x0 */
1) 0.071 us | preempt_count_add(); /* ret=0x0 */
1) 0.070 us | preempt_count_sub(); /* ret=0x0 */
1) 0.605 us | } /* down_write ret=0x80000000 */
After:
# perf ftrace -G vfs_read --graph-opts retval
...
0) | _raw_spin_unlock() {
0) 0.075 us | do_raw_spin_unlock();
0) 0.075 us | preempt_count_sub();
0) 0.380 us | } /* _raw_spin_unlock */
0) | down_read() {
0) 0.070 us | __cond_resched(); /* ret=0x0 */
0) 0.073 us | preempt_count_add();
0) 0.072 us | preempt_count_sub();
0) 0.586 us | } /* down_read */
0) | down_write() {
0) 0.070 us | __cond_resched(); /* ret=0x0 */
0) 0.072 us | preempt_count_add();
0) 0.072 us | preempt_count_sub();
0) 0.676 us | } /* down_write */
Changelog:
v2:
- Update the funcgraph-retval documentation
- Revise the cover letter
v1:
- Link: https://lore.kernel.org/all/20251207142742.229924-1-dolinux.peng@gmail.com/
pengdonglin (2):
fgraph: Use BTF to trim and filter return values
tracing: Update funcgraph-retval documentation
Documentation/trace/ftrace.rst | 76 ++++++++++++++++------------
kernel/trace/trace_functions_graph.c | 64 +++++++++++++++++++----
2 files changed, 97 insertions(+), 43 deletions(-)
--
2.34.1
next reply other threads:[~2025-12-08 13:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-08 13:19 Donglin Peng [this message]
2025-12-08 13:19 ` [PATCH v2 1/2] fgraph: Use BTF to trim and filter return values Donglin Peng
2025-12-09 0:48 ` Masami Hiramatsu
2025-12-09 1:42 ` Donglin Peng
2025-12-09 3:14 ` Donglin Peng
2025-12-08 13:19 ` [PATCH v2 2/2] tracing: Update funcgraph-retval documentation Donglin Peng
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=20251208131917.2444620-1-dolinux.peng@gmail.com \
--to=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox