Bug fixes on topdown metrics group leader selection
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest4 patches 7 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | perf topdown: Correct leader selection with sample_read enabledtools/ | +14 | 3 replies | |
| 2/4 | perf parse-events: Don't move topdown metrics events when sorting eventstools/ | +0 | 0 replies | |
| 3/4 | perf parse-events: Don't move slots event when no topdwon metrics eventtools/ tools/ tools/ | +31 | 2 replies | |
| 4/4 | perf tests: Add leader sampling test in record teststools/ | +28 | 2 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/4] Bug fixes on topdown metrics group leader selection
when counting/sampling topdown slots and metrics events, the following issues are found.
a. incorrect sampling leader selection if group only contains topdown slots event without topdown metrics event, such as
perf record -e '{slots,branches}:S' -c 10000 -vv sleep 1
In this case, the slots event should be sampled as leader but the branches event is sampled in fact like the verbose output shows.
perf_event_attr:
type 4 (cpu) size 168 config 0x400 (slots) sample_type IP|TID|TIME|READ|CPU|IDENTIFIER read_format ID|GROUP|LOST disabled 1 sample_id_all 1 exclude_guest 1
------------------------------------------------------------sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 5
------------------------------------------------------------perf_event_attr:
type 0 (PERF_TYPE_HARDWARE)
size 168
config 0x4 (PERF_COUNT_HW_BRANCH_INSTRUCTIONS)
{ sample_period, sample_freq } 10000
sample_type IP|TID|TIME|READ|CPU|IDENTIFIER
read_format ID|GROUP|LOST
sample_id_all 1
exclude_guest 1b. Fail to run the perf command
perf record -e "{slots,instructions,topdown-retiring}:S" -vv -C0 sleep 1
------------------------------------------------------------perf_event_attr:
type 4 (cpu) size 168 config 0x400 (slots) sample_type IP|TID|TIME|READ|CPU|PERIOD|IDENTIFIER read_format ID|GROUP|LOST disabled 1 sample_id_all 1 exclude_guest 1
------------------------------------------------------------sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 5
------------------------------------------------------------perf_event_attr:
type 4 (cpu)
size 168
config 0x8000 (topdown-retiring)
{ sample_period, sample_freq } 4000
sample_type IP|TID|TIME|READ|CPU|PERIOD|IDENTIFIER
read_format ID|GROUP|LOST
freq 1
sample_id_all 1
exclude_guest 1------------------------------------------------------------sys_perf_event_open: pid -1 cpu 0 group_fd 5 flags 0x8 sys_perf_event_open failed, error -22
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (topdown-retiring).
Perf tool tries to regroup the events and move topdown-retiring event closely after slots event and leads to topdown-retiring event is select to sample. This is incorrect.
c. unnecessary events regroup for the group which only has slots event but without topdown metrics events, such as
perf stat -e "{instructions,slots}" -C 0 sleep 1
WARNING: events were regrouped to match PMUs
Performance counter stats for 'CPU(s) 0':
27,581,148 slots
8,390,827 instructions
1.045546595 seconds time elapsedObviously, this events regroup is unnecessary.
The patches 1-3 separately fixes the above 3 issues in order and the patch 4/4 adds a new perf test to verify the leader sampling.
Dapeng Mi (4):
perf topdown: Correct leader selection with sample_read enabled perf parse-events: Don't move topdown metrics events when sorting
events
perf parse-events: Don't move slots event when no topdwon metrics
event
perf tests: Add leader sampling test in record tests
tools/perf/arch/x86/util/evlist.c | 11 ++++------ tools/perf/arch/x86/util/topdown.c | 16 ++++++++++++-- tools/perf/tests/shell/record.sh | 28 ++++++++++++++++++++++++ tools/perf/util/evlist.h | 7 +++++- tools/perf/util/parse-events.c | 35 ++++++++++++++++++------------ 5 files changed, 73 insertions(+), 24 deletions(-)
base-commit: 73e931504f8e0d42978bfcda37b323dbbd1afc08
Signature · 1 line
2.40.1