Performance counters in kernel-mode drivers

Hi,

I want to implement some performance counters in a kernel-mode driver, so that some parameters can be monitored with the standard performance monitor.
However, it is not clear which technology to use for this: WMI, Performance Counters, …
According to the MSDN documentation, WMI performance counters are no longer supported in Vista; they direct to the Performance Counters 6.0 library. However, the latter is using manifests as from Vista on (not sure if this works on XP as well; also, not sure if this works for drivers).

The performance counters I want to implement must run on XP (32- and 64-bit) and later OS’s. I suppose I have to implement 1 or more IOCTLs to support counter gathering and a (user-mode) DLL to retrieve these counters.

Any help, or sample code, would be greatly appreciated.

Kurt

Where is this in the WDK documentation? I just checked and did not see it
in the installable documentation, and the MSDN online stuff is crap. I am
not saying it is there, but would really like to know.

In one sense Microsoft never supported performance counters in WMI. For
years they had this wonky procedure that if your drivers performance
counters did not appear in perfmon, you needed to stop and start services,
reboot and do other things until they showed up (this was one of those
repeat until working type of models), not something you could tell a
commercial customer to go do on a large server.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

wrote in message news:xxxxx@ntdev…
> Hi,
>
> I want to implement some performance counters in a kernel-mode driver, so
> that some parameters can be monitored with the standard performance
> monitor.
> However, it is not clear which technology to use for this: WMI,
> Performance Counters, …
> According to the MSDN documentation, WMI performance counters are no
> longer supported in Vista; they direct to the Performance Counters 6.0
> library. However, the latter is using manifests as from Vista on (not sure
> if this works on XP as well; also, not sure if this works for drivers).
>
> The performance counters I want to implement must run on XP (32- and
> 64-bit) and later OS’s. I suppose I have to implement 1 or more IOCTLs to
> support counter gathering and a (user-mode) DLL to retrieve these
> counters.
>
> Any help, or sample code, would be greatly appreciated.
>
> Kurt
>

Well Don,

I can provide you with an (alas an online) link to the MSDN: http://msdn2.microsoft.com/en-us/library/aa392296.aspx
Also the following URL indicates WMI as a possible provider: http://msdn2.microsoft.com/en-us/library/aa371643.aspx
I also consulted the book Developing Drivers with the WDF. The latter only mentions WMI, but nothing about performance counters.

According the first link, we should not use WMI anymore, but instead PerfCounter v. 6.0 (sic!).
The second link, refers to the perf counters lib.
Browsing through the WDK examples, revealed WMI examples, but no perf counters samples.

So, what is the best (=read future proof) API to implement perf counters? Also, are there any best practices/examples for kernel mode drivers?

The perf counter interface in user mode has not changed all that much (for instance, you could run the NT4 version of perfmon.exe on vista and it can find all of the vista counters). With that in mind for future proofing a solution, a UM DLL which exposes the perf counter and then uses an IOCTL or WMI to slurp the data is the best solution IMO.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@barco.com
Sent: Friday, October 12, 2007 6:08 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Performance counters in kernel-mode drivers

Well Don,

I can provide you with an (alas an online) link to the MSDN: http://msdn2.microsoft.com/en-us/library/aa392296.aspx
Also the following URL indicates WMI as a possible provider: http://msdn2.microsoft.com/en-us/library/aa371643.aspx
I also consulted the book Developing Drivers with the WDF. The latter only mentions WMI, but nothing about performance counters.

According the first link, we should not use WMI anymore, but instead PerfCounter v. 6.0 (sic!).
The second link, refers to the perf counters lib.
Browsing through the WDK examples, revealed WMI examples, but no perf counters samples.

So, what is the best (=read future proof) API to implement perf counters? Also, are there any best practices/examples for kernel mode drivers?


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thank you Doron.
Is there any information on the performance impact of perfmon on the driver?
Should I handle the IOCTLs in a separate (low-priority) thread annex queue?
Or can the driver directly fill in the data in a user/DLL-supplied buffer (so, circumventing any IOCTL call)?