Skip to content

Commit 68ce3f4

Browse files
committed
ARM64 24H2 cycle-based CPU fix
1 parent 6a62653 commit 68ce3f4

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

SystemInformer/procprv.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,19 @@ VOID PhpEstimateIdleCyclesForARM(
20742074
)
20752075
{
20762076
// EXPERIMENTAL (jxy-s)
2077+
//
2078+
// Update (9/29/2024) - 24H2 is now estimating the cycle counts for idle threads in the kernel
2079+
// making this routine obsolete. However, this means that the idle thread cycle counts returned
2080+
// from the kernel is not a reflection of the actual CPU effort of the idle threads. In other
2081+
// words the idle threads now represent the percentage of the CPU *not* being used by other
2082+
// processes, as it does on other architectures. The kernel has also broadly changed the cycle
2083+
// accounting across the entire system to no longer use PMCCNTR_EL0 and instead it uses
2084+
// KeQueryPerformanceCounter. This means it is currently impossible to represent the cycle
2085+
// accounting in a way best suited for the ARM architecture. The kernel appears to have opted
2086+
// for more consistency between architectures instead of accuracy for ARM.
2087+
//
2088+
assert(WindowsVersion < WINDOWS_11_24H2);
2089+
20772090
//
20782091
// The kernel uses PMCCNTR_EL0 for CycleTime in threads and the processor control blocks.
20792092
// Here is a snippet from ntoskrnl!KiIdleLoop:
@@ -2279,7 +2292,7 @@ VOID PhProcessProviderUpdate(
22792292
pidBuckets[bucketIndex] = process;
22802293

22812294
#ifdef _ARM64_ // see: PhpEstimateIdleCyclesForARM (jxy-s)
2282-
if (PhEnableCycleCpuUsage && process->UniqueProcessId != SYSTEM_IDLE_PROCESS_ID)
2295+
if (PhEnableCycleCpuUsage && (WindowsVersion >= WINDOWS_11_24H2 || process->UniqueProcessId != SYSTEM_IDLE_PROCESS_ID))
22832296
#else
22842297
if (PhEnableCycleCpuUsage)
22852298
#endif
@@ -2434,7 +2447,7 @@ VOID PhProcessProviderUpdate(
24342447
}
24352448

24362449
#ifdef _ARM64_
2437-
if (PhEnableCycleCpuUsage)
2450+
if (PhEnableCycleCpuUsage && WindowsVersion < WINDOWS_11_24H2)
24382451
PhpEstimateIdleCyclesForARM(&sysTotalCycleTime, &sysIdleCycleTime);
24392452
#endif
24402453

0 commit comments

Comments
 (0)