Skip to content

tracing/probes: Support function parameter access from return probe

Masami Hiramatsu (Google) linux-doc linux-kselftest linux-trace-kernel lkml 3 versions – New

Get series with b4
b4 am 170952359657.229804.14867636035660590574.stgit@devnote2

Versions newest first · linked by author and title

  1. v3 Latest8 patches 0 repliesNew
  2. v27 patches 12 repliesSuperseded
  3. v1 RFC5 patches 1 replySuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8fprobe: Fix to allocate entry_data_size buffer with rethook instanceskernel/trace/fprobe.c+6 -80 replies
2/8tracing/fprobe-event: cleanup: Fix a wrong comment in fprobe eventkernel/trace/trace_fprobe.c+1 -10 replies
3/8tracing/probes: Cleanup probe argument parserkernel/trace/trace_probe.c+137 -930 replies
4/8tracing/probes: cleanup: Set trace_probe::nr_args at trace_probe_initkernel/trace/trace_eprobe.c kernel/trace/trace_fprobe.c kernel/trace/trace_kprobe.c +3 more+11 -90 replies
5/8tracing: Remove redundant #else block for BTF args from READMEkernel/trace/trace.c+1 -30 replies
6/8tracing/probes: Support $argN in return probe (kprobe and fprobe)kernel/trace/trace.c kernel/trace/trace_eprobe.c kernel/trace/trace_fprobe.c +7 more+289 -620 replies
7/8selftests/ftrace: Add test cases for entry args at function exittools/testing/selftests/ftrace/test.d/dynevent/fprobe_entry_arg.tc tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_entry_arg.tc+36 -00 replies
8/8Documentation: tracing: Add entry argument access at function exitDocumentation/trace/fprobetrace.rst Documentation/trace/kprobetrace.rst+40 -00 replies

Reviews trailers per patch

3 of 8 patches have a Reviewed-by or Acked-by.

PatchJiri OlsaSteven Rostedt (Google)
1/8T-b
2/8R-b
3/8R-b
4/8
5/8R-b
6/8
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/8] tracing/probes: Support function parameter access from return probe

Hi,

Here is version 3 series of patches to support accessing function entry data from function *return* probes (including kretprobe and fprobe-exit event). The previous version is here;

https://lore.kernel.org/all/170891987362.609861.6767830614537418260.stgit@devnote2/

In this version, [1/8] is a bugfix patch (but note that this is already pushed to probes-fixes-v6.8-rc5, just for reference), updated [4/8] changelog and build error, fixes selftests error [6/8], update document[8/8] and added Steve's reviewed-by.

This allows us to access the results of some functions, which returns the error code and its results are passed via function parameter, such as an structure-initialization function.

For example, vfs_open() will link the file structure to the inode and update mode. Thus we can trace that changes.

 # echo 'f vfs_open mode=file->f_mode:x32 inode=file->f_inode:x64' >> dynamic_events
 # echo 'f vfs_open%return mode=file->f_mode:x32 inode=file->f_inode:x64' >> dynamic_events 
 # echo 1 > events/fprobes/enable 
 # cat trace
              sh-131     [006] ...1.  1945.714346: vfs_open__entry: (vfs_open+0x4/0x40) mode=0x2 inode=0x0
              sh-131     [006] ...1.  1945.714358: vfs_open__exit: (do_open+0x274/0x3d0 <- vfs_open) mode=0x4d801e inode=0xffff888008470168
             cat-143     [007] ...1.  1945.717949: vfs_open__entry: (vfs_open+0x4/0x40) mode=0x1 inode=0x0
             cat-143     [007] ...1.  1945.717956: vfs_open__exit: (do_open+0x274/0x3d0 <- vfs_open) mode=0x4a801d inode=0xffff888005f78d28
             cat-143     [007] ...1.  1945.720616: vfs_open__entry: (vfs_open+0x4/0x40) mode=0x1 inode=0x0
             cat-143     [007] ...1.  1945.728263: vfs_open__exit: (do_open+0x274/0x3d0 <- vfs_open) mode=0xa800d inode=0xffff888004ada8d8

So as you can see those fields are initialized at exit.

This series is based on v6.8-rc5 kernel or you can checkout from

https://git.kernel.org/pub/scm/linux/kernel/git/mhiramat/linux.git/log/?h=topic/entry-data

Thank you,

---

Masami Hiramatsu (Google) (8):
fprobe: Fix to allocate entry_data_size buffer with rethook instances tracing/fprobe-event: cleanup: Fix a wrong comment in fprobe event tracing/probes: Cleanup probe argument parser tracing/probes: cleanup: Set trace_probe::nr_args at trace_probe_init
tracing: Remove redundant #else block for BTF args from README tracing/probes: Support $argN in return probe (kprobe and fprobe) selftests/ftrace: Add test cases for entry args at function exit
Documentation: tracing: Add entry argument access at function exit

 Documentation/trace/fprobetrace.rst                |   31 +
 Documentation/trace/kprobetrace.rst                |    9 
 kernel/trace/fprobe.c                              |   14 -
 kernel/trace/trace.c                               |    5 
 kernel/trace/trace_eprobe.c                        |    8 
 kernel/trace/trace_fprobe.c                        |   59 ++-
 kernel/trace/trace_kprobe.c                        |   58 ++-
 kernel/trace/trace_probe.c                         |  417 ++++++++++++++------
 kernel/trace/trace_probe.h                         |   30 +
 kernel/trace/trace_probe_tmpl.h                    |   10 
 kernel/trace/trace_uprobe.c                        |   14 -
 .../ftrace/test.d/dynevent/fprobe_entry_arg.tc     |   18 +
 .../ftrace/test.d/dynevent/fprobe_syntax_errors.tc |    4 
 .../ftrace/test.d/kprobe/kprobe_syntax_errors.tc   |    2 
 .../ftrace/test.d/kprobe/kretprobe_entry_arg.tc    |   18 +
 15 files changed, 521 insertions(+), 176 deletions(-)
 create mode 100644 tools/testing/selftests/ftrace/test.d/dynevent/fprobe_entry_arg.tc
 create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_entry_arg.tc

--
Masami Hiramatsu (Google) <[email protected]>