From: Eduard Zingerman <eddyz87@gmail.com>
To: Vineet Gupta <vineet.gupta@linux.dev>,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
memxor@gmail.com
Cc: martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev,
john.fastabend@gmail.com, shuah@kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [RFC bpf-next 1/6] bpf: turn bpf_reg_state->precise into a flags field [NFC]
Date: Tue, 18 Aug 2026 14:38:25 -0700 [thread overview]
Message-ID: <17813f00c2c81cd2588672197cc6d4de619ca36b.camel@gmail.com> (raw)
In-Reply-To: <20260814231945.3884596-2-vineet.gupta@linux.dev>
On Fri, 2026-08-14 at 16:19 -0700, Vineet Gupta wrote:
> bpf_reg_state carries a single bool, ->precise. Other per-register boolean
> properties exist (and more are coming), so convert the bool into a u8,
> call it flags and give the property a name.
>
> - bool precise;
> +#define BPF_FLAG_PRECISE (1U << 7)
> + u8 flags;
>
> Both occupy 1 byte at the same offset, so the struct layout is unchanged.
> ->precise was the last field, after ->frameno, and ->flags takes exactly
> that slot, so the memcmp()/offsetof() based comparisons are unaffected:
> every one of them stops at offsetof(id), offsetof(var_off) or
> offsetof(frameno), i.e. at or before the field either way.
>
> That tail position is not an accident -- it is where fields live that are
> compared semantically rather than byte-wise. ->precise is never memcmp()ed;
> regsafe() tests it explicitly, and an imprecise old scalar is a wildcard:
>
> if (!reg_is_precise(rold) && exact == NOT_EXACT)
> return true;
>
> PRECISE also takes bit 7 rather than bit 0, because it is the odd one out
> among the flags that will share this byte: the others describe how a register
> relates to its ->id set and are cleared as a group, while PRECISE belongs to
> the register alone and must survive that clearing. Growing the rest up from
> bit 0 keeps a clear-the-link-bits mask from reaching it by construction.
>
> Reads go through a helper, since they are the common case and read better.
> Set and clear stay open-coded as the usual reg->flags |= / &= ~ bit ops.
>
> No functional change intended.
>
> Suggested-by: Eduard Zingerman <eddyz87@gmail.com>
> Signed-off-by: Vineet Gupta <vineet.gupta@linux.dev>
> ---
Sorry for the confusion, what I intended to suggest is usage of bitfields,
instead of carving out bits from the 'id' field.
Let me read the rest of the series to see how the flags look overall,
but looking just at this patch I'd suggest bitfields.
next prev parent reply other threads:[~2026-08-18 21:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 23:19 [RFC bpf-next 0/6] bpf: track scalar equality across the low 32 bits Vineet Gupta
2026-08-14 23:19 ` [RFC bpf-next 1/6] bpf: turn bpf_reg_state->precise into a flags field [NFC] Vineet Gupta
2026-08-18 21:38 ` Eduard Zingerman [this message]
2026-08-14 23:19 ` [RFC bpf-next 2/6] bpf: move the linked-scalar flags into bpf_reg_state->flags [NFC] Vineet Gupta
2026-08-18 22:51 ` Eduard Zingerman
2026-08-14 23:19 ` [RFC bpf-next 3/6] bpf: support low-32 subreg scalar linking for zero-extending movs Vineet Gupta
2026-08-19 3:39 ` Eduard Zingerman
2026-08-19 4:07 ` Eduard Zingerman
2026-08-14 23:19 ` [RFC bpf-next 4/6] selftests/bpf: cover low-32 subreg-equal link " Vineet Gupta
2026-08-19 5:05 ` Eduard Zingerman
2026-08-14 23:19 ` [RFC bpf-next 5/6] bpf: support low-32 subreg scalar linking for sign-extending movs Vineet Gupta
2026-08-19 6:18 ` Eduard Zingerman
2026-08-14 23:19 ` [RFC bpf-next 6/6] selftests/bpf: cover 32-bit sign-extension low-32 links Vineet Gupta
2026-08-19 4:35 ` [RFC bpf-next 0/6] bpf: track scalar equality across the low 32 bits Eduard Zingerman
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=17813f00c2c81cd2588672197cc6d4de619ca36b.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=vineet.gupta@linux.dev \
--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
all inboxes | Powered by JetHome®