mirror of
https://github.com/ebrandi/FDD-book.git
synced 2026-12-06 00:23:30 +00:00
Organize companion code and materials by book part: part-01/ Foundations part-02/ Kernel & driver fundamentals part-03/ Character & block devices part-04/ Networking & storage part-05/ Buses & advanced topics part-06/ Debugging & performance part-07/ Real-world drivers appendices/ Supplementary material README.md Overview and build instructions
40 lines
911 B
D
40 lines
911 B
D
#!/usr/sbin/dtrace -s
|
|
/*
|
|
* lockstat-simple.d - count lock acquisitions in and around perfdemo_read.
|
|
*
|
|
* Usage: sudo dtrace -s lockstat-simple.d
|
|
*
|
|
* Prints, per lock, the number of times the lock was held while
|
|
* perfdemo_read was on-CPU. A lock that appears here many times is
|
|
* touched by the read path.
|
|
*
|
|
* Note: on a perfdemo built without its own mutex, the output will
|
|
* show only the locks touched by common kernel code (sleepq locks,
|
|
* sched_lock, etc.). A driver with its own mutex under load will
|
|
* show that mutex prominently.
|
|
*/
|
|
|
|
#pragma D option quiet
|
|
|
|
fbt:perfdemo:perfdemo_read:entry
|
|
{
|
|
self->in_read = 1;
|
|
}
|
|
|
|
fbt:perfdemo:perfdemo_read:return
|
|
{
|
|
self->in_read = 0;
|
|
}
|
|
|
|
lockstat:::adaptive-acquire
|
|
/self->in_read/
|
|
{
|
|
@[probefunc, stringof(args[0]->lock_object.lo_name)] =
|
|
count();
|
|
}
|
|
|
|
END
|
|
{
|
|
printf("%-30s %-30s %s\n", "caller", "lock", "count");
|
|
printa("%-30s %-30s %@d\n", @);
|
|
}
|