From: Puranjay Mohan <puranjay@kernel.org>
To: bpf@vger.kernel.org, rcu@vger.kernel.org
Cc: Puranjay Mohan <puranjay@kernel.org>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Harry Yoo (Oracle)" <harry@kernel.org>,
"Paul E. McKenney" <paulmck@kernel.org>
Subject: [PATCH bpf-next v2 4/4] selftests/bpf: Add a test for bpf_call_rcu_tasks_trace()
Date: Tue, 15 Sep 2026 04:42:37 -0700 [thread overview]
Message-ID: <20260915114240.3269184-5-puranjay@kernel.org> (raw)
In-Reply-To: <20260915114240.3269184-1-puranjay@kernel.org>
Run the same functional test against the tasks trace flavour.
Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
---
.../testing/selftests/bpf/prog_tests/call_rcu.c | 12 ++++++++----
tools/testing/selftests/bpf/progs/call_rcu.c | 17 +++++++++++++++++
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/call_rcu.c b/tools/testing/selftests/bpf/prog_tests/call_rcu.c
index d21807d5d347c..7afbf79bda9a8 100644
--- a/tools/testing/selftests/bpf/prog_tests/call_rcu.c
+++ b/tools/testing/selftests/bpf/prog_tests/call_rcu.c
@@ -24,9 +24,10 @@ static bool wait_for_callbacks(struct call_rcu *skel, int expected)
return false;
}
-static void test_call_rcu_run(void)
+static void test_call_rcu_run(bool trace)
{
LIBBPF_OPTS(bpf_test_run_opts, opts);
+ struct bpf_program *prog;
struct call_rcu *skel;
struct elem elem;
__u32 key = 1;
@@ -36,7 +37,8 @@ static void test_call_rcu_run(void)
if (!ASSERT_OK_PTR(skel, "skel_open_and_load"))
return;
- err = bpf_prog_test_run_opts(bpf_program__fd(skel->progs.arm), &opts);
+ prog = trace ? skel->progs.arm_trace : skel->progs.arm;
+ err = bpf_prog_test_run_opts(bpf_program__fd(prog), &opts);
if (!ASSERT_OK(err, "test_run") || !ASSERT_EQ(opts.retval, 0, "retval"))
goto out;
@@ -55,7 +57,7 @@ static void test_call_rcu_run(void)
ASSERT_EQ(elem.val, 0, "value_cleared");
/* The head is disarmed before the callback runs, so it can be reused. */
- err = bpf_prog_test_run_opts(bpf_program__fd(skel->progs.arm), &opts);
+ err = bpf_prog_test_run_opts(bpf_program__fd(prog), &opts);
if (!ASSERT_OK(err, "test_run_again"))
goto out;
ASSERT_EQ(skel->bss->arm_err, 0, "rearm_err");
@@ -197,7 +199,9 @@ static void test_call_rcu_inner_map(void)
void test_call_rcu(void)
{
if (test__start_subtest("run"))
- test_call_rcu_run();
+ test_call_rcu_run(false);
+ if (test__start_subtest("run_tasks_trace"))
+ test_call_rcu_run(true);
if (test__start_subtest("chain"))
test_call_rcu_chain();
if (test__start_subtest("teardown"))
diff --git a/tools/testing/selftests/bpf/progs/call_rcu.c b/tools/testing/selftests/bpf/progs/call_rcu.c
index 414be225979ec..6a7b316d9ef8b 100644
--- a/tools/testing/selftests/bpf/progs/call_rcu.c
+++ b/tools/testing/selftests/bpf/progs/call_rcu.c
@@ -65,6 +65,23 @@ int arm(void *ctx)
return 0;
}
+SEC("syscall")
+int arm_trace(void *ctx)
+{
+ __u32 key = 1;
+ struct elem *e;
+
+ e = bpf_map_lookup_elem(&arr, &key);
+ if (!e)
+ return 1;
+
+ e->val = 0xdeadbeef;
+ /* No lock needed: the enclosing rcu_read_lock_trace() already blocks the grace period. */
+ arm_err = bpf_call_rcu_tasks_trace(&e->rh, &arr, reclaim);
+ busy_err = bpf_call_rcu_tasks_trace(&e->rh, &arr, reclaim);
+ return 0;
+}
+
SEC("iter/bpf_map_elem")
int dump(struct bpf_iter__bpf_map_elem *ctx)
{
--
2.53.0-Meta
next prev parent reply other threads:[~2026-09-15 11:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 11:42 [PATCH bpf-next v2 0/4] bpf: Add bpf_call_rcu() and bpf_call_rcu_tasks_trace() Puranjay Mohan
2026-09-15 11:42 ` [PATCH bpf-next v2 1/4] bpf: Add bpf_call_rcu() kfunc Puranjay Mohan
2026-09-15 12:01 ` sashiko-bot
2026-09-15 12:07 ` Puranjay Mohan
2026-09-15 11:42 ` [PATCH bpf-next v2 2/4] selftests/bpf: Add tests for bpf_call_rcu() Puranjay Mohan
2026-09-15 12:12 ` sashiko-bot
2026-09-15 11:42 ` [PATCH bpf-next v2 3/4] bpf: Add bpf_call_rcu_tasks_trace() kfunc Puranjay Mohan
2026-09-15 11:42 ` Puranjay Mohan [this message]
2026-09-15 12:09 ` [PATCH bpf-next v2 0/4] bpf: Add bpf_call_rcu() and bpf_call_rcu_tasks_trace() Puranjay Mohan
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=20260915114240.3269184-5-puranjay@kernel.org \
--to=puranjay@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=harry@kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.