block tracepoints no longer have struct request_queue arg
authorRoman Sudarikov <roman.sudarikov@huawei.com>
Mon, 15 Mar 2021 19:31:27 +0000 (19:31 +0000)
committeryonghong-song <ys114321@gmail.com>
Thu, 1 Apr 2021 14:53:41 +0000 (07:53 -0700)
libbpf-tools/biolatency.bpf.c

index fe18fd89d7a0e798b956bf3bb205175803db5959..c09426cb73a5f2d3dda1311b8a1d89076a362d9a 100644 (file)
@@ -6,6 +6,7 @@
 #include <bpf/bpf_tracing.h>
 #include "biolatency.h"
 #include "bits.bpf.h"
+#include <linux/version.h>
 
 #define MAX_ENTRIES    10240
 
@@ -52,18 +53,34 @@ int trace_rq_start(struct request *rq)
 }
 
 SEC("tp_btf/block_rq_insert")
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 1)
+int BPF_PROG(block_rq_insert, struct request *rq)
+{
+       return trace_rq_start(rq);
+}
+#else
 int BPF_PROG(block_rq_insert, struct request_queue *q, struct request *rq)
 {
        return trace_rq_start(rq);
 }
+#endif
 
 SEC("tp_btf/block_rq_issue")
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 1)
+int BPF_PROG(block_rq_issue, struct request *rq)
+{
+       if (targ_queued && BPF_CORE_READ(rq->q, elevator))
+               return 0;
+       return trace_rq_start(rq);
+}
+#else
 int BPF_PROG(block_rq_issue, struct request_queue *q, struct request *rq)
 {
        if (targ_queued && BPF_CORE_READ(q, elevator))
                return 0;
        return trace_rq_start(rq);
 }
+#endif
 
 SEC("tp_btf/block_rq_complete")
 int BPF_PROG(block_rq_complete, struct request *rq, int error,