Re: Ktrace'ing kernel threads

2010-02-17 Thread John Baldwin
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
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Ktrace'ing kernel threads

2010-02-15 Thread Fernando Gleiser
- Original Message 
 From: Shrikanth Kamath shrikant...@gmail.com
 To: freebsd-hackers@freebsd.org
 Sent: Mon, February 15, 2010 8:21:40 AM
 Subject: Ktrace'ing kernel threads
 
 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?


Yo can do that easily with dtrace

#!/usr/sbin/dtrace -s

fbt::build_msg:entry
{
 printf(%d\n, timestamp)
}

fbt::build_msg:return
{
 printf(%d\n, timestamp)
}


or if you want to get an histogram of the call time distributions:

fbt::build_msg:entry
{
 self-ts=timestamp;
}

fbt::build_msg:return
{
 @[probefunc]=quantize(timestamp - self-ts);
}


Those are from the top of my head, I don't have a FreeBSD system at hand to 
test them, but I hope you'll get the idea


Fer


  
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org