Skip to content

Instantly share code, notes, and snippets.

@x2c3z4
Last active May 9, 2016 03:08
Show Gist options
  • Save x2c3z4/1e756e845ab9e1dbfddb8aa9cfaa21ff to your computer and use it in GitHub Desktop.
Save x2c3z4/1e756e845ab9e1dbfddb8aa9cfaa21ff to your computer and use it in GitHub Desktop.
#!/usr/sbin/dtrace -s
dtrace:::BEGIN
{
num=0;
}
pid$target::di_init:entry
{
self->ts = timestamp;
/* self->vts = vtimestamp; */
}
pid$target::di_init:return
/self->ts/
{
/* printf("%d\n", timestamp - self->ts);*/
@time[probefunc] = avg(timestamp - self->ts);
@ = quantize(timestamp - self->ts);
/*@c["On-CPU us:"] = lquantize((vtimestamp - self->vts) / 1000, 0, 10000, 10);*/
self->ts = 0;
num++;
/*self->vts = 0;*/
}
/*
fbt::sd_unit_attach:return
/self->ts == 0&& num >= $1/
{
exit(0);
}
*/
/*tick-100s { exit(0); }*/
#!/usr/sbin/dtrace -s
pid$target::di_init:entry,
pid$target::main:entry
{
ts[probefunc] = timestamp;
/* self->vts = vtimestamp; */
}
pid$target::main:return,
pid$target::di_init:return
/ts[probefunc]/
{
/* printf("%d\n", timestamp - self->ts);*/
@time[probefunc] = sum(timestamp - ts[probefunc]);
/*@ = quantize(timestamp - ts[probefunc]);*/
/*@c["On-CPU us:"] = lquantize((vtimestamp - self->vts) / 1000, 0, 10000, 10);*/
ts[probefunc] = 0;
}
#!/usr/sbin/dtrace -s
#pragma D option flowindent
pid$target::main:entry
{
self->trace = 1;
}
pid$target::main:return
/self->trace/
{
self->trace = 0;
}
pid$target:::entry,
pid$target:::return
/self->trace/
{
}
#!/usr/sbin/dtrace -s
pid$target:::entry,
pid$target:::entry
{
ts[probefunc] = timestamp;
/* self->vts = vtimestamp; */
}
pid$target:::return,
pid$target:::return
/ts[probefunc]/
{
/* printf("%d\n", timestamp - self->ts);*/
@time[probefunc] = sum(timestamp - ts[probefunc]);
/*@ = quantize(timestamp - ts[probefunc]);*/
/*@c["On-CPU us:"] = lquantize((vtimestamp - self->vts) / 1000, 0, 10000, 10);*/
ts[probefunc] = 0;
}
@x2c3z4
Copy link
Author

x2c3z4 commented May 6, 2016

dtrace -s ./user.d -c "mpathadm list lu"

@x2c3z4
Copy link
Author

x2c3z4 commented May 6, 2016

dtrace -ln 'pid$target:::entry' -c "mpathadm list lu"

@x2c3z4
Copy link
Author

x2c3z4 commented May 6, 2016

@x2c3z4
Copy link
Author

x2c3z4 commented May 9, 2016

dtrace -x stackframes=100 -n 'profile-997 /pid == $target/ { @[stack()] = count(); } tick-60s { exit(0); }' -c "mpathadm list lu"  -o out.kern_stacks
dtrace -x ustackframes=100 -n 'profile-997 /pid == $target/ { @[ustack()] = count(); } tick-60s { exit(0); }' -c "mpathadm list lu"  -o out.user_stacks
./stackcollapse.pl out.kern_stacks | ./flamegraph.pl >kern.svg
./stackcollapse.pl out.user_stacks | ./flamegraph.pl >user.svg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment