From: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
To: "Emil Tsalapatis" <emil@etsalapatis.com>, <bpf@vger.kernel.org>
Cc: <ast@kernel.org>, <andrii@kernel.org>, <memxor@gmail.com>,
<daniel@iogearbox.net>, <eddyz87@gmail.com>,
<mattbobrowski@google.com>, <song@kernel.org>
Subject: Re: [PATCH bpf-next v3 1/5] selftests/bpf: libarena: Fix can-loop zero variable definition
Date: Sun, 05 Jul 2026 08:34:15 +0200 [thread overview]
Message-ID: <DJQFFKHUGET8.2D2JRDZA26OIS@gmail.com> (raw)
In-Reply-To: <20260701225034.12628-2-emil@etsalapatis.com>
On Thu Jul 2, 2026 at 12:50 AM CEST, Emil Tsalapatis wrote:
> BPF can_loop based loops require the index variable to stay imprecise.
> This means we must initialize them from a currently imprecise variable
> instead of directly assigning 0 to them, like so:
>
> static volatile u32 zero = 0;
>
> for (i = zero; i < NUM_LOOPS; i++) {
> /* loop body */
> }
>
> The libarena implementation of this technique is currently faulty. For
> the technique to work, the variable must not be in a map. This includes
> the .rodata DATASEC map used for const variables. However, libarena
> still defines the zero variable as constant.
>
> Modify the zero variable definition into a volatile variable. This
> change adds a complication caused by the compiler optimizing array
> derefences from
>
> for (i = zero; i < NUM_LOOPS; i++) {
> val = *(ptr + i);
> }
>
> into
>
> for (i = zero; i < NUM_LOOPS; i++) {
> val = *ptr++;
> }
>
> and causing verification failures. Use the barrier_var() clobber macro
> to prevent this optimization from taking place. Using barrier_var() is
> the only way to break the optimization, as annotating the index as
> volatile does not suffice.
>
> After that, remove the bpf_for() invocations introduced in libarena for
> parallel spmc testing.
>
> Reported-by: Eduard Zingerman <eddyz87@gmail.com>
> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
> Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>
> ---
> .../selftests/bpf/libarena/include/libarena/common.h | 2 +-
> .../bpf/libarena/selftests/test_asan_buddy.bpf.c | 8 ++++++-
No such file exists, did you forget to send the renaming patch from
st_asan_buddy to test_asan_buddy ordered before this one?
Please respin. Looks good otherwise.
pw-bot: cr
next prev parent reply other threads:[~2026-07-05 6:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 22:50 [PATCH bpf-next v3 0/5] selftests/bpf: libarena cleanup and bitmap struct Emil Tsalapatis
2026-07-01 22:50 ` [PATCH bpf-next v3 1/5] selftests/bpf: libarena: Fix can-loop zero variable definition Emil Tsalapatis
2026-07-01 23:35 ` bot+bpf-ci
2026-07-05 6:34 ` Kumar Kartikeya Dwivedi [this message]
2026-07-06 15:31 ` Emil Tsalapatis
2026-07-01 22:50 ` [PATCH bpf-next v3 2/5] selftests/bpf: libarena: Clean up allocation state before buddy tests Emil Tsalapatis
2026-07-01 22:50 ` [PATCH bpf-next v3 3/5] selftests/bpf: Add arena-based bitmap data structure Emil Tsalapatis
2026-07-01 23:35 ` bot+bpf-ci
2026-07-01 22:50 ` [PATCH bpf-next v3 4/5] selftests/bpf: libarena: Add bitmap selftests Emil Tsalapatis
2026-07-01 22:50 ` [PATCH bpf-next v3 5/5] selftests/bpf: libarena: Add parallel bitmap selftest Emil Tsalapatis
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=DJQFFKHUGET8.2D2JRDZA26OIS@gmail.com \
--to=memxor@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=mattbobrowski@google.com \
--cc=song@kernel.org \
/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