Instruments 15.0.1 on Sonoma 14.1.1 and CORE_ACTIVE_CYCLE kernel always 0

Hi, I have a few traces where I have samples for kernel (and other processes), yet kernel is always 0 for any CPU Counter selected. There are other processes with an equivalent number of samples where the counter values appear.

Perhaps there is a bit of 'art' to get the kernel counters to populate?

I am trying to understand the workload from the system perspective (not simply the narrower process perspective), and it would be helpful to have the counter values. I've tried running for extended durations, yet that doesn't seem to adjust the counted events. I've adjusted to include "High Frequency Sampling" to resolve issues with VMware counter collection. Yet.. I need help to enable counter values to appear for kernel.

Sam

Answered by Systems Engineer in 773121022

You're hitting a limitation of Instruments' focus on user space profiling. CORE_ACTIVE_CYCLE is a configurable event (goes on a configurable counter) and Instruments filters those events to only increment in user space. The kernel doesn't have any threads that run in user space, so its CORE_ACTIVE_CYCLES (and any other configurable counter counts, from other events) are recorded as 0.

To work around this for cycles specifically, you might try using the "Cycles (FIXED_CYCLE)" event instead. That event is hosted on a fixed counter and is not subject to filtering based on kernel vs. user space execution. Note that this cannot be used as a sampling trigger (Instruments calls this "Sample By: Events"), however. And it only works for cycles or instructions; the other configurable events don't have fixed counters available.

It does seem useful for Instruments to allow counting the kernel here, so please file a feedback for that through https://developer.apple.com/bug-reporting/.

What was the VMWare counter collection issue you had to work around with high frequency sampling?

I confirmed kernel_task, PID 0, has %CPU cycles.

Accepted Answer

You're hitting a limitation of Instruments' focus on user space profiling. CORE_ACTIVE_CYCLE is a configurable event (goes on a configurable counter) and Instruments filters those events to only increment in user space. The kernel doesn't have any threads that run in user space, so its CORE_ACTIVE_CYCLES (and any other configurable counter counts, from other events) are recorded as 0.

To work around this for cycles specifically, you might try using the "Cycles (FIXED_CYCLE)" event instead. That event is hosted on a fixed counter and is not subject to filtering based on kernel vs. user space execution. Note that this cannot be used as a sampling trigger (Instruments calls this "Sample By: Events"), however. And it only works for cycles or instructions; the other configurable events don't have fixed counters available.

It does seem useful for Instruments to allow counting the kernel here, so please file a feedback for that through https://developer.apple.com/bug-reporting/.

What was the VMWare counter collection issue you had to work around with high frequency sampling?

My understanding is that VMware's Fusion product doesn't expose host MSRs to enable vPMC, which prevents the guest OSes from running tools to collect the MSRs. Using the system view (with baselines vs load), albeit with some inaccuracies, is an alternative to using a different host OS for VMware. However, I ended up using a different host OS to get vPMC access in the guest.

Thank you for the answer, I apologize for the delay in responding.

Sam

ps, I'll file a bug-report to ask for the kernel/user CORE-ACTIVE-CYCLE feedback, though likely this will be low priority given the IA32 nature of the request.

Instruments 15.0.1 on Sonoma 14.1.1 and CORE_ACTIVE_CYCLE kernel always 0
 
 
Q