Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: almasrymina@google.com
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	shuah@kernel.org, linux-kselftest@vger.kernel.org,
	bestswngs@gmail.com, daniel@iogearbox.net, razor@blackwall.org,
	dw@davidwei.uk, sdf.kernel@gmail.com, bobbyeshleman@meta.com,
	dtatulea@nvidia.com
Subject: Re: [PATCH net-next v4 4/7] net: devmem: fold net_devmem_lookup_dmabuf() into net_devmem_get_binding()
Date: Mon, 23 Nov 2026 04:59:24 +0000	[thread overview]
Message-ID: <179540996476.3135.17355620050045766012@kernel.org> (raw)
In-Reply-To: <20261120045918.1239746-5-almasrymina@google.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message presents the fold as closing a gap: with two
  RCU sections, synchronize_net() after clearing NET_DEVMEM_BINDING_LIVE…

--

net: devmem: fold net_devmem_lookup_dmabuf() into net_devmem_get_binding()

This patch folds net_devmem_lookup_dmabuf() into its only caller,
net_devmem_get_binding(). The xarray lookup, binding validation,
dst_dev check and net_devmem_dmabuf_binding_get() now all run inside one
rcu_read_lock() section. Because the reference is taken only after all
checks pass, the error path no longer needs a reference put.

> Because the lookup and device checks are split across two RCU read-side
> critical sections, waiting for synchronize_net() after clearing
> NET_DEVMEM_BINDING_LIVE does not guarantee that in-flight
> net_devmem_get_binding() callers have finished validating the binding
> and returned.

[Severity: Low]

Does anything in the tree at this commit depend on closing that gap yet?

For a TX binding, net_devmem_unbind_dmabuf() only calls list_del() and
percpu_ref_kill() after synchronize_net(). bound_rxqs is empty, and the
map_dev clear only runs for DMA_FROM_DEVICE:

net/core/devmem.c:net_devmem_unbind_dmabuf() {
    ...
	synchronize_net();

	if (binding->list.next)
		list_del(&binding->list);
    ...
	if (binding->direction == DMA_FROM_DEVICE && binding->map_dev &&
	    !busy) {
		net_devmem_dmabuf_binding_unmap(binding);
		WRITE_ONCE(binding->map_dev, NULL);
	}

	percpu_ref_kill(&binding->ref);
}

So this path writes none of the fields net_devmem_get_binding() checks
(tx_vec, net, uid, map_dev, bind_dev).

net_devmem_dev_unregister() does change TX-checked state. It clears
NET_DEVMEM_BINDING_LIVE and bind_dev, unmaps, and then clears map_dev. It
never calls synchronize_net(), though, so it does not use the
single-section guarantee either:

net/core/devmem.c:net_devmem_dev_unregister() {
    ...
			WRITE_ONCE(binding->bind_dev, NULL);
			__xa_clear_mark(&net_devmem_dmabuf_bindings, xa_idx,
					NET_DEVMEM_BINDING_LIVE);
		}

		xa_unlock(&net_devmem_dmabuf_bindings);
		if (!netif_is_queue_leasee(dev))
			net_devmem_dmabuf_binding_unmap(binding);
		xa_lock(&net_devmem_dmabuf_bindings);
		WRITE_ONCE(binding->map_dev, NULL);
    ...
}

Before this patch, net_devmem_lookup_dmabuf() already held a percpu_ref
through the second RCU section. The late checks therefore could not race
with teardown in a way that mattered.

The new guarantee seems to be used first by the later commit "net:
devmem: always populate bind_dev and detach both devices on unregister".
That commit adds synchronize_net() to net_devmem_dev_unregister() before
it clears map_dev.

Could the commit message say this is preparation for that change and has
no functional change by itself? As written, it describes a gap but no
failure, and it has no Fixes: tag. That makes it hard for maintainers and
stable backporters to know whether it is meant as a fix.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120045918.1239746-1-almasrymina%40google.com

  reply	other threads:[~2026-11-23  4:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  4:59 [PATCH net-next v4 0/7] net: devmem: support leased RX and TX queues on netdev unregister Mina Almasry
2026-11-20  4:59 ` [PATCH net-next v4 1/7] net: devmem: pass net_device pointer to net_devmem_lock_dev() Mina Almasry
2026-11-20  4:59 ` [PATCH net-next v4 2/7] net: devmem: rename binding dev and vdev to map_dev and bind_dev Mina Almasry
2026-11-20  4:59 ` [PATCH net-next v4 3/7] net: guard memory provider RX queue open and close on unregister Mina Almasry
2026-11-23  4:59   ` netdev-bot+sashiko
2026-11-20  4:59 ` [PATCH net-next v4 4/7] net: devmem: fold net_devmem_lookup_dmabuf() into net_devmem_get_binding() Mina Almasry
2026-11-23  4:59   ` netdev-bot+sashiko [this message]
2026-11-20  4:59 ` [PATCH net-next v4 5/7] net: devmem: always populate bind_dev and detach both devices on unregister Mina Almasry
2026-11-23  4:59   ` netdev-bot+sashiko
2026-11-20  4:59 ` [PATCH net-next v4 6/7] net: devmem: resolve physical map_dev for leased RX bindings Mina Almasry
2026-11-23  4:59   ` netdev-bot+sashiko
2026-11-20  4:59 ` [PATCH net-next v4 7/7] selftests: net: add leased devmem RX and TX netdev unregister tests Mina Almasry
2026-11-20 17:04 ` [PATCH net-next v4 0/7] net: devmem: support leased RX and TX queues on netdev unregister Stanislav Fomichev
2026-11-22  9:16 ` Nikolay Aleksandrov

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=179540996476.3135.17355620050045766012@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=almasrymina@google.com \
    --cc=bestswngs@gmail.com \
    --cc=bobbyeshleman@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dtatulea@nvidia.com \
    --cc=dw@davidwei.uk \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=sdf.kernel@gmail.com \
    --cc=shuah@kernel.org \
    /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