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 <[email protected]>
diff --git a/tools/biolatency.py b/tools/biolatency.py
index 427cee4..10c852a 100755
--- a/tools/biolatency.py
+++ b/tools/biolatency.py
@@ -128,12 +128,16 @@
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 0f33441..ea8b1ce 100755
--- a/tools/biolatpcts.py
+++ b/tools/biolatpcts.py
@@ -72,9 +72,9 @@
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('__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 ae38e38..a2b636a 100755
--- a/tools/biosnoop.py
+++ b/tools/biosnoop.py
@@ -125,7 +125,7 @@
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 @@
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 b3e3ea0..882835f 100755
--- a/tools/biotop.py
+++ b/tools/biotop.py
@@ -129,8 +129,8 @@
// 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 @@
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")