Re: [PATCH bpf-next v5 1/2] bpf: htab: Split htab_elem_lru and htab_elem_pcpu off of htab_elem
From: Alexei Starovoitov
Date: Sun Sep 20 2026 - 20:51:22 EST
On Sun, Sep 20, 2026 at 05:22 PM T.J. Mercier <tjmercier@xxxxxxxxxx> wrote:
> - if ((u64)attr->key_size + attr->value_size >= KMALLOC_MAX_SIZE -
> - sizeof(struct htab_elem))
> + if (round_up((u64)attr->key_size, 8) + round_up((u64)attr->value_size, 8) >=
> + KMALLOC_MAX_SIZE - sizeof(union htab_elem_all))
sizeof(union htab_elem_all) is the same 48 bytes as before.
The round_up() part is an unrelated change in what map_create accepts.
Drop it from this patch.
[...]
> + if (htab_is_lru(htab))
> + elem_offset = offsetof(struct htab_elem_lru, elem);
> + else if (percpu && !prealloc)
> + elem_offset = offsetof(struct htab_elem_pcpu, elem);
> +
> + BUILD_BUG_ON(elem_offset + sizeof(struct htab_elem) >
> + sizeof(union htab_elem_all));
elem_offset is a run-time value. BUILD_BUG_ON() works here only when
the compiler manages to fold it, and it cannot trigger by construction
of the union. Drop it.