* [PATCH bpf-next] selftests/bpf: add assert for user stacks in test_task_stack
@ 2023-11-12 2:30 Jordan Rome
2023-11-12 19:03 ` Stanislav Fomichev
2023-11-14 2:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Jordan Rome @ 2023-11-12 2:30 UTC (permalink / raw)
To: bpf
Cc: linux-kselftest, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Martin KaFai Lau, Kernel Team
This is a follow up to:
commit b8e3a87a627b ("bpf: Add crosstask check to __bpf_get_stack").
This test ensures that the task iterator only gets a single
user stack (for the current task).
Signed-off-by: Jordan Rome <linux@jordanrome.com>
---
tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 2 ++
tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c | 5 +++++
2 files changed, 7 insertions(+)
diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
index 4e02093c2cbe..618af9dfae9b 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
@@ -332,6 +332,8 @@ static void test_task_stack(void)
do_dummy_read(skel->progs.dump_task_stack);
do_dummy_read(skel->progs.get_task_user_stacks);
+ ASSERT_EQ(skel->bss->num_user_stacks, 1, "num_user_stacks");
+
bpf_iter_task_stack__destroy(skel);
}
diff --git a/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c b/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c
index f2b8167b72a8..442f4ca39fd7 100644
--- a/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c
+++ b/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c
@@ -35,6 +35,8 @@ int dump_task_stack(struct bpf_iter__task *ctx)
return 0;
}
+int num_user_stacks = 0;
+
SEC("iter/task")
int get_task_user_stacks(struct bpf_iter__task *ctx)
{
@@ -51,6 +53,9 @@ int get_task_user_stacks(struct bpf_iter__task *ctx)
if (res <= 0)
return 0;
+ /* Only one task, the current one, should succeed */
+ ++num_user_stacks;
+
buf_sz += res;
/* If the verifier doesn't refine bpf_get_task_stack res, and instead
--
2.39.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH bpf-next] selftests/bpf: add assert for user stacks in test_task_stack
2023-11-12 2:30 [PATCH bpf-next] selftests/bpf: add assert for user stacks in test_task_stack Jordan Rome
@ 2023-11-12 19:03 ` Stanislav Fomichev
2023-11-14 2:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Stanislav Fomichev @ 2023-11-12 19:03 UTC (permalink / raw)
To: Jordan Rome
Cc: bpf, linux-kselftest, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Martin KaFai Lau, Kernel Team
On 11/11, Jordan Rome wrote:
> This is a follow up to:
> commit b8e3a87a627b ("bpf: Add crosstask check to __bpf_get_stack").
>
> This test ensures that the task iterator only gets a single
> user stack (for the current task).
>
> Signed-off-by: Jordan Rome <linux@jordanrome.com>
Acked-by: Stanislav Fomichev <sdf@google.com>
(based on the tests passing)
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH bpf-next] selftests/bpf: add assert for user stacks in test_task_stack
2023-11-12 2:30 [PATCH bpf-next] selftests/bpf: add assert for user stacks in test_task_stack Jordan Rome
2023-11-12 19:03 ` Stanislav Fomichev
@ 2023-11-14 2:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-11-14 2:50 UTC (permalink / raw)
To: Jordan Rome
Cc: bpf, linux-kselftest, ast, daniel, andrii, martin.lau,
kernel-team
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Sat, 11 Nov 2023 18:30:10 -0800 you wrote:
> This is a follow up to:
> commit b8e3a87a627b ("bpf: Add crosstask check to __bpf_get_stack").
>
> This test ensures that the task iterator only gets a single
> user stack (for the current task).
>
> Signed-off-by: Jordan Rome <linux@jordanrome.com>
>
> [...]
Here is the summary with links:
- [bpf-next] selftests/bpf: add assert for user stacks in test_task_stack
https://git.kernel.org/bpf/bpf-next/c/727a92d62fd6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-14 2:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-12 2:30 [PATCH bpf-next] selftests/bpf: add assert for user stacks in test_task_stack Jordan Rome
2023-11-12 19:03 ` Stanislav Fomichev
2023-11-14 2:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox