sio2project / sio2jail

A tool for supervising execution of programs submitted in algorithmic competitions
MIT License
29 stars 10 forks source link

Add support for heterogenous cpus to PerfListener #46

Closed A-dead-pixel closed 3 months ago

A-dead-pixel commented 4 months ago

Related issue: https://github.com/sio2project/sinol-make/issues/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:

I think that using raw perf events based on data from sysfs is more robust than the above methods.