This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Inserting delays with systemtap
- From: "Bryn M. Reeves" <bmr at redhat dot com>
- To: systemtap at sourceware dot org
- Date: Wed, 07 Mar 2012 11:00:51 +0000
- Subject: Inserting delays with systemtap
-----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-----