From 563843907d3b7c82c9442dbb4810e090029da21f Mon Sep 17 00:00:00 2001 From: Wangjunqi123 Date: Wed, 21 Jun 2023 17:10:17 +0800 Subject: [PATCH] biotop probe: define the kprobe of blk_account_io_start to record pid and pid name --- observation/src/biotop/biotop.bpf.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/observation/src/biotop/biotop.bpf.c b/observation/src/biotop/biotop.bpf.c index 8d79e3d9..470e6411 100644 --- a/observation/src/biotop/biotop.bpf.c +++ b/observation/src/biotop/biotop.bpf.c @@ -30,4 +30,17 @@ struct { __type(value, struct val_t); } counts SEC(".maps"); +SEC("kprobe") +int BPF_KPROBE(blk_account_io_start, struct request *req) +{ + struct who_t who = {}; + + /* cache PID and comm by request */ + bpf_get_current_comm(&who.name, sizeof(who.name)); + who.pid = bpf_get_current_pid_tgid() >> 32; + bpf_map_update_elem(&whobyreq, &req, &who, BPF_ANY); + + return 0; +} + char LICENSE[] SEC("license") = "GPL"; -- Gitee