static int trace_return()

in src/samplers/ext4/bpf.c [43:75]


static int trace_return(struct pt_regs *ctx, int op)
{
    // get pid
    u32 pid = bpf_get_current_pid_tgid();

    // lookup start
    u64 *tsp = start.lookup(&pid);

    // skip events with unknown start
    if (tsp == 0) {
        return 0;
    }

    // calculate latency
    u64 delta = (bpf_ktime_get_ns() - *tsp) / 1000;

    // store as histogram
    unsigned int index = value_to_index2(delta);
    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 entry from the map
    start.delete(&pid);

    return 0;
}