Search code examples
kernelperformancecounterinterrupt-handlingsystems-programmingapic

how to generate the Performance monitoring interrupt after every overflow


I want to configure the performance counter IA32_PERF_FIXED_CTR0 to generate performance monitoring interrupt (PMI) after every N retired instructions.

The problem is that although I get the first PMC interrupt, I don’t get any further ones even though I reset the counter to its initial count, clear the overflow flag as it is said in the Intel reference manual.

I did some checks by putting some print after resetting the counter’s value and I verified that this is done correctly and I also verified that the counter continues to count up from the reset value. I also verified that the counter overflows after resetting it but for some reason, there are no interrupt generated.

Can someone let me know how can I generate the interrupt after every N instructions. Any help will be highly appreciated.


Solution

  • Don't forget to clear the interrupt mask bit in the LVT performance counter register; to enable further interrupt. This flag is automatically set to 1 every times the LAPIC handles a performance monitoring interrupt thus blocking any subsequent PMI. Read the intel doc chapter 10 on LAPIC.