From: "Emil Tsalapatis" <emil@etsalapatis.com>
To: <bot+bpf-ci@kernel.org>, <emil@etsalapatis.com>, <bpf@vger.kernel.org>
Cc: <ast@kernel.org>, <andrii@kernel.org>, <memxor@gmail.com>,
<daniel@iogearbox.net>, <eddyz87@gmail.com>, <song@kernel.org>,
<mattbobrowski@google.com>, <martin.lau@kernel.org>,
<yonghong.song@linux.dev>, <clm@meta.com>,
<ihor.solodrai@linux.dev>
Subject: Re: [RESEND PATCH bpf-next 2/2] selftests/bpf: libarena: Add Lev-Chase queue data structure
Date: Tue, 12 May 2026 16:20:07 -0400 [thread overview]
Message-ID: <DIGZ6H0UY24G.18SRE0QFZXPIT@etsalapatis.com> (raw)
In-Reply-To: <c4601c9bc4a124aaaa0c981923fb415af769be9d59ab9a9acf5505426ebbc130@mail.kernel.org>
On Mon May 11, 2026 at 6:12 PM EDT, bot+bpf-ci wrote:
>> The data structure exposes three main calls. two of them are available to
>> the thread owning the queue and one available to all threads in the program:
>>
>> lvqueue_owner_push(): Push an item to the top of the lvqueue.
>> lvqueue_owner_pop(): Pop an item from the top of the lvqueue.
>> lvqueue_steal(): Steal a thread from the bottom of the lvqueue from
>> any thread.
>
> The API names in the commit message don't match the actual functions.
> Looking at tools/testing/selftests/bpf/libarena/include/libarena/lvqueue.h:
>
> int lvq_owner_push(lv_queue_t *lvq, u64 val);
> int lvq_owner_pop(lv_queue_t *lvq, u64 *val);
> int lvq_steal(lv_queue_t *lvq, u64 *val);
>
> The functions use 'lvq_' prefix, not 'lvqueue_'.
>
> Also, the commit message describes push/pop as operating on the 'top' and
> steal as operating on the 'bottom', while the code follows the standard
> Chase-Lev convention where the owner operates at 'bottom' and stealers at
> 'top'. In lvq_owner_push():
>
> b = smp_load_acquire(&lvq->bottom);
> ...
> lv_arr_put(lvq->cur, b, val);
> smp_store_release(&lvq->bottom, b + 1);
>
> And in lvq_steal():
>
> t = smp_load_acquire(&lvq->top);
> ...
> if (cmpxchg(&lvq->top, t, t + 1) != t)
>
> Could the commit message use the correct API names and clarify the
> terminology to match the variable names in the code?
Ack, will clean up.
>
> [ ... ]
>
>> diff --git a/tools/testing/selftests/bpf/libarena/src/lvqueue.bpf.c b/tools/testing/selftests/bpf/libarena/src/lvqueue.bpf.c
>> new file mode 100644
>> index 000000000000..b93c4f9d1c92
>> --- /dev/null
>> +++ b/tools/testing/selftests/bpf/libarena/src/lvqueue.bpf.c
>> @@ -0,0 +1,241 @@
>
> [ ... ]
>
>> +static inline
>> +int lvq_order_init(lv_queue_t *lvq __arg_arena, int order)
>> +{
>> + lv_arr_t *arr = &lvq->arr[order];
>> +
>> + if (unlikely(!lvq))
>> + return -EINVAL;
>> +
>> + if (order >= LV_ARR_ORDERS)
>> + return -E2BIG;
>
> The pointer 'arr' is computed from '&lvq->arr[order]' before both the NULL
> check and the bounds check. Although this pointer is never dereferenced on
> the failure paths, forming a pointer more than one past the end of an array
> is undefined behavior per C17 6.5.6p8.
>
> This can occur when lvq_owner_push() calls lvq_order_init(lvq, arr->order + 1)
> with arr->order + 1 == LV_ARR_ORDERS.
>
> Since this function is marked '__arg_arena' and invoked by BPF programs, the
> verifier may reject the out-of-bounds pointer arithmetic. Should the 'arr'
> assignment be moved after both checks?
>
Will move the pointer calculation to its proper place, thought the bit
about verifier failures is completely extrapolated - this is an arena,
of course we can do any pointer arithmetic we like.
> [ ... ]
>
>
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
>
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/25699461713
next prev parent reply other threads:[~2026-05-12 20:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 21:40 [RESEND PATCH bpf-next 0/2] selftests/bpf: libarena: Add initial data structures Emil Tsalapatis
2026-05-11 21:40 ` [RESEND PATCH bpf-next 1/2] selftests/bpf: libarena: Add rbtree data structure Emil Tsalapatis
2026-05-11 22:24 ` bot+bpf-ci
2026-05-12 20:18 ` Emil Tsalapatis
2026-05-13 0:42 ` sashiko-bot
2026-05-11 21:41 ` [RESEND PATCH bpf-next 2/2] selftests/bpf: libarena: Add Lev-Chase queue " Emil Tsalapatis
2026-05-11 22:12 ` bot+bpf-ci
2026-05-12 20:20 ` Emil Tsalapatis [this message]
2026-05-13 2:23 ` sashiko-bot
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=DIGZ6H0UY24G.18SRE0QFZXPIT@etsalapatis.com \
--to=emil@etsalapatis.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=martin.lau@kernel.org \
--cc=mattbobrowski@google.com \
--cc=memxor@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox