Skip to content

Instantly share code, notes, and snippets.

@oraoto
Created February 15, 2019 11:12
Show Gist options
  • Save oraoto/bcf51158d2923de5a76976f50584b26e to your computer and use it in GitHub Desktop.
Save oraoto/bcf51158d2923de5a76976f50584b26e to your computer and use it in GitHub Desktop.
Block IO size and latency tracing
#!/usr/bin/env bpftrace
BEGIN {
printf("Tracing block io, Ctrl-C to get result\n");
}
tracepoint:block:block_rq_issue / args->sector > 0 /
{
@start[args->sector] = nsecs;
@kbs[args->sector] = args->bytes / 1024;
}
tracepoint:block:block_rq_complete /args->sector > 0 && @start[args->sector] /
{
$now = nsecs;
$sector = args->sector;
$s = @start[$sector];
$lat = ($now - $s) / 1000000;
delete(@start[$sector]);
$k = @kbs[$sector];
delete(@kbs[$sector]);
@kbytes = hist($k);
@latency_ms = hist($lat);
}
END {
delete(@start);
delete(@kbs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment