From: Eduard Zingerman <eddyz87@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
daniel@iogearbox.net, kafai@meta.com, kernel-team@meta.com,
Mykyta Yatsenko <yatsenko@meta.com>
Subject: Re: [PATCH bpf-next 2/3] libbpf: split bpf object load into prepare/load
Date: Mon, 03 Mar 2025 14:04:21 -0800 [thread overview]
Message-ID: <25f64bc2c9dbeb68a0ef21290323954e70e7366b.camel@gmail.com> (raw)
In-Reply-To: <CAEf4Bzat3grecmd_PkmLpN9gAfkuGhmO4o4HmgZWE4sJ9BL+fw@mail.gmail.com>
On Mon, 2025-03-03 at 13:38 -0800, Andrii Nakryiko wrote:
> On Sat, Mar 1, 2025 at 1:45 PM Mykyta Yatsenko
> <mykyta.yatsenko5@gmail.com> wrote:
> >
> > On 01/03/2025 08:12, Eduard Zingerman wrote:
> > > On Fri, 2025-02-28 at 17:52 +0000, Mykyta Yatsenko wrote:
> > >
> > > [...]
> > >
> > > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > > > index 9ced1ce2334c..dd2f64903c3b 100644
> > > > --- a/tools/lib/bpf/libbpf.c
> > > > +++ b/tools/lib/bpf/libbpf.c
> > > > @@ -4858,7 +4858,7 @@ bool bpf_map__autocreate(const struct bpf_map *map)
> > > >
> > > > int bpf_map__set_autocreate(struct bpf_map *map, bool autocreate)
> > > > {
> > > > - if (map->obj->state >= OBJ_LOADED)
> > > > + if (map->obj->state >= OBJ_PREPARED)
> > > > return libbpf_err(-EBUSY);
> > > I looked through logic in patches #1 and #2 and changes look correct.
> > > Running tests under valgrind does not show issues with this feature.
> > > The only ask from my side is to consider doing ==/!= comparisons in
> > > cases like above. E.g. it seems that `map->obj->state != OBJ_OPENED`
> > > is a bit simpler to understand when reading condition above.
> > > Or maybe that's just me.
> > I'm not sure about this one. >= or < checks for state relative to
> > operand more
> > flexibly,for example `map->obj->state >= OBJ_PREPARED` is read as
> > "is the object in at least PREPARED state". Perhaps, if we add more states,
> > these >,< checks will not require any changes, while ==, != may.
> > I guess this also depends on what we actually want to check here, is it that
> > state at least PREPARED or the state is not initial OPENED.
> > Not a strong opinion, though, happy to flip code to ==, !=.
>
> Those steps are logically ordered, so >= and <= makes more sense. If
> we ever add one extra step somewhere in between existing steps, most
> checks will stay correct, while with equality a lot of them might need
> to be adjusted to multiple equalities.
As I said, for me personally it is easier to read "can set autocreate
only in OPENED state", compared to "can't set autocreate if state is
PREPARED of higher".
But whatever, I'm not a true C programmer anyway :)
[...]
next prev parent reply other threads:[~2025-03-03 22:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-28 17:52 [PATCH bpf-next 0/3] Introduce bpf_object__prepare Mykyta Yatsenko
2025-02-28 17:52 ` [PATCH bpf-next 1/3] libbpf: introduce more granular state for bpf_object Mykyta Yatsenko
2025-02-28 22:20 ` Andrii Nakryiko
2025-02-28 22:35 ` Andrii Nakryiko
2025-02-28 17:52 ` [PATCH bpf-next 2/3] libbpf: split bpf object load into prepare/load Mykyta Yatsenko
2025-02-28 22:31 ` Andrii Nakryiko
2025-03-01 8:12 ` Eduard Zingerman
2025-03-01 21:45 ` Mykyta Yatsenko
2025-03-03 21:38 ` Andrii Nakryiko
2025-03-03 22:04 ` Eduard Zingerman [this message]
2025-03-03 23:27 ` Andrii Nakryiko
2025-02-28 17:52 ` [PATCH bpf-next 3/3] selftests/bpf: add tests for bpf_object__prepare Mykyta Yatsenko
2025-02-28 22:39 ` [PATCH bpf-next 0/3] Introduce bpf_object__prepare Andrii Nakryiko
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=25f64bc2c9dbeb68a0ef21290323954e70e7366b.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kafai@meta.com \
--cc=kernel-team@meta.com \
--cc=mykyta.yatsenko5@gmail.com \
--cc=yatsenko@meta.com \
/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