Skip to content

tracing/probes: Clean up and refactor argument parser

Masami Hiramatsu (Google) linux-kselftest linux-trace-kernel lkml 2 versions – In review

Get series with b4
b4 am 178399136606.27810.4469135881050354189.stgit@devnote2

Versions newest first · linked by author and title

  1. v3 Latest5 patches 2 repliesIn review
  2. v15 patches 0 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5tracing/probes: Refactor parse_probe_vars()kernel/trace/trace_probe.c+140 -970 replies
2/5tracing/probes: Refactor parse_probe_arg()kernel/trace/trace_probe.c+174 -1260 replies
3/5tracing/probes: Sort ERRORS list in trace_probe.h alphabeticallykernel/trace/trace_probe.h+80 -800 replies
4/5tracing/probes: Extend max length of argument stringkernel/trace/trace_fprobe.c kernel/trace/trace_kprobe.c kernel/trace/trace_probe.h +4 more+8 -72 replies
5/5tracing/probes: Eliminate recursion in parse_probe_arg()kernel/trace/trace_probe.c kernel/trace/trace_probe.h tools/testing/selftests/ftrace/test.d/dynevent/fprobe_syntax_errors.tc +2 more+242 -1390 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/5] tracing/probes: Clean up and refactor argument parser

Hi,

This is the 3rd version of the series which refactors and cleans up the fetcharg parser in the trace_probe. The previous version is here:

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

The main goals are to improve code readability, prevent kernel stack overflow by eliminating recursive function calls, and extend the argument string length limit to support complex BTF typecast expressions.

In this version, I fixed to remove unused variable and add a error log in parse_this_cpu() [5/5].

Patches:
- Patch 1: Decomposes parse_probe_vars() into smaller, dedicated helper functions for parsing specific variable types ($retval, $stack, etc.).
- Patch 2: Decomposes parse_probe_arg() into static helper subroutines for handling registers, memory/symbols, and immediates.
- Patch 3: Alphabetizes the ERRORS macros list in trace_probe.h to improve readability.
- Patch 4: Extends MAX_ARGSTR_LEN from 63 to 255 for long BTF cast/dereference arguments, and introduces MAX_COMMON_HEAD_LEN to prevent regression on match head commands.
- Patch 5: Eliminates recursion in parse_probe_arg() using a loop and a parse state stack integrated into traceprobe_parse_context. It also raises the nesting limit to 8 and updates the selftest scripts.

Thanks,

---

Masami Hiramatsu (5):
tracing/probes: Refactor parse_probe_vars() tracing/probes: Refactor parse_probe_arg() tracing/probes: Sort ERRORS list in trace_probe.h alphabetically tracing/probes: Extend max length of argument string tracing/probes: Eliminate recursion in parse_probe_arg()

 kernel/trace/trace_fprobe.c                        |    2 
 kernel/trace/trace_kprobe.c                        |    2 
 kernel/trace/trace_probe.c                         |  833 ++++++++++++--------
 kernel/trace/trace_probe.h                         |  196 +++--
 kernel/trace/trace_uprobe.c                        |    2 
 .../ftrace/test.d/dynevent/fprobe_syntax_errors.tc |    6 
 .../ftrace/test.d/dynevent/tprobe_syntax_errors.tc |    4 
 .../ftrace/test.d/kprobe/kprobe_syntax_errors.tc   |    6 
 8 files changed, 623 insertions(+), 428 deletions(-)

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