summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHe Zhe <zhe.he@windriver.com>2020-08-14 03:10:51 +0000
committerKhem Raj <raj.khem@gmail.com>2020-08-14 06:56:50 -0700
commit2353b178067522545cc0e892789d5b87c1213fdd (patch)
treee90d3a468c67a47ae4125886c02347594815959d
parentccb0a3a786e5f59ec681a013be94ddd0d9e97ec9 (diff)
downloadmeta-clang-2353b178067522545cc0e892789d5b87c1213fdd.tar.gz
bcc: biosnoop: Fix failing to attach to trace_req_completion
/usr/share/bcc/tools/biosnoop cannot attach kprobe, probe entry may not exist Traceback (most recent call last): File "/usr/share/bcc/tools/biosnoop", line 162, in <module> b.attach_kprobe(event="blk_account_io_completion", File "/usr/lib64/python3.8/site-packages/bcc/_init_.py", line 660, in attach_kprobe raise Exception("Failed to attach BPF program %s to kprobe %s" % Exception: Failed to attach BPF program b'trace_req_completion' to kprobe b'blk_account_io_completion' 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". Signed-off-by: He Zhe <zhe.he@windriver.com>
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Replace-kprobe-function-blk_account_io_completion-to.patch169
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.15.0.bb1
2 files changed, 170 insertions, 0 deletions
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Replace-kprobe-function-blk_account_io_completion-to.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Replace-kprobe-function-blk_account_io_completion-to.patch
new file mode 100644
index 0000000..ef93296
--- /dev/null
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Replace-kprobe-function-blk_account_io_completion-to.patch
@@ -0,0 +1,169 @@
1From 95c9229ea9f029a1b9e8dcbe86fc67f037c0dfa2 Mon Sep 17 00:00:00 2001
2From: Chen HaoNing <owenchen1997@yeah.net>
3Date: Wed, 1 Jul 2020 15:49:17 -0500
4Subject: [PATCH] Replace kprobe function "blk_account_io_completion" to
5 "blk_account_io_done" for kernel version >= 5.8.0
6
7The 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".
8
9Upstream-Status: Backport
10
11---
12 docs/reference_guide.md | 4 ++--
13 docs/tutorial_bcc_python_developer.md | 6 +++---
14 examples/lua/kprobe-latency.lua | 2 +-
15 examples/tracing/bitehist.py | 2 +-
16 examples/tracing/disksnoop.py | 2 +-
17 tools/biosnoop.lua | 2 +-
18 tools/biosnoop.py | 2 +-
19 tools/biotop.py | 2 +-
20 tools/old/biosnoop.py | 2 +-
21 9 files changed, 12 insertions(+), 12 deletions(-)
22
23diff --git a/docs/reference_guide.md b/docs/reference_guide.md
24index 924fa203..9eaf27a5 100644
25--- a/docs/reference_guide.md
26+++ b/docs/reference_guide.md
27@@ -1784,7 +1784,7 @@ Example:
28 b = BPF(text="""
29 BPF_HISTOGRAM(dist);
30
31-int kprobe__blk_account_io_completion(struct pt_regs *ctx, struct request *req)
32+int kprobe__blk_account_io_done(struct pt_regs *ctx, struct request *req)
33 {
34 dist.increment(bpf_log2l(req->__data_len / 1024));
35 return 0;
36@@ -1835,7 +1835,7 @@ Example:
37 b = BPF(text="""
38 BPF_HISTOGRAM(dist);
39
40-int kprobe__blk_account_io_completion(struct pt_regs *ctx, struct request *req)
41+int kprobe__blk_account_io_done(struct pt_regs *ctx, struct request *req)
42 {
43 dist.increment(req->__data_len / 1024);
44 return 0;
45diff --git a/docs/tutorial_bcc_python_developer.md b/docs/tutorial_bcc_python_developer.md
46index 0cb0e780..b3b8ed6b 100644
47--- a/docs/tutorial_bcc_python_developer.md
48+++ b/docs/tutorial_bcc_python_developer.md
49@@ -220,7 +220,7 @@ void trace_completion(struct pt_regs *ctx, struct request *req) {
50
51 b.attach_kprobe(event="blk_start_request", fn_name="trace_start")
52 b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_start")
53-b.attach_kprobe(event="blk_account_io_completion", fn_name="trace_completion")
54+b.attach_kprobe(event="blk_account_io_done", fn_name="trace_completion")
55 [...]
56 ```
57
58@@ -351,7 +351,7 @@ b = BPF(text="""
59
60 BPF_HISTOGRAM(dist);
61
62-int kprobe__blk_account_io_completion(struct pt_regs *ctx, struct request *req)
63+int kprobe__blk_account_io_done(struct pt_regs *ctx, struct request *req)
64 {
65 dist.increment(bpf_log2l(req->__data_len / 1024));
66 return 0;
67@@ -374,7 +374,7 @@ b["dist"].print_log2_hist("kbytes")
68 A recap from earlier lessons:
69
70 - ```kprobe__```: This prefix means the rest will be treated as a kernel function name that will be instrumented using kprobe.
71-- ```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()```.
72+- ```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()```.
73 - ```req->__data_len```: Dereferencing that member.
74
75 New things to learn:
76diff --git a/examples/lua/kprobe-latency.lua b/examples/lua/kprobe-latency.lua
77index 60ac2c1c..98464e5c 100644
78--- a/examples/lua/kprobe-latency.lua
79+++ b/examples/lua/kprobe-latency.lua
80@@ -30,7 +30,7 @@ local lat_map = bpf.map('array', bins)
81 local trace_start = bpf.kprobe('myprobe:blk_start_request', function (ptregs)
82 map[ptregs.parm1] = time()
83 end, false, -1, 0)
84-local trace_end = bpf.kprobe('myprobe2:blk_account_io_completion', function (ptregs)
85+local trace_end = bpf.kprobe('myprobe2:blk_account_io_done', function (ptregs)
86 -- The lines below are computing index
87 -- using log10(x)*10 = log2(x)*10/log2(10) = log2(x)*3
88 -- index = 29 ~ 1 usec
89diff --git a/examples/tracing/bitehist.py b/examples/tracing/bitehist.py
90index 4d7c7958..89ceb307 100755
91--- a/examples/tracing/bitehist.py
92+++ b/examples/tracing/bitehist.py
93@@ -25,7 +25,7 @@ b = BPF(text="""
94 BPF_HISTOGRAM(dist);
95 BPF_HISTOGRAM(dist_linear);
96
97-int kprobe__blk_account_io_completion(struct pt_regs *ctx, struct request *req)
98+int kprobe__blk_account_io_done(struct pt_regs *ctx, struct request *req)
99 {
100 dist.increment(bpf_log2l(req->__data_len / 1024));
101 dist_linear.increment(req->__data_len / 1024);
102diff --git a/examples/tracing/disksnoop.py b/examples/tracing/disksnoop.py
103index 1101e6f2..a35e1abd 100755
104--- a/examples/tracing/disksnoop.py
105+++ b/examples/tracing/disksnoop.py
106@@ -46,7 +46,7 @@ void trace_completion(struct pt_regs *ctx, struct request *req) {
107 if BPF.get_kprobe_functions(b'blk_start_request'):
108 b.attach_kprobe(event="blk_start_request", fn_name="trace_start")
109 b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_start")
110-b.attach_kprobe(event="blk_account_io_completion", fn_name="trace_completion")
111+b.attach_kprobe(event="blk_account_io_done", fn_name="trace_completion")
112
113 # header
114 print("%-18s %-2s %-7s %8s" % ("TIME(s)", "T", "BYTES", "LAT(ms)"))
115diff --git a/tools/biosnoop.lua b/tools/biosnoop.lua
116index 8d9b6a19..3e0441e2 100755
117--- a/tools/biosnoop.lua
118+++ b/tools/biosnoop.lua
119@@ -126,7 +126,7 @@ return function(BPF, utils)
120 bpf:attach_kprobe{event="blk_account_io_start", fn_name="trace_pid_start"}
121 bpf:attach_kprobe{event="blk_start_request", fn_name="trace_req_start"}
122 bpf:attach_kprobe{event="blk_mq_start_request", fn_name="trace_req_start"}
123- bpf:attach_kprobe{event="blk_account_io_completion",
124+ bpf:attach_kprobe{event="blk_account_io_done",
125 fn_name="trace_req_completion"}
126
127 print("%-14s %-14s %-6s %-7s %-2s %-9s %-7s %7s" % {"TIME(s)", "COMM", "PID",
128diff --git a/tools/biosnoop.py b/tools/biosnoop.py
129index ff9b842b..5bbc77cd 100755
130--- a/tools/biosnoop.py
131+++ b/tools/biosnoop.py
132@@ -160,7 +160,7 @@ b.attach_kprobe(event="blk_account_io_start", fn_name="trace_pid_start")
133 if BPF.get_kprobe_functions(b'blk_start_request'):
134 b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
135 b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_req_start")
136-b.attach_kprobe(event="blk_account_io_completion",
137+b.attach_kprobe(event="blk_account_io_done",
138 fn_name="trace_req_completion")
139
140 # header
141diff --git a/tools/biotop.py b/tools/biotop.py
142index cad3759a..d3a42ef7 100755
143--- a/tools/biotop.py
144+++ b/tools/biotop.py
145@@ -178,7 +178,7 @@ b.attach_kprobe(event="blk_account_io_start", fn_name="trace_pid_start")
146 if BPF.get_kprobe_functions(b'blk_start_request'):
147 b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
148 b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_req_start")
149-b.attach_kprobe(event="blk_account_io_completion",
150+b.attach_kprobe(event="blk_account_io_done",
151 fn_name="trace_req_completion")
152
153 print('Tracing... Output every %d secs. Hit Ctrl-C to end' % interval)
154diff --git a/tools/old/biosnoop.py b/tools/old/biosnoop.py
155index 37ee3f9c..847ab91b 100755
156--- a/tools/old/biosnoop.py
157+++ b/tools/old/biosnoop.py
158@@ -98,7 +98,7 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
159 b.attach_kprobe(event="blk_account_io_start", fn_name="trace_pid_start")
160 b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
161 b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_req_start")
162-b.attach_kprobe(event="blk_account_io_completion",
163+b.attach_kprobe(event="blk_account_io_done",
164 fn_name="trace_req_completion")
165
166 # header
167--
1682.17.1
169
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.15.0.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.15.0.bb
index 2df77ed..0e55384 100644
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.15.0.bb
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.15.0.bb
@@ -17,6 +17,7 @@ RDEPENDS_${PN} += "bash python3 python3-core python3-setuptools xz"
17SRC_URI = "gitsm://github.com/iovisor/bcc \ 17SRC_URI = "gitsm://github.com/iovisor/bcc \
18 file://0001-python-CMakeLists.txt-Remove-check-for-host-etc-debi.patch \ 18 file://0001-python-CMakeLists.txt-Remove-check-for-host-etc-debi.patch \
19 file://0001-tools-opensnoop-snoop-do_sys_openat2-for-kernel-v5.6.patch \ 19 file://0001-tools-opensnoop-snoop-do_sys_openat2-for-kernel-v5.6.patch \
20 file://0001-Replace-kprobe-function-blk_account_io_completion-to.patch \
20 " 21 "
21 22
22SRCREV = "e41f7a3be5c8114ef6a0990e50c2fbabea0e928e" 23SRCREV = "e41f7a3be5c8114ef6a0990e50c2fbabea0e928e"