Commit 90035d3c authored by Ben Gainey's avatar Ben Gainey Committed by Namhyung Kim
Browse files

tools/perf: Allow inherit + PERF_SAMPLE_READ when opening events



The "perf record" tool will now default to this new mode if the user
specifies a sampling group when not in system-wide mode, and when
"--no-inherit" is not specified.

This change updates evsel to allow the combination of inherit
and PERF_SAMPLE_READ.

A fallback is implemented for kernel versions where this feature is not
supported.

Signed-off-by: default avatarBen Gainey <ben.gainey@arm.com>
Cc: james.clark@arm.com
Link: https://lore.kernel.org/r/20241001121505.1009685-3-ben.gainey@arm.com


Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent 80c281fc
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ Following tests are defined (with perf commands):
  perf record --call-graph fp kill              (test-record-graph-fp-aarch64)
  perf record -e '{cycles,instructions}' kill   (test-record-group1)
  perf record -e '{cycles/period=1/,instructions/period=2/}:S' kill (test-record-group2)
  perf record -e '{cycles,cache-misses}:S' kill (test-record-group-sampling1)
  perf record -c 10000 -e '{cycles,cache-misses}:S' kill (test-record-group-sampling2)
  perf record -D kill                           (test-record-no-delay)
  perf record -i kill                           (test-record-no-inherit)
  perf record -n kill                           (test-record-no-samples)
+2 −0
Original line number Diff line number Diff line
@@ -18,5 +18,7 @@ sample_type=65927
mmap=0
comm=0
task=0
inherit=0

[event:system-wide-dummy]
inherit=0
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ sample_period=4000
sample_type=391
read_format=4|20
disabled=0
inherit=1
inherit=0
pinned=0
exclusive=0
exclude_user=0
+2 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
command = record
args    = --no-bpf-event -e '{cycles,cache-misses}:S' kill >/dev/null 2>&1
ret     = 1
kernel_until = 6.12

[event-1:base-record]
fd=1
@@ -18,7 +19,7 @@ group_fd=1
type=0
config=3

# default | PERF_SAMPLE_READ
# default | PERF_SAMPLE_READ | PERF_SAMPLE_PERIOD
sample_type=343

# PERF_FORMAT_ID | PERF_FORMAT_GROUP  | PERF_FORMAT_LOST
+50 −0
Original line number Diff line number Diff line
[config]
command = record
args    = --no-bpf-event -e '{cycles,cache-misses}:S' kill >/dev/null 2>&1
ret     = 1
kernel_since = 6.12

[event-1:base-record]
fd=1
group_fd=-1

# cycles
type=0
config=0

# default | PERF_SAMPLE_READ | PERF_SAMPLE_PERIOD
sample_type=343

# PERF_FORMAT_ID | PERF_FORMAT_GROUP  | PERF_FORMAT_LOST | PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_TOTAL_TIME_RUNNING
read_format=28|31
task=1
mmap=1
comm=1
enable_on_exec=1
disabled=1

# inherit is enabled for group sampling
inherit=1

[event-2:base-record]
fd=2
group_fd=1

# cache-misses
type=0
config=3

# default | PERF_SAMPLE_READ | PERF_SAMPLE_PERIOD
sample_type=343

# PERF_FORMAT_ID | PERF_FORMAT_GROUP  | PERF_FORMAT_LOST | PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_TOTAL_TIME_RUNNING
read_format=28|31
task=0
mmap=0
comm=0
enable_on_exec=0
disabled=0
freq=0

# inherit is enabled for group sampling
inherit=1
Loading