On Jun 18, 2009, at 2:58 AM, Rahulkumar Tibdewal wrote: Is there any way to check memory consumption (kernel address space) and cpu consumption done by kext?
It may sound silly question but I want to make sure efficient resource utilization.
It's not a silly question at all; it's an excellent question and one that deserves some attention.
As Terry notes, it is difficult for the kernel itself to know who is "responsible" for a given allocation, and it's quite impractical to try to work out how much CPU time is being used "by a kext" in the general sense.
There are, however, some ways your kext can help you answer your questions about efficient resource consumption.
The ioclasscount tool will tell you how many instances of your class(es) have been allocated.
If you create a malloc zone for your allocations, you can track the zone statistics with zprint.
You can use the trace facility (kdebug) to emit trace markers, and then use the trace tool to look for and measure these markers. You may also be able to use Instruments to do more intelligent things with them (I have not played with this aspect of Instruments). You can use trace markers for many things - obviously you can emit them when you begin and end work, and measure the distance between them to determine how long your work took. You can emit them when you allocate and free memory, and count the alloc/free pairs to determine how much memory a given unit of work consumes.
You can also use the Shark tool to profile the kernel while your kext is doing work; this can help you narrow down your CPU utilisation even further.
Hopefully the above will point you in some useful directions.
= Mike
-- Excellence in any department can be attained only by the labor of a lifetime; it is not to be purchased at a lesser price -- Samuel Johnson
|