Inserting delays with systemtap
Bryn M. Reeves
bmr@redhat.com
Wed Mar 7 11:01:00 GMT 2012
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Folks,
Recently I found it useful to use systemtap to add a configurable
delay inside a critical section of module code. This was done to widen
a (very difficult to hit) race window for testing/verification purposes.
I got this working with a bit of embedded C:
# cat cdc-acm-test.stp
#!/usr/bin/stap -DSTP_NO_OVERLOAD -g
%{
#include <linux/delay.h>
%}
function mdelay(ms:long) %{
/* guru */
mdelay(THIS->ms);
%}
probe begin {
printf("%s\n", "cdc-acm-test: inserting delay probe in tasklet fn")
}
probe end {
printf("%s\n", "cdc-acm-test: removing delay probe from tasklet fn")
printf("%s\n", "cdc-acm-test: done")
}
probe module("cdc_acm").statement("*@drivers/usb/class/cdc-acm.c:341") {
mdelay($1)
}
The DWARF probe is necessary as we need to land in the middle of a
section protected by a spinlock (that's taken from a tasklet without
disabling interrupts..).
Would it be worth having something like this in a tapset? The
requirement to use STP_NO_OVERLOAD for long-running delays (I needed
200ms to reliably hit the lockup in cdc-acm) might make this less
useful but I found the technique very useful for this particular case.
Cheers,
Bryn.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk9XP+MACgkQ6YSQoMYUY96kdgCfURomvfhypSukwT+DZ6eyvWip
+cYAnRTENEwT7IhWEVUdhsKq7AEJwNOY
=RWuQ
-----END PGP SIGNATURE-----
More information about the Systemtap
mailing list