}
static void
-kpc_sample_kperf_x86(uint32_t ctr, uint64_t count, uint64_t config)
+kpc_sample_kperf_x86(uint32_t ctr, uint32_t actionid, uint64_t count,
+ uint64_t config)
{
- uint32_t actionid = FIXED_ACTIONID(ctr);
bool kernel = false;
uintptr_t pc = get_interrupted_pc(&kernel);
kperf_kpc_flags_t flags = kernel ? KPC_KERNEL_PC : 0;
FIXED_SHADOW(ctr)
+= (kpc_fixed_max() - FIXED_RELOAD(ctr) + 1 /* Wrap */) + extra;
- BUF_INFO(PERF_KPC_FCOUNTER, ctr, FIXED_SHADOW(ctr), extra, FIXED_ACTIONID(ctr));
+ uint32_t actionid = FIXED_ACTIONID(ctr);
+ BUF_INFO(PERF_KPC_FCOUNTER, ctr, FIXED_SHADOW(ctr), extra, actionid);
- if (FIXED_ACTIONID(ctr)) {
- kpc_sample_kperf_x86(ctr, FIXED_SHADOW(ctr) + extra, 0);
+ if (actionid != 0) {
+ kpc_sample_kperf_x86(ctr, actionid, FIXED_SHADOW(ctr) + extra, 0);
}
}
}
-#endif
+#endif // FIXED_COUNTER_SHADOW
for (ctr = 0; ctr < kpc_configurable_count(); ctr++) {
if ((1ULL << ctr) & status) {
* bits are in the correct state before the call to kperf_sample */
wrmsr64(MSR_IA32_PERF_GLOBAL_OVF_CTRL, 1ull << ctr);
- BUF_INFO(PERF_KPC_COUNTER, ctr, CONFIGURABLE_SHADOW(ctr), extra, CONFIGURABLE_ACTIONID(ctr));
+ unsigned int actionid = CONFIGURABLE_ACTIONID(ctr);
+ BUF_INFO(PERF_KPC_COUNTER, ctr, CONFIGURABLE_SHADOW(ctr), extra, actionid);
- if (CONFIGURABLE_ACTIONID(ctr)) {
+ if (actionid != 0) {
uint64_t config = IA32_PERFEVTSELx(ctr);
- kpc_sample_kperf_x86(ctr + kpc_configurable_count(),
+ kpc_sample_kperf_x86(ctr + kpc_fixed_count(), actionid,
CONFIGURABLE_SHADOW(ctr) + extra, config);
}
}