biolatpcts: Build fixes on recent kernels
* `struct request` definition recently moved from blkdev.h to blk-mq.h
breaking both tools/biolatpcts and examples/tracing/biolatpcts. Fix them
by also including blk-mq.h.
* blk_account_io_done() got split into two parts - inline condition checks
and the actual accounting with the latter now done in
__blk_account_io_done(). The kprobe attachment needs to be conditionalized
to work across the change. tools/biolatpcts was already updated but
examples/tracing/biolatpcts wasn't. Fix it.
Signed-off-by: Tejun Heo <tj@kernel.org>
diff --git a/examples/tracing/biolatpcts.py b/examples/tracing/biolatpcts.py
index c9bb834..68a5951 100755
--- a/examples/tracing/biolatpcts.py
+++ b/examples/tracing/biolatpcts.py
@@ -11,6 +11,7 @@
bpf_source = """
#include <linux/blk_types.h>
+#include <linux/blk-mq.h>
#include <linux/blkdev.h>
#include <linux/time64.h>
@@ -45,7 +46,10 @@
"""
bpf = BPF(text=bpf_source)
-bpf.attach_kprobe(event='blk_account_io_done', fn_name='kprobe_blk_account_io_done')
+if BPF.get_kprobe_functions(b'__blk_account_io_done'):
+ bpf.attach_kprobe(event="__blk_account_io_done", fn_name="kprobe_blk_account_io_done")
+else:
+ bpf.attach_kprobe(event="blk_account_io_done", fn_name="kprobe_blk_account_io_done")
cur_lat_100ms = bpf['lat_100ms']
cur_lat_1ms = bpf['lat_1ms']
diff --git a/tools/biolatpcts.py b/tools/biolatpcts.py
index a2f5959..0f33441 100755
--- a/tools/biolatpcts.py
+++ b/tools/biolatpcts.py
@@ -56,6 +56,7 @@
bpf_source = """
#include <linux/blk_types.h>
#include <linux/blkdev.h>
+#include <linux/blk-mq.h>
#include <linux/time64.h>
BPF_PERCPU_ARRAY(rwdf_100ms, u64, 400);