From: Bobby Eshleman <bobbyeshleman@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Kuniyuki Iwashima <kuniyu@google.com>,
Willem de Bruijn <willemb@google.com>,
Neal Cardwell <ncardwell@google.com>,
David Ahern <dsahern@kernel.org>,
Mina Almasry <almasrymina@google.com>,
Arnd Bergmann <arnd@arndb.de>, Jonathan Corbet <corbet@lwn.net>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Shuah Khan <shuah@kernel.org>,
Donald Hunter <donald.hunter@gmail.com>,
Stanislav Fomichev <sdf@fomichev.me>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arch@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kselftest@vger.kernel.org, asml.silence@gmail.com,
matttbe@kernel.org, skhawaja@google.com,
Bobby Eshleman <bobbyeshleman@meta.com>
Subject: Re: [PATCH net-next v10 4/5] net: devmem: document NETDEV_A_DMABUF_AUTORELEASE netlink attribute
Date: Wed, 21 Jan 2026 18:37:56 -0800 [thread overview]
Message-ID: <aXGNhEKOhkTHbJvw@devvm11784.nha0.facebook.com> (raw)
In-Reply-To: <20260121173512.748e2155@kernel.org>
On Wed, Jan 21, 2026 at 05:35:12PM -0800, Jakub Kicinski wrote:
> On Tue, 20 Jan 2026 21:44:09 -0800 Bobby Eshleman wrote:
> > On Tue, Jan 20, 2026 at 04:36:50PM -0800, Jakub Kicinski wrote:
> > > On Thu, 15 Jan 2026 21:02:15 -0800 Bobby Eshleman wrote:
> > > > +- Once a system-wide autorelease mode is selected (via the first binding),
> > > > + all subsequent bindings must use the same mode. Attempts to create bindings
> > > > + with a different mode will be rejected with -EBUSY.
> > >
> > > Why?
> >
> > Originally I was using EINVAL, but when writing the tests I noticed this
> > might be a confusing case for users to interpret EINVAL (i.e., some
> > binding possibly made by someone else is in a different mode). I thought
> > EBUSY could capture the semantic "the system is locked up in a different
> > mode, try again when it isn't".
> >
> > I'm not married to it though. Happy to go back to EINVAL or another
> > errno.
>
> My question was more why the system-wide policy exists, rather than
> binding-by-binding. Naively I'd think that a single socket must pick
> but system wide there could easily be multiple bindings not bothering
> each other, doing different things?
Originally we allowed per-binding policy, but it seemed one-per-system
may 1) simplify reasoning through the code by only allowing one policy
per system, and 2) allow simpler deprecation of autorelease=on if its
found to be obsolete over time (just hack off that particular path of
the static branch set). It doesn't prevent any races/bugs or anything.
>
> > > > +- Applications using manual release mode (autorelease=0) must ensure all tokens
> > > > + are returned via SO_DEVMEM_DONTNEED before socket close to avoid resource
> > > > + leaks during the lifetime of the dmabuf binding. Tokens not released before
> > > > + close() will only be freed when all RX queues are unbound AND all sockets
> > > > + that called recvmsg() are closed.
> > >
> > > Could you add a short example on how? by calling shutdown()?
> >
> > Show an example of the three steps: returning the tokens, unbinding, and closing the
> > sockets (TCP/NL)?
>
> TBH I read the doc before reading the code, which I guess may actually
> be better since we don't expect users to read the code first either..
>
> Now after reading the code I'm not sure the doc explains things
> properly. AFAIU there's no association of token <> socket within the
> same binding. User can close socket A and return the tokens via socket
> B. As written the doc made me think that there will be a leak if socket
> is closed without releasing tokens, or that there may be a race with
> data queued but not read. Neither is true, really?
That is correct, neither is true. If the two sockets share a binding the
kernel doesn't care which socket received the token or which one
returned it. No token <> socket association. There is no
queued-but-not-read race either. If any tokens are not returned, as long
as all of the binding references are eventually released and all sockets
that used the binding are closed, then all references will be accounted
for and everything cleaned up.
Best,
Bobby
next prev parent reply other threads:[~2026-01-22 2:38 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 5:02 [PATCH net-next v10 0/5] net: devmem: improve cpu cost of RX token management Bobby Eshleman
2026-01-16 5:02 ` [PATCH net-next v10 1/5] net: devmem: rename tx_vec to vec in dmabuf binding Bobby Eshleman
2026-01-16 5:02 ` [PATCH net-next v10 2/5] net: devmem: refactor sock_devmem_dontneed for autorelease split Bobby Eshleman
2026-01-16 5:02 ` [PATCH net-next v10 3/5] net: devmem: implement autorelease token management Bobby Eshleman
2026-01-21 1:00 ` Jakub Kicinski
2026-01-21 5:33 ` Bobby Eshleman
2026-01-22 4:15 ` Mina Almasry
2026-01-22 5:18 ` Bobby Eshleman
2026-01-16 5:02 ` [PATCH net-next v10 4/5] net: devmem: document NETDEV_A_DMABUF_AUTORELEASE netlink attribute Bobby Eshleman
2026-01-21 0:36 ` Jakub Kicinski
2026-01-21 5:44 ` Bobby Eshleman
2026-01-22 1:35 ` Jakub Kicinski
2026-01-22 2:37 ` Bobby Eshleman [this message]
2026-01-22 2:50 ` Jakub Kicinski
2026-01-22 3:25 ` Bobby Eshleman
2026-01-22 3:46 ` Jakub Kicinski
2026-01-22 4:07 ` Stanislav Fomichev
2026-01-27 1:26 ` Jakub Kicinski
2026-01-27 2:30 ` Bobby Eshleman
2026-01-27 2:44 ` Jakub Kicinski
2026-01-27 3:06 ` Bobby Eshleman
2026-01-27 3:43 ` Jakub Kicinski
2026-01-27 3:50 ` Bobby Eshleman
2026-01-16 5:02 ` [PATCH net-next v10 5/5] selftests: drv-net: devmem: add autorelease tests Bobby Eshleman
2026-01-21 1:07 ` [PATCH net-next v10 0/5] net: devmem: improve cpu cost of RX token management Jakub Kicinski
2026-01-21 5:29 ` Bobby Eshleman
2026-01-22 1:37 ` Jakub Kicinski
2026-01-22 4:21 ` Mina Almasry
2026-01-26 18:45 ` Bobby Eshleman
2026-01-27 1:31 ` Jakub Kicinski
2026-01-27 6:00 ` Stanislav Fomichev
2026-01-27 6:48 ` Bobby Eshleman
2026-01-30 11:13 ` Pavel Begunkov
2026-02-05 3:48 ` Jens Axboe
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=aXGNhEKOhkTHbJvw@devvm11784.nha0.facebook.com \
--to=bobbyeshleman@gmail.com \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=arnd@arndb.de \
--cc=asml.silence@gmail.com \
--cc=bobbyeshleman@meta.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=matttbe@kernel.org \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=skhawaja@google.com \
--cc=willemb@google.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