Skip to content

Commit

Permalink
Monitor Windows system-wide timer resolution events
Browse files Browse the repository at this point in the history
UIforETW already monitors the system-wide Windows timer resolution, as
set by timeBeginPeriod and NtSetTimerResolution. However that is based
on sampling, so it misses any short-term changes to the timer frequency,
and it can't tell *who* has raised the timer frequency.

I fortuitously discovered that the Microsoft-Windows-Kernel-Power
provider - undocumented, like most of these - provides events whenever
the timer frequency changes. The timer changes are contained in events
such as SystemTimeResolutionChange and SystemTimeResolutionKernelChange
for changes by normal processes and the kernel respectively.

The new "Randomascii System Time Resolution" preset for the Generic
Events is set up with a filter to show just these events. To configure
this filtering I used the View Editor, Advanced, and the syntax that is
lightly documented here:
  https://msdn.microsoft.com/en-us/windows/hardware/commercialize/test/wpt/wpa-query-syntax
Look at SystemTimeResolutionChange and SystemTimeResolutionKernelChange, and in
 particular at the RequestedResolution field (units are 0.1 microseconds, so
0x2710 == 10,000 = 1 ms).
  • Loading branch information
Bruce Dawson committed Nov 10, 2016
1 parent d361ca9 commit 46d5b17
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
19 changes: 16 additions & 3 deletions UIforETW/UIforETWDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,9 +956,22 @@ void CUIforETWDlg::OnBnClickedStarttracing()

// DWM providers can be helpful also. Uncomment to enable.
//userProviders += L"+Microsoft-Windows-Dwm-Dwm";
// Theoretically better power monitoring data, Windows 7+, but it doesn't
// seem to work.
//userProviders += L"+Microsoft-Windows-Kernel-Processor-Power+Microsoft-Windows-Kernel-Power";

// Monitoring of timer frequency changes from timeBeginPeriod and
// NtSetTimerResolution. Windows 7 and above.
// Like most providers the information provide by this one is undocumented and
// therefore only easily usable by those who created it. However, a bit of
// exploration will find useful information. The timer changes are contained
// in events such as SystemTimeResolutionChange and SystemTimeResolutionKernelChange
// for changes by normal processes and the kernel.
// The "Randomascii System Time Resolution" preset for the Generic Events is set up
// with a filter to show just these events. To configure this filtering I used the
// View Editor, Advanced, and the syntax that is lightly documented here:
// https://msdn.microsoft.com/en-us/windows/hardware/commercialize/test/wpt/wpa-query-syntax
// Look at SystemTimeResolutionChange and SystemTimeResolutionKernelChange, and in
// particular at the RequestedResolution field (units are 0.1 microseconds, so
// 0x2710 == 10,000 = 1 ms).
userProviders += L"+Microsoft-Windows-Kernel-Power";

// If the Chrome providers were successfully registered and if the user has requested tracing
// some of Chrome's categories (keywords/flags) then add chrome:flags to the list of user
Expand Down
35 changes: 35 additions & 0 deletions bin/startup10.wpaProfile
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,41 @@
<Column Guid="bbfc990a-b6c9-4dcd-858b-f040ab4a1efe" Name="Time" SortPriority="30" Width="80" IsVisible="true" />
</Columns>
</Preset>
<Preset Name="Randomascii System Time Resolution" BarGraphIntervalCount="50" IsThreadActivityTable="false" GraphColumnCount="27" KeyColumnCount="9" LeftFrozenColumnCount="8" RightFrozenColumnCount="26" InitialFilterQuery="[Provider Name]:*&quot;Microsoft-WIndows-Kernel-Power&quot; AND [Task Name]:~=&quot;SystemTimeResolution&quot;" InitialFilterShouldKeep="true" GraphFilterTopValue="0" GraphFilterThresholdValue="0">
<MetadataEntries>
<MetadataEntry Guid="edf01e5d-3644-4dbc-ab9d-f8954e6db6ea" Name="ThreadId" ColumnMetadata="EndThreadId" />
<MetadataEntry Guid="bbfc990a-b6c9-4dcd-858b-f040ab4a1efe" Name="Time" ColumnMetadata="StartTime" />
<MetadataEntry Guid="bbfc990a-b6c9-4dcd-858b-f040ab4a1efe" Name="Time" ColumnMetadata="EndTime" />
</MetadataEntries>
<HighlightEntries />
<Columns>
<Column Guid="7ee6a5ff-1faf-428a-a7c2-7d2cb2b5cf26" Name="Process" SortPriority="18" Width="186" IsVisible="false" />
<Column Guid="8b4c40f8-0d99-437d-86ab-56ec200137dc" Name="Provider Name" SortPriority="13" Width="238" IsVisible="true" />
<Column Guid="511777f7-30ef-4e86-bd0b-0facaf23a0d3" Name="Task Name" SortPriority="14" Width="250" IsVisible="true" />
<Column Guid="85d40897-ae0f-4a6b-aea3-b4bcd27c14f7" Name="Process Name" SortPriority="1" Width="150" IsVisible="true" />
<Column Guid="2a23f9b1-65d6-46d2-87b2-72f3606b7f75" Name="Provider Id" SortPriority="19" Width="100" IsVisible="false" />
<Column Guid="5b51716b-b88f-443a-a396-c6316296d5f8" Name="Opcode Name" SortPriority="15" Width="100" IsVisible="false" />
<Column Guid="c72e1c5a-f6db-4c84-8c0b-85989e514075" Name="Id" SortPriority="16" Width="80" IsVisible="false" />
<Column Guid="d446a182-5203-4a29-aca1-4ab9bea0d1b5" Name="Version" SortPriority="2" Width="80" IsVisible="false" />
<Column Guid="cb796d44-2927-5ac1-d231-4b71904c18f5" Name="Thread Name" SortPriority="3" Width="80" IsVisible="false" />
<Column Guid="82ddfdff-ee93-5f35-08ac-4705069618dc" Name="Thread Activity Tag" SortPriority="4" Width="80" IsVisible="false" />
<Column Guid="2818954f-2d30-5569-4510-dade0a5a605c" Name="Annotation" SortPriority="5" Width="80" IsVisible="false" />
<Column Guid="90fe0b49-e3bb-440f-b829-5813c42108a1" Name="Event Name" SortPriority="17" Width="239" IsVisible="false" />
<Column Guid="72892fbe-0f55-426a-9aa1-26b6baf09ffb" Name="Event Type" SortPriority="20" Width="100" IsVisible="false" />
<Column Guid="0734f1a4-fbd9-4ff6-aec0-cf43875c8253" Name="Message" SortPriority="21" Width="100" IsVisible="false" />
<Column Guid="3be8610c-babb-4154-9970-1b2210928024" Name="Cpu" SortPriority="22" Width="45" IsVisible="false" />
<Column Guid="342f7677-17b2-4c7e-b9ec-e89612c49792" Name="Count" AggregationMode="Sum" SortOrder="Descending" SortPriority="0" Width="80" IsVisible="true" />
<Column Guid="edf01e5d-3644-4dbc-ab9d-f8954e6db6ea" Name="ThreadId" SortPriority="23" Width="63" IsVisible="true" />
<Column Guid="0c5cf8cd-9b9e-5798-1a5d-09d429f7fa3c" Name="Field 1" AggregationMode="Average" SortPriority="6" Width="111" IsVisible="true" />
<Column Guid="71badd11-26e5-56bc-44ec-12f4cc6a8f3e" Name="Field 2" AggregationMode="Average" SortPriority="7" Width="80" IsVisible="true" />
<Column Guid="411dba2d-5d6e-5272-8287-636d0841768c" Name="Field 3" AggregationMode="Average" SortPriority="8" Width="80" IsVisible="true" />
<Column Guid="048f5050-1f17-59b3-fa22-4b0781ee630b" Name="Field 4" AggregationMode="Average" SortPriority="9" Width="80" IsVisible="true" />
<Column Guid="94e48f22-d499-5227-bb04-be011b4159b0" Name="Field 5" AggregationMode="Average" SortPriority="10" Width="80" IsVisible="true" />
<Column Guid="c1054028-424a-59ba-e760-6d30abbd69c5" Name="Field 6" AggregationMode="Average" SortPriority="11" Width="80" IsVisible="false" />
<Column Guid="5cbc4b58-2de1-5449-55b2-4651d4edf90a" Name="Field 7" AggregationMode="Average" SortPriority="12" Width="80" IsVisible="false" />
<Column Guid="bbfc990a-b6c9-4dcd-858b-f040ab4a1efe" Name="Time" SortPriority="24" Width="80" IsVisible="true" />
</Columns>
</Preset>
</ModifiedPresets>
<PersistedPresets />
</GraphSchema>
Expand Down

0 comments on commit 46d5b17

Please sign in to comment.