bcc/bcc-0.20.0-tools-Fix-BCC-bio-tools-with-recent-kernel-change.patch
Jerome Marchand 1544174780 Fix bio tools
Fix the bio tools thas has been broken by a couple of changes in the
kernel.

Resolves: rhbz#2039595
2022-02-25 07:22:03 +01:00

120 lines
5.0 KiB
Diff

From 59a4e7ea490f78ba289c1ba461bfe1fce9e7ef19 Mon Sep 17 00:00:00 2001
From: Hengqi Chen <chenhengqi@outlook.com>
Date: Sat, 11 Dec 2021 17:36:17 +0800
Subject: [PATCH] tools: Fix BCC bio tools with recent kernel change
Several BCC bio tools are broken due to kernel change ([0]).
blk_account_io_{start, done} were renamed to __blk_account_io_{start, done},
and the symbols gone from /proc/kallsyms. Fix them by checking symbol existence.
[0]: https://github.com/torvalds/linux/commit/be6bfe36db1795babe9d92178a47b2e02193cb0f
Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
---
tools/biolatency.py | 12 ++++++++----
tools/biolatpcts.py | 5 ++++-
tools/biosnoop.py | 11 ++++++++---
tools/biotop.py | 11 ++++++++---
4 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/tools/biolatency.py b/tools/biolatency.py
index 0599609b..2e75a5de 100755
--- a/tools/biolatency.py
+++ b/tools/biolatency.py
@@ -168,13 +168,18 @@ bpf_text = bpf_text.replace("STORE", store_str)
# load BPF program
b = BPF(text=bpf_text)
if args.queued:
- b.attach_kprobe(event="blk_account_io_start", fn_name="trace_req_start")
+ if BPF.get_kprobe_functions(b'__blk_account_io_start'):
+ b.attach_kprobe(event="__blk_account_io_start", fn_name="trace_req_start")
+ else:
+ b.attach_kprobe(event="blk_account_io_start", fn_name="trace_req_start")
else:
if BPF.get_kprobe_functions(b'blk_start_request'):
b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_req_start")
-b.attach_kprobe(event="blk_account_io_done",
- fn_name="trace_req_done")
+if BPF.get_kprobe_functions(b'__blk_account_io_done'):
+ b.attach_kprobe(event="__blk_account_io_done", fn_name="trace_req_done")
+else:
+ b.attach_kprobe(event="blk_account_io_done", fn_name="trace_req_done")
if not args.json:
print("Tracing block device I/O... Hit Ctrl-C to end.")
@@ -277,4 +282,3 @@ dist = b.get_table("dist")
countdown -= 1
if exiting or countdown == 0:
exit()
-
diff --git a/tools/biolatpcts.py b/tools/biolatpcts.py
index 5ab8aa5f..a2f59592 100755
--- a/tools/biolatpcts.py
+++ b/tools/biolatpcts.py
@@ -142,7 +142,10 @@ bpf_source = bpf_source.replace('__MAJOR__', str(major))
bpf_source = bpf_source.replace('__MINOR__', str(minor))
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")
# times are in usecs
MSEC = 1000
diff --git a/tools/biosnoop.py b/tools/biosnoop.py
index 333949b5..2b954ac9 100755
--- a/tools/biosnoop.py
+++ b/tools/biosnoop.py
@@ -163,12 +163,17 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
# initialize BPF
b = BPF(text=bpf_text)
-b.attach_kprobe(event="blk_account_io_start", fn_name="trace_pid_start")
+if BPF.get_kprobe_functions(b'__blk_account_io_start'):
+ b.attach_kprobe(event="__blk_account_io_start", fn_name="trace_pid_start")
+else:
+ b.attach_kprobe(event="blk_account_io_start", fn_name="trace_pid_start")
if BPF.get_kprobe_functions(b'blk_start_request'):
b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_req_start")
-b.attach_kprobe(event="blk_account_io_done",
- fn_name="trace_req_completion")
+if BPF.get_kprobe_functions(b'__blk_account_io_done'):
+ b.attach_kprobe(event="__blk_account_io_done", fn_name="trace_req_completion")
+else:
+ b.attach_kprobe(event="blk_account_io_done", fn_name="trace_req_completion")
# header
print("%-11s %-14s %-6s %-7s %-1s %-10s %-7s" % ("TIME(s)", "COMM", "PID",
diff --git a/tools/biotop.py b/tools/biotop.py
index 596f0076..0ebfef0e 100755
--- a/tools/biotop.py
+++ b/tools/biotop.py
@@ -180,12 +180,17 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
exit()
b = BPF(text=bpf_text)
-b.attach_kprobe(event="blk_account_io_start", fn_name="trace_pid_start")
+if BPF.get_kprobe_functions(b'__blk_account_io_start'):
+ b.attach_kprobe(event="__blk_account_io_start", fn_name="trace_pid_start")
+else:
+ b.attach_kprobe(event="blk_account_io_start", fn_name="trace_pid_start")
if BPF.get_kprobe_functions(b'blk_start_request'):
b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_req_start")
-b.attach_kprobe(event="blk_account_io_done",
- fn_name="trace_req_completion")
+if BPF.get_kprobe_functions(b'__blk_account_io_done'):
+ b.attach_kprobe(event="__blk_account_io_done", fn_name="trace_req_completion")
+else:
+ b.attach_kprobe(event="blk_account_io_done", fn_name="trace_req_completion")
print('Tracing... Output every %d secs. Hit Ctrl-C to end' % interval)
--
2.35.1