I'm novice on using PEBS facility and I am trying to use "long latency loads" facility and want to dump "raw PEBS records" for further analysis.
For writing a simple example, I referenced SDM v3, especially on 220.127.116.11 through 18.104.22.168 (for Sandy Bridge).
When testing, counting long latency loads counter normally works, but PEBS recording does not correctly works.
In the test, I fount that PMCx reset value for adjusting sampling rate does not correctly working, specifically it does not overflow at all for too low counts.
According to SDM v3, it needs to trigger overflow to "arm PEBS facility" and to set "PEBS Counter X Reset" for triggering PEBS counters repeatedly.
However, even with set of "PEBS Counter X Reset" in high value (0xFFFFFFFFFF00 in my case), PMCx does not appear to correctly set as preset value in Debug Store Area (0x40H ~ 0x58H), even after first overflow of PMCx.
I was trying to find simple examples on this, but it is hard to find the example that includes entire process.
Are there any problems on my approach? Or, is there further process to set PEBS records sampling rate?
Here is summarized my approach
1. Setting "PEBS_ENABLE" as 0
2. Allocation of "debug store area" and set initial values (PEBS Buffer Base, Index, max, threshold, Counter X reset)
3. Writing "debug store area" address to IA32_DS_AREA MSR
4. Setting "IA32_PERF_GLOBAL_CTRL" and "IA32_PEBS_ENABLE" as 0
5. Setting "MEM_TRANS_REITRED" event in "IA32_PERFEVTSEL" MSR and target latency in "PEBS_LD_LAT" MSR
6. Setting "IA32_PERF_GLOBAL_CTRL" MSR as 0x1 and "IA32_PEBS_ENABLE" as 0x0000000100000001 (I used only PMC0 counter)
I tried this on Ivy Bridge-EP based (Intel Xeon E5-2640 v2) platform and linux 3.13.0
I'm not too familar with enabling PEBS so I can't really say if you are setting it up exactly right.
But I wonder if you are setting the threshold so low that you basically measuring your attempts at measuring. I doubt that a PEBS measurement takes 0 cycles. Do you get correct results if you set the threshold higher? And at what threshold do things start to fail? About how many cycles between each measurement when it works and when it fails?