Commit 5853e72e authored by Brendan Gregg's avatar Brendan Gregg

shorten disksnoop.c example further

parent 75f47bed
......@@ -15,27 +15,21 @@
BPF_HASH(start, struct request *);
int kprobe__blk_start_request(struct pt_regs *ctx, struct request *req) {
u64 ts;
void kprobe__blk_start_request(struct pt_regs *ctx, struct request *req) {
// stash start timestamp by request ptr
ts = bpf_ktime_get_ns();
start.update(&req, &ts);
u64 ts = bpf_ktime_get_ns();
return 0;
start.update(&req, &ts);
}
int kprobe__blk_update_request(struct pt_regs *ctx, struct request *req) {
void kprobe__blk_update_request(struct pt_regs *ctx, struct request *req) {
u64 *tsp, delta;
tsp = start.lookup(&req);
if (tsp != 0) {
delta = bpf_ktime_get_ns() - *tsp;
bpf_trace_printk("%d %x %d\n", req->__data_len,
req->cmd_flags, delta / 1000);
start.delete(&req);
}
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment