Fix bio tools
Fix the bio tools thas has been broken by a couple of changes in the kernel. Resolves: rhbz#2039595
This commit is contained in:
parent
0336e763b9
commit
1544174780
60
bcc-0.20.0-biolatpcts-Build-fixes-on-recent-kernels.patch
Normal file
60
bcc-0.20.0-biolatpcts-Build-fixes-on-recent-kernels.patch
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
From 11614bcacdecd4d1f7015bb0f0311bb709207991 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tejun Heo <tj@kernel.org>
|
||||||
|
Date: Thu, 27 Jan 2022 06:25:31 -1000
|
||||||
|
Subject: [PATCH] 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>
|
||||||
|
---
|
||||||
|
examples/tracing/biolatpcts.py | 6 +++++-
|
||||||
|
tools/biolatpcts.py | 1 +
|
||||||
|
2 files changed, 6 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/examples/tracing/biolatpcts.py b/examples/tracing/biolatpcts.py
|
||||||
|
index c9bb834e..68a59516 100755
|
||||||
|
--- a/examples/tracing/biolatpcts.py
|
||||||
|
+++ b/examples/tracing/biolatpcts.py
|
||||||
|
@@ -11,6 +11,7 @@ from time import sleep
|
||||||
|
|
||||||
|
bpf_source = """
|
||||||
|
#include <linux/blk_types.h>
|
||||||
|
+#include <linux/blk-mq.h>
|
||||||
|
#include <linux/blkdev.h>
|
||||||
|
#include <linux/time64.h>
|
||||||
|
|
||||||
|
@@ -45,7 +46,10 @@ void kprobe_blk_account_io_done(struct pt_regs *ctx, struct request *rq, u64 now
|
||||||
|
"""
|
||||||
|
|
||||||
|
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 a2f59592..0f334419 100755
|
||||||
|
--- a/tools/biolatpcts.py
|
||||||
|
+++ b/tools/biolatpcts.py
|
||||||
|
@@ -56,6 +56,7 @@ parser.add_argument('--verbose', '-v', action='count', default = 0)
|
||||||
|
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);
|
||||||
|
--
|
||||||
|
2.35.1
|
||||||
|
|
@ -0,0 +1,119 @@
|
|||||||
|
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
|
||||||
|
|
66
bcc-0.20.0-tools-include-blk-mq.h-in-bio-tools.patch
Normal file
66
bcc-0.20.0-tools-include-blk-mq.h-in-bio-tools.patch
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
From ee81072e75bcc796b1154c315e2eb0371928a922 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jerome Marchand <jmarchan@redhat.com>
|
||||||
|
Date: Wed, 23 Feb 2022 16:04:30 +0100
|
||||||
|
Subject: [PATCH] tools: include blk-mq.h in bio tools
|
||||||
|
|
||||||
|
Kernel commit 24b83deb29b ("block: move struct request to blk-mq.h")
|
||||||
|
has moved struct request from blkdev.h to blk-mq.h. It results in
|
||||||
|
several bio tools to fail with errors of the following type:
|
||||||
|
|
||||||
|
error: incomplete definition of type 'struct request'
|
||||||
|
|
||||||
|
Since blk-mq.h had always included blkdev.h. it is safe to simply
|
||||||
|
replace the inclusion of blkdev.h by blk-mq-h. It works on both older
|
||||||
|
and newer kernel.
|
||||||
|
|
||||||
|
Fixes: #3869
|
||||||
|
|
||||||
|
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
||||||
|
---
|
||||||
|
tools/biolatency.py | 2 +-
|
||||||
|
tools/biosnoop.py | 2 +-
|
||||||
|
tools/biotop.py | 2 +-
|
||||||
|
3 files changed, 3 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/tools/biolatency.py b/tools/biolatency.py
|
||||||
|
index f4e2c9ea..427cee47 100755
|
||||||
|
--- a/tools/biolatency.py
|
||||||
|
+++ b/tools/biolatency.py
|
||||||
|
@@ -64,7 +64,7 @@ debug = 0
|
||||||
|
# define BPF program
|
||||||
|
bpf_text = """
|
||||||
|
#include <uapi/linux/ptrace.h>
|
||||||
|
-#include <linux/blkdev.h>
|
||||||
|
+#include <linux/blk-mq.h>
|
||||||
|
|
||||||
|
typedef struct disk_key {
|
||||||
|
char disk[DISK_NAME_LEN];
|
||||||
|
diff --git a/tools/biosnoop.py b/tools/biosnoop.py
|
||||||
|
index 2b954ac9..ae38e384 100755
|
||||||
|
--- a/tools/biosnoop.py
|
||||||
|
+++ b/tools/biosnoop.py
|
||||||
|
@@ -37,7 +37,7 @@ debug = 0
|
||||||
|
# define BPF program
|
||||||
|
bpf_text="""
|
||||||
|
#include <uapi/linux/ptrace.h>
|
||||||
|
-#include <linux/blkdev.h>
|
||||||
|
+#include <linux/blk-mq.h>
|
||||||
|
|
||||||
|
// for saving the timestamp and __data_len of each request
|
||||||
|
struct start_req_t {
|
||||||
|
diff --git a/tools/biotop.py b/tools/biotop.py
|
||||||
|
index eac4dab9..b3e3ea00 100755
|
||||||
|
--- a/tools/biotop.py
|
||||||
|
+++ b/tools/biotop.py
|
||||||
|
@@ -54,7 +54,7 @@ diskstats = "/proc/diskstats"
|
||||||
|
# load BPF program
|
||||||
|
bpf_text = """
|
||||||
|
#include <uapi/linux/ptrace.h>
|
||||||
|
-#include <linux/blkdev.h>
|
||||||
|
+#include <linux/blk-mq.h>
|
||||||
|
|
||||||
|
// for saving the timestamp and __data_len of each request
|
||||||
|
struct start_req_t {
|
||||||
|
--
|
||||||
|
2.35.1
|
||||||
|
|
8
bcc.spec
8
bcc.spec
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
Name: bcc
|
Name: bcc
|
||||||
Version: 0.20.0
|
Version: 0.20.0
|
||||||
Release: 8%{?dist}
|
Release: 9%{?dist}
|
||||||
Summary: BPF Compiler Collection (BCC)
|
Summary: BPF Compiler Collection (BCC)
|
||||||
License: ASL 2.0
|
License: ASL 2.0
|
||||||
URL: https://github.com/iovisor/bcc
|
URL: https://github.com/iovisor/bcc
|
||||||
@ -44,6 +44,9 @@ Patch8: %{name}-%{version}-Fix-mdflush-on-RHEL9.patch
|
|||||||
Patch9: %{name}-%{version}-Handle-renaming-of-task_struct_-state-field-on-RHEL-.patch
|
Patch9: %{name}-%{version}-Handle-renaming-of-task_struct_-state-field-on-RHEL-.patch
|
||||||
Patch10: %{name}-%{version}-Fix-a-llvm-compilation-error.patch
|
Patch10: %{name}-%{version}-Fix-a-llvm-compilation-error.patch
|
||||||
Patch11: %{name}-%{version}-Remove-APInt-APSInt-toString-std-string-variants.patch
|
Patch11: %{name}-%{version}-Remove-APInt-APSInt-toString-std-string-variants.patch
|
||||||
|
Patch12: %{name}-%{version}-tools-Fix-BCC-bio-tools-with-recent-kernel-change.patch
|
||||||
|
Patch13: %{name}-%{version}-biolatpcts-Build-fixes-on-recent-kernels.patch
|
||||||
|
Patch14: %{name}-%{version}-tools-include-blk-mq.h-in-bio-tools.patch
|
||||||
|
|
||||||
# Arches will be included as upstream support is added and dependencies are
|
# Arches will be included as upstream support is added and dependencies are
|
||||||
# satisfied in the respective arches
|
# satisfied in the respective arches
|
||||||
@ -255,6 +258,9 @@ install libbpf-tools/tmp-install/bin/* %{buildroot}/%{_sbindir}
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Feb 24 2022 Jerome Marchand <jmarchan@redhat.com> - 0.20.0-9
|
||||||
|
- Fix bio tools (rhbz#2039595)
|
||||||
|
|
||||||
* Mon Nov 22 2021 Jerome Marchand <jmarchan@redhat.com> - 0.20.0-8
|
* Mon Nov 22 2021 Jerome Marchand <jmarchan@redhat.com> - 0.20.0-8
|
||||||
- Rebuild for LLVM 13
|
- Rebuild for LLVM 13
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user