BPF List
 help / color / mirror / Atom feed
From: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>
To: Eduard Zingerman <eddyz87@gmail.com>,
	bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
	daniel@iogearbox.net, kafai@meta.com, kernel-team@meta.com
Cc: Mykyta Yatsenko <yatsenko@meta.com>
Subject: Re: [PATCH bpf-next 2/3] libbpf: split bpf object load into prepare/load
Date: Sat, 1 Mar 2025 21:45:03 +0000	[thread overview]
Message-ID: <00e385df-7ffc-4fd9-aad8-60dddef300af@gmail.com> (raw)
In-Reply-To: <5d7fb7202625b999cb77a1e010ba6f7099dbb561.camel@gmail.com>

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 ==, !=.
>   
>>   	map->autocreate = autocreate;
> [...]
>


  reply	other threads:[~2025-03-01 21:45 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 [this message]
2025-03-03 21:38       ` Andrii Nakryiko
2025-03-03 22:04         ` Eduard Zingerman
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=00e385df-7ffc-4fd9-aad8-60dddef300af@gmail.com \
    --to=mykyta.yatsenko5@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=kafai@meta.com \
    --cc=kernel-team@meta.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