Add support for heterogenous cpus to PerfListener #46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issue: sio2project/sinol-make#158.
This is achieved by opening a raw perf event for every cpu core type, quite similiarly to the perf userspace tool.
The values needed to open the proper raw events are gathered from
/sys/devices/cpu*/{type,events/instructions,format/*}
.This solution should work as long as the sysfs interface doesn't drastically change while maintaining compatibility with older kernels, as the mentioned interface seems to be the same as in at least 2014, when there was a failed effort to document the interface as stable.
I tested on:
Alternative approaches that I considered:
config
value for the perf event, as both Intel and AMD seem to use0xc0
for counting instructions at the moment.config
layout for PERF_TYPE_HARDWARE event type (see "INTEL HYBRID SUPPORT" inperf-stat(1)
). This would require some separate logic for handling older kernels which don't support this.I think that using raw perf events based on data from sysfs is more robust than the above methods.