Skip to content

Improvements to memory usage by parse events

Ian Rogers bpf lkml netdev 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest10 patches 2 repliesIn review
  2. v510 patches 13 repliesApplied
  3. v49 patches 2 repliesApplied
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v39 patches14 repliesSuperseded
v29 patches9 repliesApplied

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10perf tools: add parse events handle errortools/perf/util/parse-events.c tools/perf/util/parse-events.h tools/perf/util/pmu.c+71 -430 replies
2/10perf tools: move ALLOC_LIST into a functiontools/perf/util/parse-events.y+43 -220 replies
3/10perf tools: avoid a malloc for array eventstools/perf/util/parse-events.y+3 -50 replies
4/10perf tools: splice events onto evlist even on errortools/perf/util/parse-events.c+11 -60 replies
5/10perf tools: ensure config and str in terms are uniquetools/perf/util/parse-events.c tools/perf/util/parse-events.y+45 -100 replies
6/10perf tools: add destructors for parse event termstools/perf/util/parse-events.y+48 -210 replies
7/10perf tools: before yyabort-ing free componentstools/perf/util/parse-events.y+197 -550 replies
8/10perf tools: if pmu configuration fails free termstools/perf/util/parse-events.c+8 -10 replies
9/10perf tools: add a deep delete for parse event termstools/perf/util/parse-events.c tools/perf/util/parse-events.h tools/perf/util/parse-events.y +1 more+17 -140 replies
10/10perf tools: report initial event parsing errortools/perf/arch/powerpc/util/kvm-stat.c tools/perf/builtin-stat.c tools/perf/builtin-trace.c +4 more+84 -280 replies

Reviews trailers per patch

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

Read the v6 thread

Cover letter [PATCH v6 00/10] Improvements to memory usage by parse events

The parse events parser leaks memory for certain expressions as well as allowing a char* to reference stack, heap or .rodata. This series of patches improves the hygeine and adds free-ing operations to reclaim memory in the parser in error and non-error situations.

The series of patches was generated with LLVM's address sanitizer and libFuzzer:
https://llvm.org/docs/LibFuzzer.html
called on the parse_events function with randomly generated input. With the patches no leaks or memory corruption issues were present.

The v6 patches address a C90 compilation issue.

The v5 patches add initial error print to the set, as requested by Jiri Olsa. They also fix additional 2 missed frees in the patch 'before yyabort-ing free components' and remove a redundant new_str variable from the patch 'add parse events handle error' as spotted by Stephane Eranian.

The v4 patches address review comments from Jiri Olsa, turning a long error message into a single warning, fixing the data type in a list iterator and reordering patches.

The v3 patches address review comments from Jiri Olsa improving commit messages, handling ENOMEM errors from strdup better, and removing a printed warning if an invalid event is passed.

The v2 patches are preferable to an earlier proposed patch:
perf tools: avoid reading out of scope array

Ian Rogers (10):
perf tools: add parse events handle error perf tools: move ALLOC_LIST into a function perf tools: avoid a malloc for array events perf tools: splice events onto evlist even on error perf tools: ensure config and str in terms are unique perf tools: add destructors for parse event terms perf tools: before yyabort-ing free components perf tools: if pmu configuration fails free terms perf tools: add a deep delete for parse event terms perf tools: report initial event parsing error

 tools/perf/arch/powerpc/util/kvm-stat.c |   9 +-
 tools/perf/builtin-stat.c               |   2 +
 tools/perf/builtin-trace.c              |  16 +-
 tools/perf/tests/parse-events.c         |   3 +-
 tools/perf/util/metricgroup.c           |   2 +-
 tools/perf/util/parse-events.c          | 239 +++++++++++----
 tools/perf/util/parse-events.h          |   7 +
 tools/perf/util/parse-events.y          | 390 +++++++++++++++++-------
 tools/perf/util/pmu.c                   |  32 +-
 9 files changed, 511 insertions(+), 189 deletions(-)
Signature · 1 line
2.24.0.432.g9d3f5f5b63-goog