[dtrace-discuss] How to record waiters on mutex locks ?
Jonathan Adams
jwadams at gmail.com
Tue Jul 18 22:22:29 PDT 2006
On 7/18/06, Jonathan Adams <jwadams at gmail.com> wrote:
>
> On 7/18/06, David Jafferian - Sun Microsystems <
> david.jafferian at east.sun.com> wrote:
>
> >
> > Hi -
> >
> > I wrote the following simple script :
> >
> > ---begin---
> > #!/usr/sbin/dtrace -s
> >
> > BEGIN
> > {
> > lp = (int64_t)&`hat_statlock;
> > }
> >
> > fbt::mutex_vector_enter:entry
> > /arg0 == lp/
> > {
> > waiters++;
> > }
> >
> > lockstat:::adaptive-block
> > /arg0 == lp/
> > {
> > waiters--;
> > }
> >
> > lockstat:::adaptive-spin
> > /arg0 == lp/
> > {
> > waiters--;
> > }
> >
> > tick-10sec
> > {
> > trace(waiters);
> > }
> > ---end---
> >
> > Then I tested it on a two CPU sun4u machine as follows :
>
> ...
>
> > I don't see why "waiters" should increase over time.
>
>
> Global variables are not guaranteed to be consistant if modified from
> multiple threads. Try using an aggregation:
>
> s/waiters++/@a = sum(1)/
> s/waiters--/@a = sum(-1)/
> s/trace(waiters)/printa(@a)/
>
In addition, with the recent putback of
6301220 <http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6301220>Fix
stats reporting so we do not lie about spins.
into Nevada, a single mutex_vector_enter() can trigger both a block and a
spin, which will break your script.
Cheers,
- jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20060718/c5cbe835/attachment.html
More information about the dtrace-discuss
mailing list