From: Yucong Sun <fallentree@fb.com>
To: <bpf@vger.kernel.org>
Cc: <andrii@kernel.org>, <sunyucong@gmail.com>
Subject: [PATCH bpf-next v6 09/14] selftests/bpf: Make uprobe tests use different attach functions.
Date: Wed, 6 Oct 2021 11:56:14 -0700 [thread overview]
Message-ID: <20211006185619.364369-10-fallentree@fb.com> (raw)
In-Reply-To: <20211006185619.364369-1-fallentree@fb.com>
From: Yucong Sun <sunyucong@gmail.com>
Using same address on different processes of the same binary often fail
with EINVAL, this patch make these tests use distinct methods, so they
can run in parallel.
Signed-off-by: Yucong Sun <sunyucong@gmail.com>
---
tools/testing/selftests/bpf/prog_tests/attach_probe.c | 8 ++++++--
tools/testing/selftests/bpf/prog_tests/bpf_cookie.c | 8 ++++++--
tools/testing/selftests/bpf/prog_tests/task_pt_regs.c | 8 ++++++--
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/attach_probe.c b/tools/testing/selftests/bpf/prog_tests/attach_probe.c
index 6c511dcd1465..eff36ba9c148 100644
--- a/tools/testing/selftests/bpf/prog_tests/attach_probe.c
+++ b/tools/testing/selftests/bpf/prog_tests/attach_probe.c
@@ -5,6 +5,10 @@
/* this is how USDT semaphore is actually defined, except volatile modifier */
volatile unsigned short uprobe_ref_ctr __attribute__((unused)) __attribute((section(".probes")));
+static int method() {
+ return get_base_addr();
+}
+
void test_attach_probe(void)
{
DECLARE_LIBBPF_OPTS(bpf_uprobe_opts, uprobe_opts);
@@ -33,7 +37,7 @@ void test_attach_probe(void)
if (CHECK(base_addr < 0, "get_base_addr",
"failed to find base addr: %zd", base_addr))
return;
- uprobe_offset = get_uprobe_offset(&get_base_addr, base_addr);
+ uprobe_offset = get_uprobe_offset(&method, base_addr);
ref_ctr_offset = get_rel_offset((uintptr_t)&uprobe_ref_ctr);
if (!ASSERT_GE(ref_ctr_offset, 0, "ref_ctr_offset"))
@@ -98,7 +102,7 @@ void test_attach_probe(void)
goto cleanup;
/* trigger & validate uprobe & uretprobe */
- get_base_addr();
+ method();
if (CHECK(skel->bss->uprobe_res != 3, "check_uprobe_res",
"wrong uprobe res: %d\n", skel->bss->uprobe_res))
diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
index 19c9f7b53cfa..5ebd8ba988e2 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
@@ -8,6 +8,10 @@
#include <test_progs.h>
#include "test_bpf_cookie.skel.h"
+static int method() {
+ return get_base_addr();
+}
+
static void kprobe_subtest(struct test_bpf_cookie *skel)
{
DECLARE_LIBBPF_OPTS(bpf_kprobe_opts, opts);
@@ -66,7 +70,7 @@ static void uprobe_subtest(struct test_bpf_cookie *skel)
ssize_t base_addr;
base_addr = get_base_addr();
- uprobe_offset = get_uprobe_offset(&get_base_addr, base_addr);
+ uprobe_offset = get_uprobe_offset(&method, base_addr);
/* attach two uprobes */
opts.bpf_cookie = 0x100;
@@ -99,7 +103,7 @@ static void uprobe_subtest(struct test_bpf_cookie *skel)
goto cleanup;
/* trigger uprobe && uretprobe */
- get_base_addr();
+ method();
ASSERT_EQ(skel->bss->uprobe_res, 0x100 | 0x200, "uprobe_res");
ASSERT_EQ(skel->bss->uretprobe_res, 0x1000 | 0x2000, "uretprobe_res");
diff --git a/tools/testing/selftests/bpf/prog_tests/task_pt_regs.c b/tools/testing/selftests/bpf/prog_tests/task_pt_regs.c
index 37c20b5ffa70..4d2f1435be90 100644
--- a/tools/testing/selftests/bpf/prog_tests/task_pt_regs.c
+++ b/tools/testing/selftests/bpf/prog_tests/task_pt_regs.c
@@ -3,6 +3,10 @@
#include <test_progs.h>
#include "test_task_pt_regs.skel.h"
+static int method() {
+ return get_base_addr();
+}
+
void test_task_pt_regs(void)
{
struct test_task_pt_regs *skel;
@@ -14,7 +18,7 @@ void test_task_pt_regs(void)
base_addr = get_base_addr();
if (!ASSERT_GT(base_addr, 0, "get_base_addr"))
return;
- uprobe_offset = get_uprobe_offset(&get_base_addr, base_addr);
+ uprobe_offset = get_uprobe_offset(&method, base_addr);
skel = test_task_pt_regs__open_and_load();
if (!ASSERT_OK_PTR(skel, "skel_open"))
@@ -32,7 +36,7 @@ void test_task_pt_regs(void)
skel->links.handle_uprobe = uprobe_link;
/* trigger & validate uprobe */
- get_base_addr();
+ method();
if (!ASSERT_EQ(skel->bss->uprobe_res, 1, "check_uprobe_res"))
goto cleanup;
--
2.30.2
next prev parent reply other threads:[~2021-10-06 18:56 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-06 18:56 [PATCH bpf-next v6 00/14] selftests/bpf: Add parallelism to test_progs Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 01/14] " Yucong Sun
2021-10-08 22:26 ` Andrii Nakryiko
2021-10-06 18:56 ` [PATCH bpf-next v6 02/14] selftests/bpf: Allow some tests to be executed in sequence Yucong Sun
2021-10-08 22:26 ` Andrii Nakryiko
2021-10-08 23:06 ` sunyucong
2021-10-09 3:17 ` Andrii Nakryiko
2021-10-06 18:56 ` [PATCH bpf-next v6 03/14] selftests/bpf: disable perf rate limiting when running tests Yucong Sun
2021-10-08 22:26 ` Andrii Nakryiko
2021-10-06 18:56 ` [PATCH bpf-next v6 04/14] selftests/bpf: add per worker cgroup suffix Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 05/14] selftests/bpf: adding read_perf_max_sample_freq() helper Yucong Sun
2021-10-08 22:27 ` Andrii Nakryiko
2021-10-08 22:49 ` sunyucong
2022-03-08 20:22 ` sunyucong
2021-10-06 18:56 ` [PATCH bpf-next v6 06/14] selftests/bpf: fix race condition in enable_stats Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 07/14] selftests/bpf: make cgroup_v1v2 use its own port Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 08/14] selftests/bpf: adding a namespace reset for tc_redirect Yucong Sun
2021-10-08 22:27 ` Andrii Nakryiko
2021-10-08 23:07 ` sunyucong
2021-10-06 18:56 ` Yucong Sun [this message]
2021-10-08 22:27 ` [PATCH bpf-next v6 09/14] selftests/bpf: Make uprobe tests use different attach functions Andrii Nakryiko
2021-10-08 22:46 ` sunyucong
2021-10-09 3:13 ` Andrii Nakryiko
2021-10-06 18:56 ` [PATCH bpf-next v6 10/14] selftests/bpf: adding pid filtering for atomics test Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 11/14] selftests/bpf: adding random delay for send_signal test Yucong Sun
2021-10-08 22:27 ` Andrii Nakryiko
2021-10-06 18:56 ` [PATCH bpf-next v6 12/14] selftests/bpf: Fix pid check in fexit_sleep test Yucong Sun
2021-10-06 18:56 ` [PATCH bpf-next v6 13/14] selftests/bpf: increase loop count for perf_branches Yucong Sun
2021-10-08 22:27 ` Andrii Nakryiko
2021-10-08 22:57 ` sunyucong
2021-10-06 18:56 ` [PATCH bpf-next v6 14/14] selfetest/bpf: make some tests serial Yucong Sun
2021-10-08 22:27 ` Andrii Nakryiko
2021-10-08 22:55 ` sunyucong
2021-10-09 3:14 ` Andrii Nakryiko
2021-10-08 22:26 ` [PATCH bpf-next v6 00/14] selftests/bpf: Add parallelism to test_progs Andrii Nakryiko
2021-10-08 22:42 ` Andrii Nakryiko
2021-10-08 23:37 ` Steven Rostedt
2021-10-09 3:20 ` Andrii Nakryiko
2021-10-09 3:28 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211006185619.364369-10-fallentree@fb.com \
--to=fallentree@fb.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sunyucong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).