Skip to content

perf tools: Add support for AUX area sampling

Adrian Hunter lkml 1 version Applied

Status from this message: The following commit has been merged into the perf/core branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest15 patches 5 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/15perf tools: Add kernel AUX area sampling definitionstools/include/uapi/linux/perf_event.h tools/perf/tests/attr/base-record tools/perf/tests/attr/base-stat +2 more+12 -41 reply
2/15perf tools: Add AUX area sample parsingtools/perf/tests/sample-parsing.c tools/perf/util/event.h tools/perf/util/evsel.c +2 more+47 -20 replies
3/15perf tools: Add a function to test for kernel support for AUX area samplingtools/perf/util/evlist.h tools/perf/util/record.c+31 -00 replies
4/15perf auxtrace: Move perf_evsel__find_pmu()tools/perf/util/auxtrace.c+12 -120 replies
5/15perf auxtrace: Add support for AUX area sample recordingtools/perf/util/auxtrace.c tools/perf/util/auxtrace.h tools/perf/util/pmu.h +1 more+126 -00 replies
6/15perf record: Add support for AUX area samplingtools/perf/Documentation/perf-record.txt tools/perf/builtin-record.c+26 -10 replies
7/15perf record: Add aux-sample-size config termtools/perf/Documentation/perf-record.txt tools/perf/util/auxtrace.c tools/perf/util/evsel.c +4 more+121 -10 replies
8/15perf inject: Cut AUX area samplestools/perf/builtin-inject.c+29 -00 replies
9/15perf auxtrace: Add support for dumping AUX area samplestools/perf/util/auxtrace.c tools/perf/util/auxtrace.h tools/perf/util/session.c+28 -20 replies
10/15perf session: Add facility to peek at all eventstools/perf/util/session.c tools/perf/util/session.h+33 -00 replies
11/15perf auxtrace: Add support for queuing AUX area samplestools/perf/util/auxtrace.c tools/perf/util/auxtrace.h+122 -00 replies
12/15perf pmu: When using default config, record which bits of config were changed by the usertools/perf/util/evsel.c tools/perf/util/evsel_config.h tools/perf/util/parse-events.c +2 more+56 -10 replies
13/15perf intel-pt: Add support for recording AUX area samplestools/perf/Documentation/intel-pt.txt tools/perf/arch/x86/util/auxtrace.c tools/perf/arch/x86/util/intel-pt.c+139 -33 replies
14/15perf intel-pt: Add support for decoding AUX area samplestools/perf/util/intel-pt.c+106 -30 replies
15/15perf intel-bts: Does not support AUX area samplingtools/perf/arch/x86/util/auxtrace.c tools/perf/arch/x86/util/intel-bts.c+7 -00 replies

Reviews trailers per patch

None of the 15 patches has a Reviewed-by or Acked-by.

PatchArnaldo Carvalho de Melo
1/15T-b
2/15
3/15
4/15
5/15
6/15
7/15
8/15
9/15
10/15
11/15
12/15
13/15
14/15
15/15

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

Read the v1 thread

Cover letter [PATCH 00/15] perf tools: Add support for AUX area sampling

Hi

The kernel changes for AUX area sampling are now in tip, so here are the tools' patches.

AUX area sampling allows bytes from a AUX area buffer to be copied onto samples of other events.

Here is the Intel PT documentation from patch "perf intel-pt: Add support for recording AUX area":

perf record AUX area sampling option
------------------------

To select Intel PT "sampling" the AUX area sampling option can be used:

--aux-sample

Optionally it can be followed by the sample size in bytes e.g.

--aux-sample=8192

In addition, the Intel PT event to sample must be defined e.g.

-e intel_pt//u

Samples on other events will be created containing Intel PT data e.g. the following will create Intel PT samples on the branch-misses event, note the events must be grouped using {}:

  	perf record --aux-sample -e '{intel_pt//u,branch-misses:u}'

An alternative to '--aux-sample' is to add the config term 'aux-sample-size' to events. In this case, the grouping is implied e.g.

perf record -e intel_pt//u -e branch-misses/aux-sample-size=8192/u

is the same as:

perf record -e '{intel_pt//u,branch-misses/aux-sample-size=8192/u}'

but allows for also using an address filter e.g.:

  	perf record -e intel_pt//u --filter 'filter * @/bin/ls' -e branch-misses/aux-sample-size=8192/u -- ls

It is important to select a sample size that is big enough to contain at least one PSB packet. If not a warning will be displayed:

Intel PT sample size (%zu) may be too small for PSB period (%zu)

The calculation used for that is: if sample_size <= psb_period + 256 display the warning. When sampling is used, psb_period defaults to 0 (2KiB).

The default sample size is 4KiB.

The sample size is passed in aux_sample_size in struct perf_event_attr. The sample size is limited by the maximum event size which is 64KiB. It is difficult to know how big the event might be without the trace sample attached, but the tool validates that the sample size is not greater than 60KiB.

Adrian Hunter (15):
perf tools: Add kernel AUX area sampling definitions
perf tools: Add AUX area sample parsing
perf tools: Add a function to test for kernel support for AUX area sampling perf auxtrace: Move perf_evsel__find_pmu()
perf auxtrace: Add support for AUX area sample recording
perf record: Add support for AUX area sampling
perf record: Add aux-sample-size config term
perf inject: Cut AUX area samples
perf auxtrace: Add support for dumping AUX area samples
perf session: Add facility to peek at all events
perf auxtrace: Add support for queuing AUX area samples
perf pmu: When using default config, record which bits of config were changed by the user perf intel-pt: Add support for recording AUX area samples
perf intel-pt: Add support for decoding AUX area samples
perf intel-bts: Does not support AUX area sampling

 tools/include/uapi/linux/perf_event.h     |  10 +-
 tools/perf/Documentation/intel-pt.txt     |  59 +++++-
 tools/perf/Documentation/perf-record.txt  |   9 +
 tools/perf/arch/x86/util/auxtrace.c       |   4 +
 tools/perf/arch/x86/util/intel-bts.c      |   5 +
 tools/perf/arch/x86/util/intel-pt.c       |  81 +++++++-
 tools/perf/builtin-inject.c               |  29 +++
 tools/perf/builtin-record.c               |  21 +-
 tools/perf/tests/attr/base-record         |   2 +-
 tools/perf/tests/attr/base-stat           |   2 +-
 tools/perf/tests/sample-parsing.c         |  16 +-
 tools/perf/util/auxtrace.c                | 322 ++++++++++++++++++++++++++++--
 tools/perf/util/auxtrace.h                |  42 ++++
 tools/perf/util/event.h                   |   6 +
 tools/perf/util/evlist.h                  |   1 +
 tools/perf/util/evsel.c                   |  31 +++
 tools/perf/util/evsel_config.h            |  13 ++
 tools/perf/util/intel-pt.c                | 109 +++++++++-
 tools/perf/util/parse-events.c            |  56 +++++-
 tools/perf/util/parse-events.h            |   1 +
 tools/perf/util/parse-events.l            |   1 +
 tools/perf/util/perf_event_attr_fprintf.c |   3 +-
 tools/perf/util/pmu.c                     |  10 +
 tools/perf/util/pmu.h                     |   2 +
 tools/perf/util/record.c                  |  30 +++
 tools/perf/util/record.h                  |   2 +
 tools/perf/util/session.c                 |  38 +++-
 tools/perf/util/session.h                 |   5 +
 tools/perf/util/synthetic-events.c        |  12 ++
 29 files changed, 894 insertions(+), 28 deletions(-)

Regards
Adrian