Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

711 lines
22 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntperf.h
  5. Abstract:
  6. This module contains the performance event logging definitions.
  7. Author:
  8. Stephen Hsiao (shsiao) 30-March-2000
  9. Revision History:
  10. --*/
  11. #ifndef _NTPERF_
  12. #define _NTPERF_
  13. #include <wmistr.h>
  14. #include <ntwmi.h>
  15. #define PERF_ASSERT(x) ASSERT(x)
  16. #define PERFINFO_ASSERT_PACKET_OVERFLOW(Size) ASSERT ((Size) <= MAXUSHORT)
  17. //
  18. // See ntwmi.w for the definition of Enable flags, hook id's, etc.
  19. //
  20. #define PERF_MASK_INDEX (0xe0000000)
  21. #define PERF_MASK_GROUP (~PERF_MASK_INDEX)
  22. #define PERF_NUM_MASKS 8
  23. typedef ULONG PERFINFO_MASK;
  24. //
  25. // This structure holds a group mask for all the PERF_NUM_MASKS sets
  26. // (see PERF_MASK_INDEX above).
  27. //
  28. typedef struct _PERFINFO_GROUPMASK {
  29. ULONG Masks[PERF_NUM_MASKS];
  30. } PERFINFO_GROUPMASK, *PPERFINFO_GROUPMASK;
  31. #define PERF_GET_MASK_INDEX(GM) (((GM) & PERF_MASK_INDEX) >> 29)
  32. #define PERF_GET_MASK_GROUP(GM) ((GM) & PERF_MASK_GROUP)
  33. #define PERFINFO_CLEAR_GROUPMASK(pGroupMask) \
  34. RtlZeroMemory((pGroupMask), sizeof(PERFINFO_GROUPMASK))
  35. #define PERFINFO_OR_GROUP_WITH_GROUPMASK(Group, pGroupMask) \
  36. (pGroupMask)->Masks[PERF_GET_MASK_INDEX(Group)] |= PERF_GET_MASK_GROUP(Group);
  37. //
  38. // Determines whether any group is on in a group mask
  39. //
  40. #define PerfIsAnyGroupOnInGroupMask(pGroupMask) \
  41. (pGroupMask != NULL)
  42. //
  43. // Determines whether a group is on in its set in a group mask
  44. //
  45. __forceinline
  46. BOOLEAN
  47. PerfIsGroupOnInGroupMask(
  48. ULONG Group,
  49. PPERFINFO_GROUPMASK GroupMask
  50. )
  51. /*++
  52. Routine Description:
  53. Determines whether any group is on in a group mask
  54. Arguments:
  55. Group - Group index to check.
  56. GroupMask - pointer to group mask to check.
  57. Return Value:
  58. Boolean indicating whether it is set or not.
  59. Environment:
  60. User mode.
  61. --*/
  62. {
  63. PPERFINFO_GROUPMASK TestMask = GroupMask;
  64. return (BOOLEAN)(((TestMask) != NULL) && (((TestMask)->Masks[PERF_GET_MASK_INDEX((Group))] & PERF_GET_MASK_GROUP((Group))) != 0));
  65. }
  66. //
  67. // The header is for perf related informations
  68. //
  69. typedef struct _PERF_TRACE_HEADER {
  70. PERFINFO_GROUPMASK GroupMasks;
  71. } PERF_TRACE_HEADER, *PPERF_TRACE_HEADER;
  72. typedef struct _PERFINFO_HOOK_HANDLE {
  73. PPERFINFO_TRACE_HEADER PerfTraceHeader;
  74. PWMI_BUFFER_HEADER WmiBufferHeader;
  75. } PERFINFO_HOOK_HANDLE, *PPERFINFO_HOOK_HANDLE;
  76. #define PERFINFO_HOOK_HANDLE_TO_DATA(_HookHandle, _Type) \
  77. ((_Type) (&((_HookHandle).PerfTraceHeader)->Data[0]))
  78. #define PERFINFO_APPLY_OFFSET_GIVING_TYPE(_Base, _Offset, _Type) \
  79. ((_Type) (((PPERF_BYTE) (_Base)) + (_Offset)))
  80. #define PERFINFO_ROUND_UP( Size, Amount ) (((ULONG)(Size) + ((Amount) - 1)) & ~((Amount) - 1))
  81. //
  82. // Data structures of events
  83. //
  84. typedef unsigned char PERF_BYTE, *PPERF_BYTE;
  85. #define PERFINFO_THREAD_SWAPABLE 0
  86. #define PERFINFO_THREAD_NONSWAPABLE 1
  87. typedef struct _PERFINFO_THREAD_INFORMATION {
  88. PVOID StackBase;
  89. PVOID StackLimit;
  90. PVOID UserStackBase;
  91. PVOID UserStackLimit;
  92. PVOID StartAddr;
  93. PVOID Win32StartAddr;
  94. ULONG ProcessId;
  95. ULONG ThreadId;
  96. char WaitMode;
  97. } PERFINFO_THREAD_INFORMATION, *PPERFINFO_THREAD_INFORMATION;
  98. typedef struct _PERFINFO_DRIVER_MAJORFUNCTION {
  99. ULONG UniqMatchId;
  100. PVOID RoutineAddr;
  101. PVOID Irp;
  102. ULONG MajorFunction;
  103. ULONG MinorFunction;
  104. PVOID FileNamePointer;
  105. } PERFINFO_DRIVER_MAJORFUNCTION, *PPERFINFO_DRIVER_MAJORFUNCTION;
  106. typedef struct _PERFINFO_DRIVER_MAJORFUNCTION_RET {
  107. ULONG UniqMatchId;
  108. PVOID Irp;
  109. } PERFINFO_DRIVER_MAJORFUNCTION_RET, *PPERFINFO_DRIVER_MAJORFUNCTION_RET;
  110. typedef struct _PERFINFO_DRIVER_COMPLETE_REQUEST {
  111. //
  112. // Driver major function routine address for the "current" stack location
  113. // on the IRP when it was completed. It is used to identify which driver
  114. // was processing the IRP when the IRP got completed.
  115. //
  116. PVOID RoutineAddr;
  117. //
  118. // Irp field and UniqMatchId is used to match COMPLETE_REQUEST
  119. // and COMPLETE_REQUEST_RET logged for an IRP completion.
  120. //
  121. PVOID Irp;
  122. ULONG UniqMatchId;
  123. } PERFINFO_DRIVER_COMPLETE_REQUEST, *PPERFINFO_DRIVER_COMPLETE_REQUEST;
  124. typedef struct _PERFINFO_DRIVER_COMPLETE_REQUEST_RET {
  125. //
  126. // Irp field and UniqMatchId is used to match COMPLETE_REQUEST
  127. // and COMPLETE_REQUEST_RET logged for an IRP completion.
  128. //
  129. PVOID Irp;
  130. ULONG UniqMatchId;
  131. } PERFINFO_DRIVER_COMPLETE_REQUEST_RET, *PPERFINFO_DRIVER_COMPLETE_REQUEST_RET;
  132. //
  133. // This structure is logged when PopSetPowerAction is called to start
  134. // propagating a new power action (e.g. standby/hibernate/shutdown)
  135. //
  136. typedef struct _PERFINFO_SET_POWER_ACTION {
  137. //
  138. // This field is used to match SET_POWER_ACTION_RET entry.
  139. //
  140. PVOID Trigger;
  141. ULONG PowerAction;
  142. ULONG LightestState;
  143. } PERFINFO_SET_POWER_ACTION, *PPERFINFO_SET_POWER_ACTION;
  144. //
  145. // This structure is logged when PopSetPowerAction completes.
  146. //
  147. typedef struct _PERFINFO_SET_POWER_ACTION_RET {
  148. PVOID Trigger;
  149. NTSTATUS Status;
  150. } PERFINFO_SET_POWER_ACTION_RET, *PPERFINFO_SET_POWER_ACTION_RET;
  151. //
  152. // This structure is logged when PopSetDevicesSystemState is called to
  153. // propagate a system state to all devices.
  154. //
  155. typedef struct _PERFINFO_SET_DEVICES_STATE {
  156. ULONG SystemState;
  157. BOOLEAN Waking;
  158. BOOLEAN Shutdown;
  159. UCHAR IrpMinor;
  160. } PERFINFO_SET_DEVICES_STATE, *PPERFINFO_SET_DEVICES_STATE;
  161. //
  162. // This structure is logged when PopSetDevicesSystemState is done.
  163. //
  164. typedef struct _PERFINFO_SET_DEVICES_STATE_RET {
  165. NTSTATUS Status;
  166. } PERFINFO_SET_DEVICES_STATE_RET, *PPERFINFO_SET_DEVICES_STATE_RET;
  167. //
  168. // This structure is logged when PopNotifyDevice calls into a driver
  169. // to set the power state of a device.
  170. //
  171. typedef struct _PERFINFO_PO_NOTIFY_DEVICE {
  172. //
  173. // This field is used to match notification and completion log
  174. // entries for a device.
  175. //
  176. PVOID Irp;
  177. //
  178. // Base address of the driver that owns this device.
  179. //
  180. PVOID DriverStart;
  181. //
  182. // Device node properties.
  183. //
  184. UCHAR OrderLevel;
  185. //
  186. // Major and minor IRP codes for the request made to the driver.
  187. //
  188. UCHAR MajorFunction;
  189. UCHAR MinorFunction;
  190. //
  191. // Type of power irp
  192. //
  193. POWER_STATE_TYPE Type;
  194. POWER_STATE State;
  195. //
  196. // Length of the device name in characters excluding terminating NUL,
  197. // and the device name itself. Depending on how much fits into our
  198. // stack buffer, this is the *last* part of the device name.
  199. //
  200. ULONG DeviceNameLength;
  201. WCHAR DeviceName[1];
  202. } PERFINFO_PO_NOTIFY_DEVICE, *PPERFINFO_PO_NOTIFY_DEVICE;
  203. //
  204. // This structure is logged when a PopNotifyDevice processing for a
  205. // particular device completes.
  206. //
  207. typedef struct _PERFINFO_PO_NOTIFY_DEVICE_COMPLETE {
  208. //
  209. // This field is used to match notification and completion log
  210. // entries for a device.
  211. //
  212. PVOID Irp;
  213. //
  214. // Status with which the notify power IRP was completed.
  215. //
  216. NTSTATUS Status;
  217. } PERFINFO_PO_NOTIFY_DEVICE_COMPLETE, *PPERFINFO_PO_NOTIFY_DEVICE_COMPLETE;
  218. //
  219. // This structure is logged around every win32 state callout
  220. //
  221. typedef struct _PERFINFO_PO_SESSION_CALLOUT {
  222. POWER_ACTION SystemAction;
  223. SYSTEM_POWER_STATE MinSystemState;
  224. ULONG Flags;
  225. ULONG PowerStateTask;
  226. } PERFINFO_PO_SESSION_CALLOUT, *PPERFINFO_PO_SESSION_CALLOUT;
  227. typedef struct _PERFINFO_PO_PRESLEEP {
  228. LARGE_INTEGER PerformanceCounter;
  229. LARGE_INTEGER PerformanceFrequency;
  230. } PERFINFO_PO_PRESLEEP, *PPERFINFO_PO_PRESLEEP;
  231. typedef struct _PERFINFO_PO_POSTSLEEP {
  232. LARGE_INTEGER PerformanceCounter;
  233. } PERFINFO_PO_POSTSLEEP, *PPERFINFO_PO_POSTSLEEP;
  234. typedef struct _PERFINFO_BOOT_PHASE_START {
  235. LONG Phase;
  236. } PERFINFO_BOOT_PHASE_START, *PPERFINFO_BOOT_PHASE_START;
  237. typedef struct _PERFINFO_BOOT_PREFETCH_INFORMATION {
  238. LONG Action;
  239. NTSTATUS Status;
  240. LONG Pages;
  241. } PERFINFO_BOOT_PREFETCH_INFORMATION, *PPERFINFO_BOOT_PREFETCH_INFORMATION;
  242. typedef struct _PERFINFO_PO_SESSION_CALLOUT_RET {
  243. NTSTATUS Status;
  244. } PERFINFO_PO_SESSION_CALLOUT_RET, *PPERFINFO_PO_SESSION_CALLOUT_RET;
  245. typedef struct _PERFINFO_FILENAME_INFORMATION {
  246. PVOID HashKeyFileNamePointer;
  247. WCHAR FileName[1];
  248. } PERFINFO_FILENAME_INFORMATION, *PPERFINFO_FILENAME_INFORMATION;
  249. typedef struct _PERFINFO_SAMPLED_PROFILE_INFORMATION {
  250. PVOID InstructionPointer;
  251. ULONG ThreadId;
  252. ULONG Count;
  253. } PERFINFO_SAMPLED_PROFILE_INFORMATION, *PPERFINFO_SAMPLED_PROFILE_INFORMATION;
  254. #define PERFINFO_SAMPLED_PROFILE_CACHE_MAX 20
  255. typedef struct _PERFINFO_SAMPLED_PROFILE_CACHE {
  256. ULONG Entries;
  257. PERFINFO_SAMPLED_PROFILE_INFORMATION Sample[PERFINFO_SAMPLED_PROFILE_CACHE_MAX];
  258. } PERFINFO_SAMPLED_PROFILE_CACHE, *PPERFINFO_SAMPLED_PROFILE_CACHE;
  259. typedef struct _PERFINFO_DPC_INFORMATION {
  260. ULONGLONG InitialTime;
  261. PVOID DpcRoutine;
  262. } PERFINFO_DPC_INFORMATION, *PPERFINFO_DPC_INFORMATION;
  263. typedef struct _PERFINFO_INTERRUPT_INFORMATION {
  264. ULONGLONG InitialTime;
  265. PVOID ServiceRoutine;
  266. ULONG ReturnValue;
  267. } PERFINFO_INTERRUPT_INFORMATION, *PPERFINFO_INTERRUPT_INFORMATION;
  268. typedef struct _PERFINFO_PFN_INFORMATION {
  269. ULONG_PTR PageFrameIndex;
  270. } PERFINFO_PFN_INFORMATION, *PPERFINFO_PFN_INFORMATION;
  271. typedef struct _PERFINFO_SWAPPROCESS_INFORMATION {
  272. ULONG_PTR PageDirectoryBase;
  273. ULONG ProcessId;
  274. } PERFINFO_SWAPPROCESS_INFORMATION, *PPERFINFO_SWAPPROCESS_INFORMATION;
  275. typedef struct _PERFINFO_HARDPAGEFAULT_INFORMATION {
  276. LARGE_INTEGER ReadOffset;
  277. LARGE_INTEGER IoTime;
  278. PVOID VirtualAddress;
  279. PVOID FileObject;
  280. ULONG ThreadId;
  281. ULONG ByteCount;
  282. } PERFINFO_HARDPAGEFAULT_INFORMATION, *PPERFINFO_HARDPAGEFAULT_INFORMATION;
  283. typedef struct _PERFINFO_TRIMPROCESS_INFORMATION {
  284. ULONG ProcessId;
  285. ULONG ProcessWorkingSet;
  286. ULONG ProcessPageFaultCount;
  287. ULONG ProcessLastPageFaultCount;
  288. ULONG ActualTrim;
  289. } PERFINFO_TRIMPROCESS_INFORMATION, *PPERFINFO_TRIMPROCESS_INFORMATION;
  290. typedef struct _PERFINFO_WS_INFORMATION {
  291. ULONG ProcessId;
  292. ULONG ProcessWorkingSet;
  293. ULONG ProcessPageFaultCount;
  294. ULONG ProcessClaim;
  295. ULONG ProcessEstimatedAvailable;
  296. ULONG ProcessEstimatedAccessed;
  297. ULONG ProcessEstimatedShared;
  298. ULONG ProcessEstimatedModified;
  299. } PERFINFO_WS_INFORMATION, *PPERFINFO_WS_INFORMATION;
  300. //
  301. // Fault based working set actions.
  302. //
  303. #define PERFINFO_WS_ACTION_RESET_COUNTER 1
  304. #define PERFINFO_WS_ACTION_NOTHING 2
  305. #define PERFINFO_WS_ACTION_INCREMENT_COUNTER 3
  306. #define PERFINFO_WS_ACTION_WILL_TRIM 4
  307. #define PERFINFO_WS_ACTION_FORCE_TRIMMING_PROCESS 5
  308. #define PERFINFO_WS_ACTION_WAIT_FOR_WRITER 6
  309. #define PERFINFO_WS_ACTION_EXAMINED_ALL_PROCESS 7
  310. #define PERFINFO_WS_ACTION_AMPLE_PAGES_EXIST 8
  311. #define PERFINFO_WS_ACTION_END_WALK_ENTRIES 9
  312. //
  313. // Claim based working set actions.
  314. //
  315. #define PERFINFO_WS_ACTION_ADJUST_CLAIM_PARAMETER 10
  316. #define PERFINFO_WS_ACTION_CLAIMBASED_TRIM 11
  317. #define PERFINFO_WS_ACTION_FORCE_TRIMMING_CLAIM 12
  318. #define PERFINFO_WS_ACTION_GOAL_REACHED 13
  319. #define PERFINFO_WS_ACTION_MAX_PASSES 14
  320. #define PERFINFO_WS_ACTION_WAIT_FOR_WRITER_CLAIM 15
  321. //
  322. // New
  323. //
  324. #define PERFINFO_WS_ACTION_CLAIM_STATE 16
  325. #define PERFINFO_WS_ACTION_FAULT_STATE 17
  326. #define PERFINFO_WS_ACTION_CLAIM_WS 18
  327. #define PERFINFO_WS_ACTION_FAULT_WS 19
  328. typedef struct _PERFINFO_WORKINGSETMANAGER_INFORMATION {
  329. ULONG Action;
  330. ULONG_PTR Available;
  331. ULONG_PTR DesiredFreeGoal;
  332. ULONG PageFaultCount;
  333. ULONG ZFODFaultCount;
  334. union {
  335. struct {
  336. ULONG_PTR DesiredReductionGoal;
  337. ULONG LastPageFaultCount;
  338. ULONG CheckCounter;
  339. } Fault;
  340. struct {
  341. ULONG_PTR TotalClaim;
  342. ULONG_PTR TotalEstimatedAvailable;
  343. ULONG AgeEstimationShift;
  344. ULONG PlentyFreePages;
  345. BOOLEAN Replacing;
  346. } Claim;
  347. };
  348. } PERFINFO_WORKINGSETMANAGER_INFORMATION, *PPERFINFO_WORKINGSETMANAGER_INFORMATION;
  349. #ifdef NTPERF
  350. /*++
  351. This code uses the BBTBuffer memory reserved at boot time
  352. (/PERFMEM=xxx) and removed from MM's memory size
  353. calculations as a memory buffer for trace event logging.
  354. If this memory is allocated and not in use by another logger
  355. such as kernel icecap, then both both WMI and PerfInfo
  356. trace events will be logged to it.
  357. The buffer is mapped in to both kernel and usermode as writable
  358. memory (the reasons this is under ifdef and will not be
  359. shipped in a retail kernel).
  360. Layout of Perfinfo trace buffer:
  361. PerfBufHdr() ----->+------------------------------------+
  362. | PERFINFO_TRACEBUF_HEADER structure |
  363. PerfBufHdr() + ----->+------------------------------------+
  364. sizeof( | Header Zone: |
  365. PERFINFO_TRACEBUF_HEADER) | Thread Hash |
  366. | |
  367. | |
  368. PerfStartPtr() == ----->+------------------------------------+
  369. PerfBufHdr() + | Trace events |
  370. PerfBufHeaderZoneSize | . Processes created |
  371. | . Pages faulted |
  372. | . Pages removed |
  373. | . Sections created |
  374. | . Drivers loaded |
  375. | . etc. etc... |
  376. | |
  377. PerfMaxPtr() ----->+------------------------------------+
  378. Information neccessary to allocate a trace event and post
  379. process the log is contained in the header.
  380. Trace events are WMI trace events.
  381. --*/
  382. typedef enum _PERFORMANCE_INFORMATION_CLASS {
  383. PerformanceMmInfoInformation,
  384. PerfICReserved1,
  385. PerformancePerfInfoStart,
  386. PerformancePerfInfoStop,
  387. PerfICReserved2,
  388. PerformanceMmInfoMarkWithFlush,
  389. PerformanceMmInfoMark,
  390. PerformanceMmInfoAsyncMark,
  391. PerfICReserved3,
  392. PerfICReserved4,
  393. PerformanceMmInfoFlush,
  394. PerformanceMmInfoBigFootOn,
  395. PerformanceMmInfoBigFootOff,
  396. PerformanceMmInfoDriverRangeSet,
  397. PerfICReserved5,
  398. PerfICReserved6,
  399. PerformanceMmInfoDriverDelaySet,
  400. PerformanceShutdownDumpInfo,
  401. PerformanceMmInfoDriverRangeReset,
  402. PerfICReserved7,
  403. PerfICReserved8,
  404. PerformanceBranchTracingBreakpoints
  405. } PERFORMANCE_INFORMATION_CLASS;
  406. //
  407. // Breakpoint info for instruction tracing
  408. //
  409. #define PERFINFO_MAX_BREAKPOINTS 4
  410. typedef struct _PERFINFO_BREAKPOINT_ADDRESS {
  411. int nAddresses;
  412. LONG Action[PERFINFO_MAX_BREAKPOINTS];
  413. PVOID Addresses[PERFINFO_MAX_BREAKPOINTS];
  414. } PERFINFO_BREAKPOINT_ADDRESS, *PPERFINFO_BREAKPOINT_ADDRESS;
  415. //
  416. // Used for the SetSystemInformation interface
  417. //
  418. typedef struct _PERFINFO_PERFORMANCE_INFORMATION {
  419. PERFORMANCE_INFORMATION_CLASS PerformanceType;
  420. union {
  421. struct {
  422. PERFINFO_GROUPMASK Flags;
  423. } StartInfo;
  424. ULONG BigFootSize;
  425. ULONG TracingOn;
  426. struct {
  427. BOOLEAN DumpOnShutDown;
  428. BOOLEAN DumpOnHibernate;
  429. } ShutdownDumpInfo;
  430. PERFINFO_BREAKPOINT_ADDRESS BreakPointAddress;
  431. };
  432. } PERFINFO_PERFORMANCE_INFORMATION, *PPERFINFO_PERFORMANCE_INFORMATION;
  433. //
  434. // This allows us to keep our bearings when our time
  435. // is reset or modified in hibernate or standby etc.
  436. //
  437. typedef struct _PERFINFO_RESUME_CLOCK_REFERENCE {
  438. PERFINFO_TIMESTAMP TickCount;
  439. LARGE_INTEGER SystemTime;
  440. } PERFINFO_RESUME_CLOCK_REFERENCE, *PPERFINFO_RESUME_CLOCK_REFERENCE;
  441. //
  442. // For private loggers which need per thread info.
  443. //
  444. #define PERFINFO_INVALID_ID -1
  445. typedef struct _PERFINFO_THREAD_HASH_ENTRY {
  446. //
  447. // These fields are used by Modbound
  448. //
  449. ULONG Start;
  450. ULONG End;
  451. ULONG Count;
  452. // Used internally by the hash table. Current thread assigned to this
  453. // node.
  454. LONG CurThread;
  455. //
  456. // These fields are used for Kernel mode stack dump
  457. //
  458. ULONG DumpStackRunning;
  459. PERFINFO_TIMESTAMP LastContextSwitchTime;
  460. } PERFINFO_THREAD_HASH_ENTRY, *PPERFINFO_THREAD_HASH_ENTRY;
  461. #define PERFINFO_MAX_LOGGER_NAME_LENGTH 80
  462. #define PERFINFO_MAJOR_VERSION 34
  463. #define PERFINFO_MINOR_VERSION 0
  464. //
  465. // What timing format is used in the trace
  466. //
  467. #define FLAG_SYSTEM_TIME 0x00000001
  468. #define FLAG_PERF_COUNTER 0x00000002
  469. #define FLAG_CYCLE_COUNT 0x00000004
  470. #define FLAG_WMI_TRACE 0x80000000
  471. //
  472. // Define event header type
  473. //
  474. #ifdef _WIN64
  475. #define TRACE_HEADER_TYPE_SYSTEM TRACE_HEADER_TYPE_SYSTEM64
  476. #define TRACE_HEADER_TYPE_PERFINFO TRACE_HEADER_TYPE_PERFINFO64
  477. #else
  478. #define TRACE_HEADER_TYPE_SYSTEM TRACE_HEADER_TYPE_SYSTEM32
  479. #define TRACE_HEADER_TYPE_PERFINFO TRACE_HEADER_TYPE_PERFINFO32
  480. #endif
  481. //
  482. // Add new fields to the header first by replacing reserved, fields
  483. // and then by adding to the end.
  484. //
  485. typedef struct _PERFINFO_TRACEBUF_HEADER {
  486. ULONG PagesReserved;
  487. USHORT usMajorVersion; // Bump if the header or existing hooks have changed.
  488. USHORT usMinorVersion; // Bump if hooks are added.
  489. BOOLEAN fVersionMismatch; // Set if a logger has a version mismatch
  490. char szBadVersionComponentName[PERFINFO_MAX_LOGGER_NAME_LENGTH];
  491. ULONG PerfBufHeaderZoneSize; // Size of header zone in bytes
  492. LONGLONG KePerfFrequency;
  493. union { // Pointers for the beginning, current log
  494. PPERF_BYTE Ptr; // log pointer, and end of the buffer.
  495. UINT_PTR Offset; // Ptr is used when logging.
  496. } Start, Current, Max; // Offset when post processing a binary file.
  497. ULONGLONG PerfInitTime; // Time when buffer inited
  498. ULONG LoggerCounts;
  499. PPERF_BYTE pCOWHeader; // Location of currently active COWHeader.
  500. // NULL if no COWHeader is allocated.
  501. ULONGLONG CalcPerfFrequency; // Calculated machine frequency
  502. ULONGLONG BufferBytesLost; // in bytes
  503. ULONGLONG PerfGlobalMaskLastSetTime;
  504. PPERFINFO_THREAD_HASH_ENTRY ThreadHash;
  505. // Per-thread logging state info
  506. ULONG Reserved2;
  507. ULONG ThreadHashOverflow; // TRUE if thread table filled during
  508. // the trace.
  509. LARGE_INTEGER PerfInitSystemTime; // SystemTime when logging was turned on.
  510. LARGE_INTEGER Reserved11;
  511. ULONG Reserved3;
  512. ULONG Reserved4;
  513. PVOID MmSystemRangeStart; // System Address Range Starts here
  514. ULONG Reserved5;
  515. ULONG TracePid; // Indicates that modbound should only log calls
  516. // within one process (default is 0 for all
  517. // processes).
  518. ULONG Reserved7;
  519. ULONG Reserved8; // byte count of timestamp
  520. PERFINFO_TIMESTAMP GetStack_CSwitchDelta;
  521. PERFINFO_TIMESTAMP GetStack_DrvDelayDelta;
  522. // Used for driver delay hooks.
  523. PERFINFO_GROUPMASK GlobalGroupMask;
  524. ULONGLONG EventPerfFrequency; // Timestamp quantum for events
  525. struct _PERFINFO_TRACEBUF_HEADER *SelfPointer;
  526. // Used to rebase the buffer when post processing
  527. ULONG Reserved9;
  528. ULONG BufferFlag;
  529. PERFINFO_TIMESTAMP LogStopTime; // Set when logging stopped
  530. //
  531. // LastClockRef is set to the last clock reference logged by
  532. // PerfkLogCurrentSystemTimeAndClock. This is so we can adjust the
  533. // buffer end timestamp (in case the clock was reset during
  534. // tracing) without heving to go through the whole buffer.
  535. //
  536. PERFINFO_RESUME_CLOCK_REFERENCE LastClockRef;
  537. ULONG TraceBufferSize;
  538. PWMI_BUFFER_HEADER UserModePerCpuBuffer[MAXIMUM_PROCESSORS];
  539. //Per CPU Buffer for user mode logging
  540. } PERFINFO_TRACEBUF_HEADER, *PPERFINFO_TRACEBUF_HEADER;
  541. typedef struct _PERFINFO_MARK_INFORMATION {
  542. char Name[1];
  543. } PERFINFO_MARK_INFORMATION, *PPERFINFO_MARK_INFORMATION;
  544. //
  545. // This means 16K is the size of our thread hash table ... currently this
  546. // takes up about 1/2MB.
  547. //
  548. #define PERFINFO_THREAD_HASH_SIZE 0x4000
  549. #define PERFINFO_THREAD_HASH_MASK 0x3FFF
  550. #define PERFINFO_HEADER_ZONE_SIZE \
  551. ALIGN_TO_POWER2((sizeof(PERFINFO_TRACEBUF_HEADER) + \
  552. (PERFINFO_THREAD_HASH_SIZE * sizeof(PERFINFO_THREAD_HASH_ENTRY))), \
  553. PAGE_SIZE)
  554. //
  555. // Instruction tracing
  556. //
  557. #define PERFINFO_BRANCH_ESCAPE -128
  558. //
  559. // Structure to hold cached branches.
  560. // We have a Used member because PerkLogBytes pads and aligns
  561. // data.
  562. //
  563. typedef struct _PERFINFO_EXCEPTION_BRANCH_CACHE {
  564. USHORT Used;
  565. PERF_BYTE Data[1];
  566. } PERFINFO_EXCEPTION_BRANCH_CACHE, *PPERFINFO_EXCEPTION_BRANCH_CACHE;
  567. #endif // NTPERF
  568. #endif // _NTPERF_