Skip to content

Commit

Permalink
locks
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendan Gregg committed Jun 26, 2013
1 parent 4fae55c commit 5893a98
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
29 changes: 29 additions & 0 deletions locks/umutexmax.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/sbin/dtrace -s
/*
* umutexmax.d User-space mutex, summarize max block time.
*
* Prints output every second, for the given PID.
*
* USAGE: ./umutexmax.d -p PID
*
* 17-Jun-2013 Brendan Gregg Created this.
*/

plockstat$target:::mutex-block
{
self->ts[arg0] = timestamp;
}

plockstat$target:::mutex-acquire
/self->ts[arg0]/
{
@["max blocked (ms)"] = max(timestamp - self->ts[arg0]);
self->ts[arg0] = 0;
}

profile:::tick-1s
{
normalize(@, 1000000);
printa(@);
trunc(@);
}
37 changes: 37 additions & 0 deletions locks/umutexsum.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/sbin/dtrace -s
/*
* umutexsum.d User-space mutex, sum block time by lock.
*
* Prints output every second, for the given PID.
*
* USAGE: ./umutexsum.d -p PID
*
* 17-Jun-2013 Brendan Gregg Created this.
*/

#pragma D option quiet

dtrace:::BEGIN
{
printf("Tracing mutex for %d.\n", $target);
}

plockstat$target:::mutex-block
{
self->ts[arg0] = timestamp;
}

plockstat$target:::mutex-acquire
/self->ts[arg0]/
{
@[arg0] = sum(timestamp - self->ts[arg0]);
self->ts[arg0] = 0;
}

profile:::tick-1s
{
normalize(@, 1000000);
printf(" %10s %s\n", "TBLOCK(ms)", "LOCK");
printa(" %@10d %6A\n", @);
trunc(@);
}

0 comments on commit 5893a98

Please sign in to comment.