Skip to content

Commit

Permalink
Fix backend io collector post 5.x kernel upgrade (#18) (#20)
Browse files Browse the repository at this point in the history
* Fix backend io collector post 5.x kernel upgrade

* Check for kprobe existence before attaching

* Fix lint 1
  • Loading branch information
prashks authored and Sebastien Roy committed Dec 6, 2019
1 parent 8049b85 commit 247f1cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bpf/stbtrace/io.st
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ int disk_io_done(struct pt_regs *ctx, struct request *reqp)
"""
b = BPF(text=bpf_text)

b.attach_kprobe(event="blk_start_request", fn_name="disk_io_start")
if BPF.get_kprobe_functions(b'blk_start_request'):
b.attach_kprobe(event="blk_start_request", fn_name="disk_io_start")
b.attach_kprobe(event="blk_mq_start_request", fn_name="disk_io_start")
b.attach_kprobe(event="blk_account_io_completion", fn_name="disk_io_done")

Expand Down
8 changes: 6 additions & 2 deletions cmd/estat.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,12 @@ class Args:
line + "'")
probe_type = probe_spec[0]
if probe_type == "kprobe":
b.attach_kprobe(event=probe_spec[1], fn_name=probe_spec[2])
probes.add("p_" + probe_spec[1] + "_bcc_" + str(os.getpid()))
if BPF.get_kprobe_functions(probe_spec[1]):
b.attach_kprobe(event=probe_spec[1], fn_name=probe_spec[2])
probes.add("p_" + probe_spec[1] + "_bcc_" + str(os.getpid()))
else:
print("WARNING: {}: {} - not found"
.format(probe_type, probe_spec[1]))
elif probe_type == "kretprobe":
b.attach_kretprobe(event=probe_spec[1], fn_name=probe_spec[2],
maxactive=MAXACTIVE)
Expand Down

0 comments on commit 247f1cc

Please sign in to comment.