Ktrace'ing kernel threads

John Baldwin jhb at freebsd.org
Wed Feb 17 20:49:26 UTC 2010


On Monday 15 February 2010 6:21:40 am Shrikanth Kamath wrote:
> Can ktrace trace another kernel thread which has roughly the semantics as
> below, right now it
> does not hit any of the designated interesting points that ktrace is built
> for, but what if I could define those,
> will ktrace still allow tracing another kernel thread?
> 
> thread(client_info)
> {
>     ...
>     ...
>     build_msg(client_info);  /* this will malloc a mbuf and fill the data in
> it */
>     ...
>     sosend(client_info);
> }
> 
> I want to time the entry/return of build_msg, and the time sosend, dump
> client_info (some specific fields).

It is probably easier to do this with DTrace (albeit possibly with more 
overhead).  You can ktrace a kthread fine, but you would need to write your 
own ktrace hooks (and record parser for kdump) which would take a bit longer 
than a D script with DTrace.

-- 
John Baldwin


More information about the freebsd-hackers mailing list