libMSR: Power Measurement
Modern processors offer a wide range of control and measurement features. While those are traditionally accessed through libraries like PAPI, some newer features no longer follow the traditional model of counters that can only be used to read the state of the processor. For example, Precise Event Based Sampling (PEBS) can generate records that requires a kernel memory for storage.
Additionally, new features like power capping and thermal control require similar new access methods. All of these features are ultimately controlled through Model Specific Registers (MSRs). We therefore need new mechanisms to make such features available to tools and ultimately to the user. libMSR provides a convenient interface to access MSRs and to allow tools to utilize their full functionality.
In particular, libMSR provides flexible access to MSR registers on x86/64 Linux systems and offers the following features:
- clocks.c—Access to the tsc and other clocks
- turbo.c—Enable/suppress turbo, calculate effective frequency
- pebs.c—Support for PEBS hardware counters, memory latency measurements
- uncore.c—Support for Uncore (unified core, aka package-wide) counters
- counters.c—Access to more traditional performance counters
- rapl.c—Measure and cap package and DRAM power
- cpuid.c—Read and parse hardware capabilities
- thermal.c—Read processor and DRAM temperature
libMSR is currently mainly targeting Intel SandyBridge processors, but we are planning to add support for other (mainly newer) processor generations as well as support for similar features in AMD processors.
libMSR requires user-level access to /dev/cpu/X/msr to read and write MSR registers. While this is often no problem on individual workstations, it is a significant security risk on multi-user systems and large scale compute clusters. The libMSR package therefore provides a matching “safe” version of the “msr” kernel module that allows controlled access to MSRs.