126 lines
4.8 KiB
Diff
126 lines
4.8 KiB
Diff
From 879792d2d47c1308e884fb59d92fe535f7bb8d71 Mon Sep 17 00:00:00 2001
|
|
From: Tejun Heo <tj@kernel.org>
|
|
Date: Thu, 10 Mar 2022 08:37:21 -1000
|
|
Subject: [PATCH 1/2] biolatency, biolatpcts, biosnoop, biotop: Build fix for
|
|
v5.17+
|
|
|
|
During 5.17 dev cycle, the kernel dropped request->rq_disk. It can now be
|
|
accessed through request->q->disk. Fix the python ones in tools/. There are
|
|
more usages in other places which need to be fixed too.
|
|
|
|
Signed-off-by: Tejun Heo <tj@kernel.org>
|
|
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
|
---
|
|
tools/biolatency.py | 8 ++++++--
|
|
tools/biolatpcts.py | 11 ++++++++---
|
|
tools/biosnoop.py | 6 +++++-
|
|
tools/biotop.py | 9 +++++++--
|
|
4 files changed, 26 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/tools/biolatency.py b/tools/biolatency.py
|
|
index 427cee47..10c852ac 100755
|
|
--- a/tools/biolatency.py
|
|
+++ b/tools/biolatency.py
|
|
@@ -128,12 +128,16 @@ storage_str = ""
|
|
store_str = ""
|
|
if args.disks:
|
|
storage_str += "BPF_HISTOGRAM(dist, disk_key_t);"
|
|
- store_str += """
|
|
+ disks_str = """
|
|
disk_key_t key = {.slot = bpf_log2l(delta)};
|
|
- void *__tmp = (void *)req->rq_disk->disk_name;
|
|
+ void *__tmp = (void *)req->__RQ_DISK__->disk_name;
|
|
bpf_probe_read(&key.disk, sizeof(key.disk), __tmp);
|
|
dist.atomic_increment(key);
|
|
"""
|
|
+ if BPF.kernel_struct_has_field(b'request', b'rq_disk'):
|
|
+ store_str += disks_str.replace('__RQ_DISK__', 'rq_disk')
|
|
+ else:
|
|
+ store_str += disks_str.replace('__RQ_DISK__', 'q->disk')
|
|
elif args.flags:
|
|
storage_str += "BPF_HISTOGRAM(dist, flag_key_t);"
|
|
store_str += """
|
|
diff --git a/tools/biolatpcts.py b/tools/biolatpcts.py
|
|
index 0f334419..ea8b1ce6 100755
|
|
--- a/tools/biolatpcts.py
|
|
+++ b/tools/biolatpcts.py
|
|
@@ -72,9 +72,9 @@ void kprobe_blk_account_io_done(struct pt_regs *ctx, struct request *rq, u64 now
|
|
if (!rq->__START_TIME_FIELD__)
|
|
return;
|
|
|
|
- if (!rq->rq_disk ||
|
|
- rq->rq_disk->major != __MAJOR__ ||
|
|
- rq->rq_disk->first_minor != __MINOR__)
|
|
+ if (!rq->__RQ_DISK__ ||
|
|
+ rq->__RQ_DISK__->major != __MAJOR__ ||
|
|
+ rq->__RQ_DISK__->first_minor != __MINOR__)
|
|
return;
|
|
|
|
cmd_flags = rq->cmd_flags;
|
|
@@ -142,6 +142,11 @@ bpf_source = bpf_source.replace('__START_TIME_FIELD__', start_time_field)
|
|
bpf_source = bpf_source.replace('__MAJOR__', str(major))
|
|
bpf_source = bpf_source.replace('__MINOR__', str(minor))
|
|
|
|
+if BPF.kernel_struct_has_field(b'request', b'rq_disk'):
|
|
+ bpf_source = bpf_source.replace('__RQ_DISK__', 'rq_disk')
|
|
+else:
|
|
+ bpf_source = bpf_source.replace('__RQ_DISK__', 'q->disk')
|
|
+
|
|
bpf = BPF(text=bpf_source)
|
|
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")
|
|
diff --git a/tools/biosnoop.py b/tools/biosnoop.py
|
|
index ae38e384..a2b636aa 100755
|
|
--- a/tools/biosnoop.py
|
|
+++ b/tools/biosnoop.py
|
|
@@ -125,7 +125,7 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
|
|
data.pid = valp->pid;
|
|
data.sector = req->__sector;
|
|
bpf_probe_read_kernel(&data.name, sizeof(data.name), valp->name);
|
|
- struct gendisk *rq_disk = req->rq_disk;
|
|
+ struct gendisk *rq_disk = req->__RQ_DISK__;
|
|
bpf_probe_read_kernel(&data.disk_name, sizeof(data.disk_name),
|
|
rq_disk->disk_name);
|
|
}
|
|
@@ -156,6 +156,10 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
|
|
bpf_text = bpf_text.replace('##QUEUE##', '1')
|
|
else:
|
|
bpf_text = bpf_text.replace('##QUEUE##', '0')
|
|
+if BPF.kernel_struct_has_field(b'request', b'rq_disk'):
|
|
+ bpf_text = bpf_text.replace('__RQ_DISK__', 'rq_disk')
|
|
+else:
|
|
+ bpf_text = bpf_text.replace('__RQ_DISK__', 'q->disk')
|
|
if debug or args.ebpf:
|
|
print(bpf_text)
|
|
if args.ebpf:
|
|
diff --git a/tools/biotop.py b/tools/biotop.py
|
|
index b3e3ea00..882835f6 100755
|
|
--- a/tools/biotop.py
|
|
+++ b/tools/biotop.py
|
|
@@ -129,8 +129,8 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
|
|
|
|
// setup info_t key
|
|
struct info_t info = {};
|
|
- info.major = req->rq_disk->major;
|
|
- info.minor = req->rq_disk->first_minor;
|
|
+ info.major = req->__RQ_DISK__->major;
|
|
+ info.minor = req->__RQ_DISK__->first_minor;
|
|
/*
|
|
* The following deals with a kernel version change (in mainline 4.7, although
|
|
* it may be backported to earlier kernels) with how block request write flags
|
|
@@ -174,6 +174,11 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
|
|
print(bpf_text)
|
|
exit()
|
|
|
|
+if BPF.kernel_struct_has_field(b'request', b'rq_disk'):
|
|
+ bpf_text = bpf_text.replace('__RQ_DISK__', 'rq_disk')
|
|
+else:
|
|
+ bpf_text = bpf_text.replace('__RQ_DISK__', 'q->disk')
|
|
+
|
|
b = BPF(text=bpf_text)
|
|
if BPF.get_kprobe_functions(b'__blk_account_io_start'):
|
|
b.attach_kprobe(event="__blk_account_io_start", fn_name="trace_pid_start")
|
|
--
|
|
2.35.1
|
|
|