Software Tuning, Performance Optimization & Platform Monitoring
Discussion regarding monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform updating.

The sample code for capping power consumption by RAPL interface/driver

Kevin
Beginner
1,279 Views

Hi,

I am trying to use RAPL for capping the power consumption but couldn't find any sample codes to do that. Codes from google/this forum are just using RAPL for measuring power/energy. Could anyone give me an example/demo code how to use RAPL for capping the power consumption of CPU? 

Thanks,

Kevin

0 Kudos
1 Reply
sbhal1
New Contributor I
1,279 Views

Power capping on intel processors is all about writing correct values into a Model Specific Resistor (MSR).

A very nice article on how to read and write MSRs can be found at http://www.mindfruit.co.uk/2012/11/a-linux-kernel-module-for.html

Next, the MSR addresses and the associated explanation can be found in section 14.9 (Chapter 14) of Software Developer Manual (vol 3b part 2) of Haswell. It also has the explanation for how to convert Watt value to bits and also the time interval in bits.

The other easy way is to install the intel_rapl kernel module available at https://github.com/torvalds/linux/blob/master/drivers/powercap/intel_rapl.c. With this you can set power cap in watts for different domains.

Hope this helps.

 

0 Kudos
Reply