Skip to content

Instantly share code, notes, and snippets.

@ethercflow
Created May 24, 2018 16:43
Show Gist options
  • Save ethercflow/4a98abc3f97ff44608e3fda99d178be1 to your computer and use it in GitHub Desktop.
Save ethercflow/4a98abc3f97ff44608e3fda99d178be1 to your computer and use it in GitHub Desktop.
global inject, delay_cnt
probe begin {
println("injdect diskio delay begin.\n");
}
probe procfs("cnt").read {
$value = sprintf("%d\n", delay_cnt);
}
probe procfs("inject").write {
inject = $value;
printf("inject count %d, delay_cnt %s", delay_cnt, inject);
}
probe vfs.read.return {
if ($return && devname == @1 && inject == "on\n") {
delay_cnt++;
udelay($2);
}
}
probe vfs.write.return {
if ($return && devname == @1 && inject == "on\n") {
delay_cnt++;
udelay($3);
}
}
@ethercflow
Copy link
Author

eg:
sudo stap -p4 -DMAXSKIPPED=9999 -m idd -g inject_diskio_delay.stp sda6 300
sudo staprun idd.ko
echo on|sudo tee /proc/systemtap/idd/inject && sleep 60 && echo off|sudo tee /proc/systemtap/idd/inject

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