Obtaining l2 misses and cpu utilization in a module

Joseph Koshy joseph.koshy at gmail.com
Wed Feb 18 19:07:49 PST 2009


> I would like to obtain fore mentioned data from within my module. I need
> these performance metrics to see how certain code executes, and make
> decisions during the runtime. pmc(3) seems complete, but it also seems to be
> intended for use in the userland.
>
> How to use pmc from modules? Is there any other way? Also, module is amd64
> only, so I don't care about portability.

At this point of time there isn't an in-kernel API for using hwpmc(4)
(but it is on the task list, see:
http://code.google.com/p/pmctools/issues/detail?id=17).

For now, you could configure hwpmc(4) to not touch specific PMC
registers using the OP_PMCADMIN request (i.e., use pmccontrol -d).
After this you can use those registers from your kernel module without
interference from hwpmc.

Koshy


More information about the freebsd-hackers mailing list