Blame SOURCES/bcc-0.20.0-biolatpcts-Build-fixes-on-recent-kernels.patch

baabe4
From 11614bcacdecd4d1f7015bb0f0311bb709207991 Mon Sep 17 00:00:00 2001
baabe4
From: Tejun Heo <tj@kernel.org>
baabe4
Date: Thu, 27 Jan 2022 06:25:31 -1000
baabe4
Subject: [PATCH] biolatpcts: Build fixes on recent kernels
baabe4
baabe4
* `struct request` definition recently moved from blkdev.h to blk-mq.h
baabe4
  breaking both tools/biolatpcts and examples/tracing/biolatpcts. Fix them
baabe4
  by also including blk-mq.h.
baabe4
baabe4
* blk_account_io_done() got split into two parts - inline condition checks
baabe4
  and the actual accounting with the latter now done in
baabe4
  __blk_account_io_done(). The kprobe attachment needs to be conditionalized
baabe4
  to work across the change. tools/biolatpcts was already updated but
baabe4
  examples/tracing/biolatpcts wasn't. Fix it.
baabe4
baabe4
Signed-off-by: Tejun Heo <tj@kernel.org>
baabe4
---
baabe4
 examples/tracing/biolatpcts.py | 6 +++++-
baabe4
 tools/biolatpcts.py            | 1 +
baabe4
 2 files changed, 6 insertions(+), 1 deletion(-)
baabe4
baabe4
diff --git a/examples/tracing/biolatpcts.py b/examples/tracing/biolatpcts.py
baabe4
index c9bb834e..68a59516 100755
baabe4
--- a/examples/tracing/biolatpcts.py
baabe4
+++ b/examples/tracing/biolatpcts.py
baabe4
@@ -11,6 +11,7 @@ from time import sleep
baabe4
 
baabe4
 bpf_source = """
baabe4
 #include <linux/blk_types.h>
baabe4
+#include <linux/blk-mq.h>
baabe4
 #include <linux/blkdev.h>
baabe4
 #include <linux/time64.h>
baabe4
 
baabe4
@@ -45,7 +46,10 @@ void kprobe_blk_account_io_done(struct pt_regs *ctx, struct request *rq, u64 now
baabe4
 """
baabe4
 
baabe4
 bpf = BPF(text=bpf_source)
baabe4
-bpf.attach_kprobe(event='blk_account_io_done', fn_name='kprobe_blk_account_io_done')
baabe4
+if BPF.get_kprobe_functions(b'__blk_account_io_done'):
baabe4
+    bpf.attach_kprobe(event="__blk_account_io_done", fn_name="kprobe_blk_account_io_done")
baabe4
+else:
baabe4
+    bpf.attach_kprobe(event="blk_account_io_done", fn_name="kprobe_blk_account_io_done")
baabe4
 
baabe4
 cur_lat_100ms = bpf['lat_100ms']
baabe4
 cur_lat_1ms = bpf['lat_1ms']
baabe4
diff --git a/tools/biolatpcts.py b/tools/biolatpcts.py
baabe4
index a2f59592..0f334419 100755
baabe4
--- a/tools/biolatpcts.py
baabe4
+++ b/tools/biolatpcts.py
baabe4
@@ -56,6 +56,7 @@ parser.add_argument('--verbose', '-v', action='count', default = 0)
baabe4
 bpf_source = """
baabe4
 #include <linux/blk_types.h>
baabe4
 #include <linux/blkdev.h>
baabe4
+#include <linux/blk-mq.h>
baabe4
 #include <linux/time64.h>
baabe4
 
baabe4
 BPF_PERCPU_ARRAY(rwdf_100ms, u64, 400);
baabe4
-- 
baabe4
2.35.1
baabe4