BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	Puranjay Mohan <puranjay12@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau	 <martin.lau@kernel.org>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>,
	Kernel Team <kernel-team@meta.com>
Subject: Re: [PATCH bpf-next v3 0/6] Introduce KF_FORBID_SLEEP modifier for acquire/release kfuncs
Date: Tue, 24 Feb 2026 10:55:33 -0800	[thread overview]
Message-ID: <a8fbc7a3669ad1014b2623c42219d3d074dfbc8f.camel@gmail.com> (raw)
In-Reply-To: <CAADnVQJ_xG+QAUzPHm1FZGpcz45X3k_cG3ThQ0da3kFa0ppLmA@mail.gmail.com>

On Tue, 2026-02-24 at 10:00 -0800, Alexei Starovoitov wrote:
> On Tue, Feb 24, 2026 at 3:24 AM Puranjay Mohan <puranjay12@gmail.com> wrote:
> > 
> > On Tue, Feb 24, 2026 at 1:49 AM Alexei Starovoitov
> > <alexei.starovoitov@gmail.com> wrote:
> > > 
> > > On Mon, Feb 23, 2026 at 9:48 AM Puranjay Mohan <puranjay@kernel.org> wrote:
> > > > 
> > > > 
> > > > Iterator KF_ACQUIRE support is not useful on its own right now, but it
> > > > becomes the foundation for KF_FORBID_SLEEP: an iterator whose _next is
> > > > annotated with KF_ACQUIRE | KF_FORBID_SLEEP can now express "holding this
> > > > pointer forbids sleeping; calling _release invalidates the pointer and
> > > > re-enables sleeping."
> > > > 
> > > 
> > > The name of the flag and semantics bothers me a bit.
> > > How about we call it KF_ACQUIRE_LOCK and make it exclusive vs KF_ACQUIRE.
> > > And document it like:
> > > KF_ACQUIRE -> acquires a resource via reference counting
> > > KF_ACQUIRE_LOCK -> acquires a resource by locking it
> > > 
> > > and to match it I would do:
> > > KF_RELEASE -> releases a resource by decrementing refcount
> > > KF_RELEASE_LOCK -> releases a resource by unlocking it.
> > > 
> > > When lock is taken it's typically prohibited to sleep and do
> > > other things. So I feel such flags would describe what's
> > > going on underneath more accurately.
> > > 
> > > Thoughts?
> > 
> > I am fine with this except, I think we should still keep the
> > KF_RELEASE a single release mechanism that releases according to how
> > the reference was taken (refcount/lock). There is nothing wrong with
> > separate KF_RELEASE and KF_RELEASE_LOCK, except we would have to
> > reject all wrong usages like KF_ACQUIRE -> KF_RELEASE_LOCK,
> > KF_ACQUIRE_LOCK -> KF_RELEASE.
> 
> yes. Is this too complex or what's the concern?
> 
> > I am fine with both but prefer the
> > common KF_RELEASE. Let me know which one you like and I will go ahead
> > with it.
> 
> Magic KF_RELEASE simplifies things a bit. I don't mind, I guess,
> but would like to hear a 3rd opinion.

At the moment verifier tracks the following locking/non-sleepable
resources:
- active_irq_id        - nesting allowed, forbids sleep, special stack slot acquire/release logic.
- active_rcu_locks     - nesting allowed, forbids sleep, used by in in_rcu_cs(),
                         no special acquire/release logic.
- active_preempt_locks - nesting allowed, forbids sleep, no special acquire/release logic.
- active_locks         - nesting disallowed, forbids sleep, no special acquire/release logic.

Currently verifier checks what kfunc/helper is called and changes
internal state accordingly. It might be possible to slice the above
into a set of "generic" flags / feats, but it requires some thought.

Maybe explore this as a separate series?

[...]

  reply	other threads:[~2026-02-24 18:55 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-23 17:46 [PATCH bpf-next v3 0/6] Introduce KF_FORBID_SLEEP modifier for acquire/release kfuncs Puranjay Mohan
2026-02-23 17:46 ` [PATCH bpf-next v3 1/6] bpf: Add KF_ACQUIRE and KF_RELEASE support for iterators Puranjay Mohan
2026-02-23 19:59   ` Mykyta Yatsenko
2026-02-23 20:41   ` Eduard Zingerman
2026-02-23 17:46 ` [PATCH bpf-next v3 2/6] bpf: consolidate sleepable context error message printing Puranjay Mohan
2026-02-23 20:06   ` Mykyta Yatsenko
2026-02-23 20:27     ` Eduard Zingerman
2026-02-23 17:46 ` [PATCH bpf-next v3 3/6] bpf: Add KF_FORBID_SLEEP modifier for KF_ACQUIRE kfuncs Puranjay Mohan
2026-02-23 22:14   ` Eduard Zingerman
2026-02-24 15:24     ` Puranjay Mohan
2026-02-24 18:17       ` Eduard Zingerman
2026-02-24 19:41         ` Kumar Kartikeya Dwivedi
2026-02-23 17:46 ` [PATCH bpf-next v3 4/6] bpf: Move locking to bpf_iter_task_vma_next() Puranjay Mohan
2026-02-23 17:46 ` [PATCH bpf-next v3 5/6] bpf: Add split iteration support to task_vma iterator Puranjay Mohan
2026-02-23 17:46 ` [PATCH bpf-next v3 6/6] selftests/bpf: Add tests for split " Puranjay Mohan
2026-02-24  1:49 ` [PATCH bpf-next v3 0/6] Introduce KF_FORBID_SLEEP modifier for acquire/release kfuncs Alexei Starovoitov
2026-02-24 11:24   ` Puranjay Mohan
2026-02-24 18:00     ` Alexei Starovoitov
2026-02-24 18:55       ` Eduard Zingerman [this message]
2026-02-24 19:32         ` Alexei Starovoitov
2026-02-24 19:47           ` Puranjay Mohan
2026-02-24 19:51         ` Puranjay Mohan
2026-02-24 20:15           ` Eduard Zingerman
2026-02-24 20:20             ` Puranjay Mohan

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=a8fbc7a3669ad1014b2623c42219d3d074dfbc8f.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    --cc=memxor@gmail.com \
    --cc=mykyta.yatsenko5@gmail.com \
    --cc=puranjay12@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