Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to software cpu-clock-ticks if cpu-cycles is not supported #2816

Closed
wants to merge 2 commits into from

Conversation

Hi-Angel
Copy link
Contributor

@Hi-Angel Hi-Angel commented Feb 20, 2021

Some machines, mainly VMs, may lack hardware support for cpu-cycles counter. However, it is no reason not to support them: there may be a similar software event available: PERF_COUNT_SW_CPU_CLOCK.

The idea is taken from the kernel-provided perf utility, function evsel__fallback at evsel.c file.

Fixes: #2815, #1753

Note: although #1753 is closed, but it has same underlying problem as 2815, so I think it's fair to say this PR fixes both of issues.

Another thing worth noting: I said at this comment that I couldn't test it because I stumbled upon an irrelevant problem. That problem I still have, but it is clearly a separate issue. To test that my changes work as expected I simply hardcoded them in place of the hw events, and ran rr record echo hey with rr replay on my laptop. No problems were experienced.

In the next commit it will be used in one more place, so deduplicate the
code

Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
Some machines, mainly VMs, may lack hardware support for cpu-cycles
counter. However, it is no reason not to support them: there may be a
similar software event available: PERF_COUNT_SW_CPU_CLOCK.

The idea is taken from the kernel-provided `perf` utility, function
`evsel__fallback` at evsel.c file.

Fixes: rr-debugger#2815,
       rr-debugger#1753

Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
@Hi-Angel
Copy link
Contributor Author

upd: fixed a commit title

@rocallahan
Copy link
Collaborator

We don't want to do this. rr can't work without working hardware performance counters, and if the cycle counter doesn't work, the retired-conditional-branches counter inevitably won't work either.

@rocallahan rocallahan closed this Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to open performance counter with 'perf_event_open'
2 participants