Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by netdev-bot+sashiko
Mon, 23 Nov 2026 04:59
Re: [PATCH net-next v4 4/7] net: devmem: fold net_devmem_lookup_dmabuf() into net_devmem_get_binding()
Author: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 04:59
Date: Mon, 23 Nov 2026 04:59
89 lines
11204 bytes
11204 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads