Software Tuning, Performance Optimization & Platform Monitoring
Discussion regarding monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform updating.
Announcements
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.

Handling Overflows in Programmable Counters

Ravitheja_G_
Beginner
232 Views

Hi Guys,

I am new to Programmable counters and i need some advice with handling overflows , i wrote a small kernel module to collect stats for each thread running on the cores and it is working well, i need some advice on how i can handle when the counters overflow.

I see that i can Performance Monitoring Interrupts when the overflow happens , it would be helpful if someone can explain how i use these interrupts to reset the counters the counters to zero once they reach a certain value so i can avoid overflows and get accurate readings

Thanks and Regards,
Ravi

0 Kudos
1 Solution
McCalpinJohn
Black Belt
232 Views

The required approach depends on what you are trying to measure. 

If you want measurements by core for any running process, and you can guarantee that the counters cannot increment more than pow(2,48) times between measurements, then you simply disable overflows (by clearing bit 20 in each of the IA32_PERFEVTSEL MSRs) and leave the counters running free.   If a measurement looks smaller than a previous measurement, then add pow(2,48) to the difference to correct for the wrap-around.

View solution in original post

2 Replies
McCalpinJohn
Black Belt
233 Views

The required approach depends on what you are trying to measure. 

If you want measurements by core for any running process, and you can guarantee that the counters cannot increment more than pow(2,48) times between measurements, then you simply disable overflows (by clearing bit 20 in each of the IA32_PERFEVTSEL MSRs) and leave the counters running free.   If a measurement looks smaller than a previous measurement, then add pow(2,48) to the difference to correct for the wrap-around.

Ravitheja_G_
Beginner
232 Views

Thank you , That helps a lot

Reply