Skip to content

Commit

Permalink
tools: Fix misuse of kernel_struct_has_field in bio* tools
Browse files Browse the repository at this point in the history
  • Loading branch information
xingfeng2510 authored and yonghong-song committed Apr 26, 2022
1 parent 2c389db commit 3b69447
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tools/biolatency.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
bpf_probe_read(&key.disk, sizeof(key.disk), __tmp);
dist.atomic_increment(key);
"""
if BPF.kernel_struct_has_field(b'request', b'rq_disk'):
if BPF.kernel_struct_has_field(b'request', b'rq_disk') == 1:
store_str += disks_str.replace('__RQ_DISK__', 'rq_disk')
else:
store_str += disks_str.replace('__RQ_DISK__', 'q->disk')
Expand Down
2 changes: 1 addition & 1 deletion tools/biolatpcts.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
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'):
if BPF.kernel_struct_has_field(b'request', b'rq_disk') == 1:
bpf_source = bpf_source.replace('__RQ_DISK__', 'rq_disk')
else:
bpf_source = bpf_source.replace('__RQ_DISK__', 'q->disk')
Expand Down
2 changes: 1 addition & 1 deletion tools/biosnoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
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'):
if BPF.kernel_struct_has_field(b'request', b'rq_disk') == 1:
bpf_text = bpf_text.replace('__RQ_DISK__', 'rq_disk')
else:
bpf_text = bpf_text.replace('__RQ_DISK__', 'q->disk')
Expand Down
2 changes: 1 addition & 1 deletion tools/biotop.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
print(bpf_text)
exit()

if BPF.kernel_struct_has_field(b'request', b'rq_disk'):
if BPF.kernel_struct_has_field(b'request', b'rq_disk') == 1:
bpf_text = bpf_text.replace('__RQ_DISK__', 'rq_disk')
else:
bpf_text = bpf_text.replace('__RQ_DISK__', 'q->disk')
Expand Down

0 comments on commit 3b69447

Please sign in to comment.