Skip to content

Commit

Permalink
Merge 'linux_perf_event: exclude_idle only on x86_64' from Benny Halevy
Browse files Browse the repository at this point in the history
Commit 93f19d3
added `exclude_idle = 1` to `linux_perf_event`.
However, as reported in
scylladb/scylladb#19227 (comment), `exclude_idle` is not supported on ARM platforms.

This change sets `exclude_idle` only on known-to-work architectures
(presently, it's only x86_64), assuming it is initialized to 0 as all
other unset bitfields in `perf_event_attr`.

Fixes #2298

Closes #2295

* github.com:scylladb/seastar:
  linux_perf_event: exclude_idle only on x86_64
  linux_perf_event: add make_linux_perf_event
  • Loading branch information
avikivity committed Jul 4, 2024
2 parents 4390d31 + 041523e commit 7c53043
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions tests/perf/linux_perf_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,29 @@ linux_perf_event::disable() {
::ioctl(_fd, PERF_EVENT_IOC_DISABLE, 0);
}

linux_perf_event
linux_perf_event::user_instructions_retired() {
static linux_perf_event
make_linux_perf_event(unsigned config, pid_t pid = 0, int cpu = -1, int group_fd = -1, unsigned long flags = 0) {
return linux_perf_event(perf_event_attr{
.type = PERF_TYPE_HARDWARE,
.size = sizeof(struct perf_event_attr),
.config = PERF_COUNT_HW_INSTRUCTIONS,
.config = config,
.disabled = 1,
.exclude_kernel = 1,
.exclude_hv = 1,
#if defined(__x86_64__)
// exclude_idle is not supported on all architectures (e.g. aarch64)
// so enable it selectively only on architectures that support it.
.exclude_idle = 1,
}, 0, -1, -1, 0);
#endif
}, pid, cpu, group_fd, flags);
}

linux_perf_event
linux_perf_event::user_instructions_retired() {
return make_linux_perf_event(PERF_COUNT_HW_INSTRUCTIONS);
}

linux_perf_event
linux_perf_event::user_cpu_cycles_retired() {
return linux_perf_event(perf_event_attr{
.type = PERF_TYPE_HARDWARE,
.size = sizeof(struct perf_event_attr),
.config = PERF_COUNT_HW_CPU_CYCLES,
.disabled = 1,
.exclude_kernel = 1,
.exclude_hv = 1,
.exclude_idle = 1,
}, 0, -1, -1, 0);
return make_linux_perf_event(PERF_COUNT_HW_CPU_CYCLES);
}

0 comments on commit 7c53043

Please sign in to comment.