in src/samplers/xfs/bpf.c [36:70]
static int trace_return(struct pt_regs *ctx, int op)
{
// get pid
u32 pid = bpf_get_current_pid_tgid();
// lookup start time
u64 *tsp = start.lookup(&pid);
// skip events without start
if (tsp == 0) {
return 0;
}
// calculate latency in microseconds
u64 delta = (bpf_ktime_get_ns() - *tsp) / 1000;
// calculate index
u64 index = value_to_index2(delta);
// store into correct histogram for OP
if (op == 0) {
read.increment(index);
} else if (op == 1) {
write.increment(index);
} else if (op == 2) {
open.increment(index);
} else if (op == 3) {
fsync.increment(index);
}
// clear the start time
start.delete(&pid);
return 0;
}