Skip to content

Commit

Permalink
Replace kprobe function "blk_account_io_completion" to "blk_account_i…
Browse files Browse the repository at this point in the history
…o_done" for kernel version >= 5.8.0

The kernel function "blk_account_io_completion" is not available anymore as attach point of Kprobe as of kernel version 5.8.0. Therefore, after discussions, we decided to use function "blk_account_io_done" instead in every kprobe attachment to "blk_account_io_completion".
  • Loading branch information
owen-chenhn authored and yonghong-song committed Jul 8, 2020
1 parent d4f6a16 commit 95c9229
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/reference_guide.md
Expand Up @@ -1784,7 +1784,7 @@ Example:
b = BPF(text="""
BPF_HISTOGRAM(dist);
int kprobe__blk_account_io_completion(struct pt_regs *ctx, struct request *req)
int kprobe__blk_account_io_done(struct pt_regs *ctx, struct request *req)
{
dist.increment(bpf_log2l(req->__data_len / 1024));
return 0;
Expand Down Expand Up @@ -1835,7 +1835,7 @@ Example:
b = BPF(text="""
BPF_HISTOGRAM(dist);
int kprobe__blk_account_io_completion(struct pt_regs *ctx, struct request *req)
int kprobe__blk_account_io_done(struct pt_regs *ctx, struct request *req)
{
dist.increment(req->__data_len / 1024);
return 0;
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorial_bcc_python_developer.md
Expand Up @@ -220,7 +220,7 @@ void trace_completion(struct pt_regs *ctx, struct request *req) {

b.attach_kprobe(event="blk_start_request", fn_name="trace_start")
b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_start")
b.attach_kprobe(event="blk_account_io_completion", fn_name="trace_completion")
b.attach_kprobe(event="blk_account_io_done", fn_name="trace_completion")
[...]
```

Expand Down Expand Up @@ -351,7 +351,7 @@ b = BPF(text="""
BPF_HISTOGRAM(dist);
int kprobe__blk_account_io_completion(struct pt_regs *ctx, struct request *req)
int kprobe__blk_account_io_done(struct pt_regs *ctx, struct request *req)
{
dist.increment(bpf_log2l(req->__data_len / 1024));
return 0;
Expand All @@ -374,7 +374,7 @@ b["dist"].print_log2_hist("kbytes")
A recap from earlier lessons:

- ```kprobe__```: This prefix means the rest will be treated as a kernel function name that will be instrumented using kprobe.
- ```struct pt_regs *ctx, struct request *req```: Arguments to kprobe. The ```ctx``` is registers and BPF context, the ```req``` is the first argument to the instrumented function: ```blk_account_io_completion()```.
- ```struct pt_regs *ctx, struct request *req```: Arguments to kprobe. The ```ctx``` is registers and BPF context, the ```req``` is the first argument to the instrumented function: ```blk_account_io_done()```.
- ```req->__data_len```: Dereferencing that member.

New things to learn:
Expand Down
2 changes: 1 addition & 1 deletion examples/lua/kprobe-latency.lua
Expand Up @@ -30,7 +30,7 @@ local lat_map = bpf.map('array', bins)
local trace_start = bpf.kprobe('myprobe:blk_start_request', function (ptregs)
map[ptregs.parm1] = time()
end, false, -1, 0)
local trace_end = bpf.kprobe('myprobe2:blk_account_io_completion', function (ptregs)
local trace_end = bpf.kprobe('myprobe2:blk_account_io_done', function (ptregs)
-- The lines below are computing index
-- using log10(x)*10 = log2(x)*10/log2(10) = log2(x)*3
-- index = 29 ~ 1 usec
Expand Down
2 changes: 1 addition & 1 deletion examples/tracing/bitehist.py
Expand Up @@ -25,7 +25,7 @@
BPF_HISTOGRAM(dist);
BPF_HISTOGRAM(dist_linear);
int kprobe__blk_account_io_completion(struct pt_regs *ctx, struct request *req)
int kprobe__blk_account_io_done(struct pt_regs *ctx, struct request *req)
{
dist.increment(bpf_log2l(req->__data_len / 1024));
dist_linear.increment(req->__data_len / 1024);
Expand Down
2 changes: 1 addition & 1 deletion examples/tracing/disksnoop.py
Expand Up @@ -46,7 +46,7 @@
if BPF.get_kprobe_functions(b'blk_start_request'):
b.attach_kprobe(event="blk_start_request", fn_name="trace_start")
b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_start")
b.attach_kprobe(event="blk_account_io_completion", fn_name="trace_completion")
b.attach_kprobe(event="blk_account_io_done", fn_name="trace_completion")

# header
print("%-18s %-2s %-7s %8s" % ("TIME(s)", "T", "BYTES", "LAT(ms)"))
Expand Down
2 changes: 1 addition & 1 deletion tools/biosnoop.lua
Expand Up @@ -126,7 +126,7 @@ return function(BPF, utils)
bpf:attach_kprobe{event="blk_account_io_start", fn_name="trace_pid_start"}
bpf:attach_kprobe{event="blk_start_request", fn_name="trace_req_start"}
bpf:attach_kprobe{event="blk_mq_start_request", fn_name="trace_req_start"}
bpf:attach_kprobe{event="blk_account_io_completion",
bpf:attach_kprobe{event="blk_account_io_done",
fn_name="trace_req_completion"}

print("%-14s %-14s %-6s %-7s %-2s %-9s %-7s %7s" % {"TIME(s)", "COMM", "PID",
Expand Down
2 changes: 1 addition & 1 deletion tools/biosnoop.py
Expand Up @@ -160,7 +160,7 @@
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_completion",
b.attach_kprobe(event="blk_account_io_done",
fn_name="trace_req_completion")

# header
Expand Down
2 changes: 1 addition & 1 deletion tools/biotop.py
Expand Up @@ -178,7 +178,7 @@ def signal_ignore(signal_value, frame):
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_completion",
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)
Expand Down
2 changes: 1 addition & 1 deletion tools/old/biosnoop.py
Expand Up @@ -98,7 +98,7 @@
b.attach_kprobe(event="blk_account_io_start", fn_name="trace_pid_start")
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_completion",
b.attach_kprobe(event="blk_account_io_done",
fn_name="trace_req_completion")

# header
Expand Down

0 comments on commit 95c9229

Please sign in to comment.