All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "T.J. Mercier" <tjmercier@google.com>, <daniel@iogearbox.net>,
	<andrii@kernel.org>, <eddyz87@gmail.com>, <memxor@gmail.com>,
	<martin.lau@linux.dev>, <song@kernel.org>,
	<yonghong.song@linux.dev>, <jolsa@kernel.org>,
	<emil@etsalapatis.com>, <ihor.solodrai@linux.dev>,
	<mykyta.yatsenko5@gmail.com>
Cc: <bpf@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf-next v5 1/2] bpf: htab: Split htab_elem_lru and htab_elem_pcpu off of htab_elem
Date: Mon, 21 Sep 2026 00:51:12 +0000	[thread overview]
Message-ID: <DLKKZEHWGP2Y.2C0DPQW74COKW@gmail.com> (raw)
In-Reply-To: <20260921002206.184660-2-tjmercier@google.com>

On Sun, Sep 20, 2026 at 05:22 PM T.J. Mercier <tjmercier@google.com> 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.

  reply	other threads:[~2026-09-21  0:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21  0:22 [PATCH bpf-next v5 0/2] bpf: htab: Reduce memory use of hash maps T.J. Mercier
2026-09-21  0:22 ` [PATCH bpf-next v5 1/2] bpf: htab: Split htab_elem_lru and htab_elem_pcpu off of htab_elem T.J. Mercier
2026-09-21  0:51   ` Alexei Starovoitov [this message]
2026-09-21 16:40     ` T.J. Mercier
2026-09-21  0:22 ` [PATCH bpf-next v5 2/2] bpf: htab: Reduce elem_size by 8 bytes for small key sizes T.J. Mercier
2026-09-21  0:57   ` Alexei Starovoitov
2026-09-21 16:34     ` T.J. Mercier

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=DLKKZEHWGP2Y.2C0DPQW74COKW@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=mykyta.yatsenko5@gmail.com \
    --cc=song@kernel.org \
    --cc=tjmercier@google.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.