Skip to content

Commit

Permalink
Add CallNtPowerInformation explanation
Browse files Browse the repository at this point in the history
CallNtPowerInformation doesn't return a meaningful CurrentMHz on recent
versions of Windows - explain why.
  • Loading branch information
randomascii committed Jun 21, 2023
1 parent c5c14ff commit 955c771
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions UIforETW/CPUFrequency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ void CCPUFrequencyMonitor::Sample()
const DWORD actualNumberCPUs = systemInfo.dwNumberOfProcessors;

// Ask Windows what frequency it thinks the CPUs are running at.
// Note that PROCESSOR_POWER_INFORMATION.CurrentMhz no longer shows current
// MHz as of Windows 10 21H1 (19043). This is due to changes in how the CPU
// and OS coordinate to choose CPU frequencies. See this tweet for details:
// https://twitter.com/BruceDawson0xB/status/1453453602949722116
std::vector<PROCESSOR_POWER_INFORMATION> processorInfo(actualNumberCPUs);
const NTSTATUS powerStatus = CallNtPowerInformation(ProcessorInformation, nullptr,
0, &processorInfo[0],
Expand Down

0 comments on commit 955c771

Please sign in to comment.