samples/bpf: use kprobe and urandom_read_iter

14c174633f34 ("random: remove unused tracepoints") removed all the
tracepoints from drivers/char/random.c, one of which,
random:urandom_read.

1b388e7765f2 ("random: convert to using fops->read_iter()") replaced
kernel function urandom_read with urandom_read_iter.
Therefore, kprobe on urandom_read is not working any more:

Fix breakage by replacing tracepoint with kprobing and replacing
urandom_read with urandom_read_iter.

TEST PLAN:
PASS: build-pkgs -c -p linux
PASS: build-pkgs -c -p linux-rt
PASS: make -j 16 M=samples/bpf
PASS: sudo samples/bpf/test_overhead

Closes-Bug: 1999136

Change-Id: Idac88160050abaa7ebe7098a54792650f2d691cd
Signed-off-by: Wentao Zhang <wentao.zhang@windriver.com>
This commit is contained in:
Wentao Zhang 2022-12-08 11:18:29 +08:00
parent 6bc25e5239
commit 8ae537061f
4 changed files with 136 additions and 0 deletions

View File

@ -0,0 +1,67 @@
From 3e65002714f5b4d20ab30b01a58ddb0e243a74ac Mon Sep 17 00:00:00 2001
From: Wentao Zhang <wentao.zhang@windriver.com>
Date: Thu, 8 Dec 2022 11:55:17 +0800
Subject: [PATCH] samples/bpf: use kprobe and urandom_read_iter
14c174633f34 ("random: remove unused tracepoints") removed all the
tracepoints from drivers/char/random.c, one of which,
random:urandom_read.
1b388e7765f2 ("random: convert to using fops->read_iter()") replaced
kernel function urandom_read with urandom_read_iter.
Therefore, kprobe on urandom_read is not working any more.
Use kprobing to replace the tracepoint and use urandom_read_iter
to replace urandom_read to fix the breakage.
Fixes: 1b388e7765f2 ("random: convert to using fops->read_iter()")
Fixes: 14c174633f34 ("random: remove unused tracepoints")
Signed-off-by: Wentao Zhang <wentao.zhang@windriver.com>
---
samples/bpf/test_overhead_kprobe_kern.c | 2 +-
samples/bpf/test_overhead_raw_tp_kern.c | 2 +-
samples/bpf/test_overhead_tp_kern.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/samples/bpf/test_overhead_kprobe_kern.c b/samples/bpf/test_overhead_kprobe_kern.c
index f6d593e47..2dcb4ba0e 100644
--- a/samples/bpf/test_overhead_kprobe_kern.c
+++ b/samples/bpf/test_overhead_kprobe_kern.c
@@ -38,7 +38,7 @@ int prog(struct pt_regs *ctx)
return 0;
}
-SEC("kprobe/urandom_read")
+SEC("kprobe/urandom_read_iter")
int prog2(struct pt_regs *ctx)
{
return 0;
diff --git a/samples/bpf/test_overhead_raw_tp_kern.c b/samples/bpf/test_overhead_raw_tp_kern.c
index 8763181a3..34a5aba61 100644
--- a/samples/bpf/test_overhead_raw_tp_kern.c
+++ b/samples/bpf/test_overhead_raw_tp_kern.c
@@ -9,7 +9,7 @@ int prog(struct bpf_raw_tracepoint_args *ctx)
return 0;
}
-SEC("raw_tracepoint/urandom_read")
+SEC("kprobe/urandom_read_iter")
int prog2(struct bpf_raw_tracepoint_args *ctx)
{
return 0;
diff --git a/samples/bpf/test_overhead_tp_kern.c b/samples/bpf/test_overhead_tp_kern.c
index eaa32693f..d5f7abb4c 100644
--- a/samples/bpf/test_overhead_tp_kern.c
+++ b/samples/bpf/test_overhead_tp_kern.c
@@ -28,7 +28,7 @@ struct urandom_read {
int pool_left;
int input_left;
};
-SEC("tracepoint/random/urandom_read")
+SEC("kprobe/urandom_read_iter")
int prog2(struct urandom_read *ctx)
{
return 0;
--
2.25.1

View File

@ -34,3 +34,4 @@
0036-xfs-open-code-ioend-needs-workqueue-helper.patch 0036-xfs-open-code-ioend-needs-workqueue-helper.patch
0037-xfs-drop-unused-ioend-private-merge-and-setfilesize-.patch 0037-xfs-drop-unused-ioend-private-merge-and-setfilesize-.patch
0038-xfs-drop-unnecessary-setfilesize-helper.patch 0038-xfs-drop-unnecessary-setfilesize-helper.patch
0039-samples-bpf-use-kprobe-and-urandom_read_iter.patch

View File

@ -0,0 +1,67 @@
From 3e65002714f5b4d20ab30b01a58ddb0e243a74ac Mon Sep 17 00:00:00 2001
From: Wentao Zhang <wentao.zhang@windriver.com>
Date: Thu, 8 Dec 2022 11:55:17 +0800
Subject: [PATCH] samples/bpf: use kprobe and urandom_read_iter
14c174633f34 ("random: remove unused tracepoints") removed all the
tracepoints from drivers/char/random.c, one of which,
random:urandom_read.
1b388e7765f2 ("random: convert to using fops->read_iter()") replaced
kernel function urandom_read with urandom_read_iter.
Therefore, kprobe on urandom_read is not working any more.
Use kprobing to replace the tracepoint and use urandom_read_iter
to replace urandom_read to fix the breakage.
Fixes: 1b388e7765f2 ("random: convert to using fops->read_iter()")
Fixes: 14c174633f34 ("random: remove unused tracepoints")
Signed-off-by: Wentao Zhang <wentao.zhang@windriver.com>
---
samples/bpf/test_overhead_kprobe_kern.c | 2 +-
samples/bpf/test_overhead_raw_tp_kern.c | 2 +-
samples/bpf/test_overhead_tp_kern.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/samples/bpf/test_overhead_kprobe_kern.c b/samples/bpf/test_overhead_kprobe_kern.c
index f6d593e47..2dcb4ba0e 100644
--- a/samples/bpf/test_overhead_kprobe_kern.c
+++ b/samples/bpf/test_overhead_kprobe_kern.c
@@ -38,7 +38,7 @@ int prog(struct pt_regs *ctx)
return 0;
}
-SEC("kprobe/urandom_read")
+SEC("kprobe/urandom_read_iter")
int prog2(struct pt_regs *ctx)
{
return 0;
diff --git a/samples/bpf/test_overhead_raw_tp_kern.c b/samples/bpf/test_overhead_raw_tp_kern.c
index 8763181a3..34a5aba61 100644
--- a/samples/bpf/test_overhead_raw_tp_kern.c
+++ b/samples/bpf/test_overhead_raw_tp_kern.c
@@ -9,7 +9,7 @@ int prog(struct bpf_raw_tracepoint_args *ctx)
return 0;
}
-SEC("raw_tracepoint/urandom_read")
+SEC("kprobe/urandom_read_iter")
int prog2(struct bpf_raw_tracepoint_args *ctx)
{
return 0;
diff --git a/samples/bpf/test_overhead_tp_kern.c b/samples/bpf/test_overhead_tp_kern.c
index eaa32693f..d5f7abb4c 100644
--- a/samples/bpf/test_overhead_tp_kern.c
+++ b/samples/bpf/test_overhead_tp_kern.c
@@ -28,7 +28,7 @@ struct urandom_read {
int pool_left;
int input_left;
};
-SEC("tracepoint/random/urandom_read")
+SEC("kprobe/urandom_read_iter")
int prog2(struct urandom_read *ctx)
{
return 0;
--
2.25.1

View File

@ -33,3 +33,4 @@
0035-xfs-open-code-ioend-needs-workqueue-helper.patch 0035-xfs-open-code-ioend-needs-workqueue-helper.patch
0036-xfs-drop-unused-ioend-private-merge-and-setfilesize-.patch 0036-xfs-drop-unused-ioend-private-merge-and-setfilesize-.patch
0037-xfs-drop-unnecessary-setfilesize-helper.patch 0037-xfs-drop-unnecessary-setfilesize-helper.patch
0038-samples-bpf-use-kprobe-and-urandom_read_iter.patch