Re: [PATCH bpf-next 2/2] selftests/bpf: add inline assembly helpers to access array elements

From: Barret Rhoden
Date: Wed Jan 03 2024 - 15:07:15 EST


On 1/3/24 14:51, Andrii Nakryiko wrote:
I'm curious how bpf_cmp_likely/bpf_cmp_unlikely (just applied to
bpf-next) compares to this?

these work great!

e.g.

if (bpf_cmp_likely(idx, <, NR_MAP_ELEMS))
map_elems[idx] = i;

works fine. since that's essentially the code that bpf_array_elem() was trying to replace, i'd rather just use the new bpf_cmp helpers than have the special array_elem helpers.

thanks,

barret