* [PATCH bpf-next v3] selftests/bpf: test access to ringbuf position with map pointer
@ 2026-03-31 7:04 Menglong Dong
2026-03-31 8:13 ` Leon Hwang
2026-03-31 22:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Menglong Dong @ 2026-03-31 7:04 UTC (permalink / raw)
To: ast, olsajiri
Cc: daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
john.fastabend, kpsingh, sdf, haoluo, jolsa, shuah, bpf,
linux-kselftest, linux-kernel
Add the testing to access the bpf_ringbuf with the map pointer.
"consumer_pos" and "producer_pos" is accessed in this testing. We reserve
128 bytes in the ringbuf to test the producer_pos, which should be
"128 + BPF_RINGBUF_HDR_SZ".
It will be helpful if we want to evaluate the usage of the ringbuf in bpf
prog with the consumer and producer position.
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
---
v3:
- use BPF_RINGBUF_HDR_SZ instead of 8 in check_ringbuf()
v2:
- don't set the max_entries for the ringbuf map
- add comment for the producer_pos
---
.../testing/selftests/bpf/progs/map_ptr_kern.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/tools/testing/selftests/bpf/progs/map_ptr_kern.c b/tools/testing/selftests/bpf/progs/map_ptr_kern.c
index efaf622c28dd..373c8d17ea55 100644
--- a/tools/testing/selftests/bpf/progs/map_ptr_kern.c
+++ b/tools/testing/selftests/bpf/progs/map_ptr_kern.c
@@ -647,8 +647,14 @@ static inline int check_devmap_hash(void)
return 1;
}
+struct bpf_ringbuf {
+ unsigned long consumer_pos;
+ unsigned long producer_pos;
+} __attribute__((preserve_access_index));
+
struct bpf_ringbuf_map {
struct bpf_map map;
+ struct bpf_ringbuf *rb;
} __attribute__((preserve_access_index));
struct {
@@ -659,9 +665,20 @@ static inline int check_ringbuf(void)
{
struct bpf_ringbuf_map *ringbuf = (struct bpf_ringbuf_map *)&m_ringbuf;
struct bpf_map *map = (struct bpf_map *)&m_ringbuf;
+ struct bpf_ringbuf *rb;
+ void *ptr;
VERIFY(check(&ringbuf->map, map, 0, 0, page_size));
+ ptr = bpf_ringbuf_reserve(&m_ringbuf, 128, 0);
+ VERIFY(ptr);
+
+ bpf_ringbuf_discard(ptr, 0);
+ rb = ringbuf->rb;
+ VERIFY(rb);
+ VERIFY(rb->consumer_pos == 0);
+ VERIFY(rb->producer_pos == 128 + BPF_RINGBUF_HDR_SZ);
+
return 1;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH bpf-next v3] selftests/bpf: test access to ringbuf position with map pointer
2026-03-31 7:04 [PATCH bpf-next v3] selftests/bpf: test access to ringbuf position with map pointer Menglong Dong
@ 2026-03-31 8:13 ` Leon Hwang
2026-03-31 22:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Leon Hwang @ 2026-03-31 8:13 UTC (permalink / raw)
To: Menglong Dong, ast, olsajiri
Cc: daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
john.fastabend, kpsingh, sdf, haoluo, jolsa, shuah, bpf,
linux-kselftest, linux-kernel
On 31/3/26 15:04, Menglong Dong wrote:
> Add the testing to access the bpf_ringbuf with the map pointer.
> "consumer_pos" and "producer_pos" is accessed in this testing. We reserve
> 128 bytes in the ringbuf to test the producer_pos, which should be
> "128 + BPF_RINGBUF_HDR_SZ".
>
> It will be helpful if we want to evaluate the usage of the ringbuf in bpf
> prog with the consumer and producer position.
>
> Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
> Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
> Acked-by: Jiri Olsa <jolsa@kernel.org>
lgtm,
Acked-by: Leon Hwang <leon.hwang@linux.dev>
[...]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next v3] selftests/bpf: test access to ringbuf position with map pointer
2026-03-31 7:04 [PATCH bpf-next v3] selftests/bpf: test access to ringbuf position with map pointer Menglong Dong
2026-03-31 8:13 ` Leon Hwang
@ 2026-03-31 22:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-31 22:50 UTC (permalink / raw)
To: Menglong Dong
Cc: ast, olsajiri, daniel, andrii, martin.lau, eddyz87, song,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa, shuah,
bpf, linux-kselftest, linux-kernel
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Tue, 31 Mar 2026 15:04:34 +0800 you wrote:
> Add the testing to access the bpf_ringbuf with the map pointer.
> "consumer_pos" and "producer_pos" is accessed in this testing. We reserve
> 128 bytes in the ringbuf to test the producer_pos, which should be
> "128 + BPF_RINGBUF_HDR_SZ".
>
> It will be helpful if we want to evaluate the usage of the ringbuf in bpf
> prog with the consumer and producer position.
>
> [...]
Here is the summary with links:
- [bpf-next,v3] selftests/bpf: test access to ringbuf position with map pointer
https://git.kernel.org/bpf/bpf-next/c/3e6475dc6085
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:[~2026-03-31 22:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31 7:04 [PATCH bpf-next v3] selftests/bpf: test access to ringbuf position with map pointer Menglong Dong
2026-03-31 8:13 ` Leon Hwang
2026-03-31 22: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