From: Eduard Zingerman <eddyz87@gmail.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: bpf@vger.kernel.org, kkd@meta.com,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@kernel.org>,
kernel-team@fb.com
Subject: Re: [PATCH bpf-next v1 3/7] bpf: Consolidate RCU and preempt locks in bpf_func_state
Date: Thu, 21 Nov 2024 10:54:10 -0800 [thread overview]
Message-ID: <763a88cb28f66ac5c62ddbeef763b77fc6833418.camel@gmail.com> (raw)
In-Reply-To: <CAP01T75sz0YB7dj3fchyw-E2kjftaewcXhWJP_=hf_OBnWBDQA@mail.gmail.com>
On Thu, 2024-11-21 at 19:12 +0100, Kumar Kartikeya Dwivedi wrote:
> On Thu, 21 Nov 2024 at 19:09, Eduard Zingerman <eddyz87@gmail.com> wrote:
> >
> > On Wed, 2024-11-20 at 16:53 -0800, Kumar Kartikeya Dwivedi wrote:
> > > To ensure consistency in resource handling, move RCU and preemption
> > > state counters to bpf_func_state, and convert all users to access them
> > > through cur_func(env).
> > >
> > > For the sake of consistency, also compare active_locks in ressafe as a
> > > quick way to eliminate iteration and entry matching if the number of
> > > locks are not the same.
> > >
> > > OTOH, the comparison of active_preempt_locks and active_rcu_lock is
> > > needed for correctness, as state exploration cannot be avoided if these
> > > counters do not match, and not comparing them will lead to problems
> > > since they lack an actual entry in the acquired_res array.
> > >
> > > Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> > > ---
> >
> > This change is a bit confusing to me.
> > The following is done currently:
> > - in setup_func_entry() called from check_func_call():
> > copy_resource_state(callee, caller);
> > - in prepare_func_exit():
> > copy_resource_state(caller, callee);
> >
> > So it seems that it is logical to track resources in the
> > bpf_verifier_state and avoid copying.
> > There is probably something I don't understand.
> >
>
> This is what we were doing all along, and you're right, it is sort of
> a global entity.
Right, but since this patch-set does a refactoring,
might be a good time to change.
> But we've moved active_locks to bpf_func_state, where references reside, while
> RCU and preempt lock state stays in verifier state. Either everything
> should be in
> cur_func, or in bpf_verifier_state. I am fine with either of them,
> because it would
> materially does not matter too much.
>
> Alexei's preference has been stashing this in bpf_func_state instead in [0].
> Let me know what you think.
>
> [0] https://lore.kernel.org/bpf/CAADnVQKxgE7=WhjNckvMDTZ5GZujPuT3Dqd+sY=pW8CWoaF9FA@mail.gmail.com
As far as I understand check_func_call(), function calls to static
functions are allowed while holding each kind of resources currently
tracked. So it seems odd to track it as a part of function state.
The way I understand Alexei in the thread [0] the idea is more
to track all counters in one place.
Let's wait what Alexei has to say.
next prev parent reply other threads:[~2024-11-21 18:54 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-21 0:53 [PATCH bpf-next v1 0/7] IRQ save/restore Kumar Kartikeya Dwivedi
2024-11-21 0:53 ` [PATCH bpf-next v1 1/7] bpf: Refactor and rename resource management Kumar Kartikeya Dwivedi
2024-11-21 16:57 ` Eduard Zingerman
2024-11-21 17:17 ` Kumar Kartikeya Dwivedi
2024-11-22 0:24 ` Alexei Starovoitov
2024-11-22 0:31 ` Kumar Kartikeya Dwivedi
2024-11-21 0:53 ` [PATCH bpf-next v1 2/7] bpf: Be consistent between {acquire,find,release}_lock_state Kumar Kartikeya Dwivedi
2024-11-21 17:54 ` Eduard Zingerman
2024-11-21 0:53 ` [PATCH bpf-next v1 3/7] bpf: Consolidate RCU and preempt locks in bpf_func_state Kumar Kartikeya Dwivedi
2024-11-21 18:09 ` Eduard Zingerman
2024-11-21 18:12 ` Kumar Kartikeya Dwivedi
2024-11-21 18:54 ` Eduard Zingerman [this message]
2024-11-21 22:04 ` Kumar Kartikeya Dwivedi
2024-11-21 0:53 ` [PATCH bpf-next v1 4/7] bpf: Refactor mark_{dynptr,iter}_read Kumar Kartikeya Dwivedi
2024-11-21 18:00 ` Eduard Zingerman
2024-11-21 0:53 ` [PATCH bpf-next v1 5/7] bpf: Introduce support for bpf_local_irq_{save,restore} Kumar Kartikeya Dwivedi
2024-11-21 20:21 ` Eduard Zingerman
2024-11-21 22:06 ` Kumar Kartikeya Dwivedi
2024-11-21 23:08 ` Eduard Zingerman
2024-11-21 23:12 ` Kumar Kartikeya Dwivedi
2024-11-22 0:30 ` Eduard Zingerman
2024-11-22 0:32 ` Alexei Starovoitov
2024-11-22 0:42 ` Kumar Kartikeya Dwivedi
2024-11-21 22:46 ` kernel test robot
2024-11-21 0:53 ` [PATCH bpf-next v1 6/7] selftests/bpf: Expand coverage of preempt tests to sleepable kfunc Kumar Kartikeya Dwivedi
2024-11-21 20:23 ` Eduard Zingerman
2024-11-21 0:53 ` [PATCH bpf-next v1 7/7] selftests/bpf: Add IRQ save/restore tests Kumar Kartikeya Dwivedi
2024-11-21 20:43 ` Eduard Zingerman
2024-11-21 22:07 ` Kumar Kartikeya Dwivedi
2024-11-21 23:09 ` 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=763a88cb28f66ac5c62ddbeef763b77fc6833418.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=kernel-team@fb.com \
--cc=kkd@meta.com \
--cc=martin.lau@kernel.org \
--cc=memxor@gmail.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