From: Mina Almasry <almasrymina@google.com>
To: netdev@vger.kernel.org
Cc: Mina Almasry <almasrymina@google.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org,
Stanislav Fomichev <sdf.kernel@gmail.com>,
Bobby Eshleman <bobbyeshleman@meta.com>,
Nikolay Aleksandrov <razor@blackwall.org>,
Daniel Borkmann <daniel@iogearbox.net>,
David Wei <dw@davidwei.uk>,
Pavel Begunkov <asml.silence@gmail.com>,
Jens Axboe <axboe@kernel.dk>, Weiming Shi <bestswngs@gmail.com>,
io-uring@vger.kernel.org,
Jesper Dangaard Brouer <hawk@kernel.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>
Subject: [PATCH net-next v5 5/6] net: propagate busy status on memory provider uninstall
Date: Fri, 4 Dec 2026 23:10:29 +0000 [thread overview]
Message-ID: <20261204231030.3815575-6-almasrymina@google.com> (raw)
In-Reply-To: <20261204231030.3815575-1-almasrymina@google.com>
netif_rxq_cleanup_unlease() currently discards the return value of
__netif_mp_close_rxq(), so memory providers cannot tell whether closing
a leased queue failed and hardware may still be using the page pool.
Tracking failed closes in a local variable in net_devmem_unbind_dmabuf()
is also insufficient once leased-queue uninstalls span multiple queues
or precede userspace socket close.
Pass a bool busy flag (!!err from __netif_mp_close_rxq()) through
memory_provider_ops->uninstall() and record failed closes in a new
binding->rxq_busy flag on struct net_devmem_dmabuf_binding. Both
mp_dmabuf_devmem_uninstall() and net_devmem_unbind_dmabuf() then defer
unmapping whenever any queue of the binding failed to close, leaving
cleanup to net_devmem_dev_unregister() or
__net_devmem_dmabuf_binding_free(). Existing io_uring/zcrx uninstall
behavior is left unchanged.
These issues were identified by code inspection while extending devmem
unregister teardown to leased queues; they have not been observed in
production or tested on real hardware. Verified with netdevsim and
netkit selftests in nl_netdev.py and nk_qlease.py.
Signed-off-by: Mina Almasry <almasrymina@google.com>
---
v4 -> v5:
- Split out busy queue-close propagation into its own patch, adding
bool busy to memory_provider_ops->uninstall() and binding->rxq_busy.
---
include/net/page_pool/memory_provider.h | 7 ++++++-
io_uring/zcrx.c | 3 ++-
net/core/dev.c | 2 +-
net/core/dev.h | 3 ++-
net/core/devmem.c | 12 +++++++-----
net/core/devmem.h | 1 +
net/core/netdev_rx_queue.c | 10 ++++++----
7 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/include/net/page_pool/memory_provider.h b/include/net/page_pool/memory_provider.h
index bceb5f7740e2f..82eac3feefc94 100644
--- a/include/net/page_pool/memory_provider.h
+++ b/include/net/page_pool/memory_provider.h
@@ -26,7 +26,12 @@ struct memory_provider_ops {
void (*destroy)(struct page_pool *pool);
int (*nl_fill)(void *mp_priv, struct sk_buff *rsp,
struct netdev_rx_queue *rxq);
- void (*uninstall)(void *mp_priv, struct netdev_rx_queue *rxq);
+ /* Called under netdev_lock(rxq->dev) on device unregister or queue
+ * unlease. If @busy is true, closing @rxq failed and hardware may
+ * still be using the page pool.
+ */
+ void (*uninstall)(void *mp_priv, struct netdev_rx_queue *rxq,
+ bool busy);
};
bool net_mp_niov_set_dma_addr(struct net_iov *niov, dma_addr_t addr);
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 20597bfa146d6..ed44835a783b5 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -1457,7 +1457,8 @@ static int io_pp_nl_fill(void *mp_priv, struct sk_buff *rsp,
return 0;
}
-static void io_pp_uninstall(void *mp_priv, struct netdev_rx_queue *rxq)
+static void io_pp_uninstall(void *mp_priv, struct netdev_rx_queue *rxq,
+ bool busy)
{
struct io_zcrx_ifq *ifq = mp_priv;
diff --git a/net/core/dev.c b/net/core/dev.c
index b7757f91fdf92..55af817b61e5a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -12774,7 +12774,7 @@ static void dev_memory_provider_uninstall(struct net_device *dev)
for (i = 0; i < dev->real_num_rx_queues; i++) {
struct netdev_rx_queue *rxq = &dev->_rx[i];
- __netif_mp_uninstall_rxq(rxq, &rxq->mp_params);
+ __netif_mp_uninstall_rxq(rxq, &rxq->mp_params, false);
}
}
diff --git a/net/core/dev.h b/net/core/dev.h
index 183c580006b54..2132cbde9d232 100644
--- a/net/core/dev.h
+++ b/net/core/dev.h
@@ -127,7 +127,8 @@ int __netif_mp_open_rxq(struct net_device *dev, unsigned int rxq_idx,
int __netif_mp_close_rxq(struct net_device *dev, unsigned int rxq_idx,
const struct pp_memory_provider_params *old_p);
void __netif_mp_uninstall_rxq(struct netdev_rx_queue *rxq,
- const struct pp_memory_provider_params *p);
+ const struct pp_memory_provider_params *p,
+ bool busy);
/* netdev management, shared between various uAPI entry points */
struct netdev_name_node {
diff --git a/net/core/devmem.c b/net/core/devmem.c
index a395f100d2f33..01621c0f8b485 100644
--- a/net/core/devmem.c
+++ b/net/core/devmem.c
@@ -206,7 +206,6 @@ void net_devmem_unbind_dmabuf(struct net_devmem_dmabuf_binding *binding)
struct netdev_rx_queue *rxq;
unsigned long xa_idx;
unsigned int rxq_idx;
- bool busy = false;
xa_clear_mark(&net_devmem_dmabuf_bindings, binding->id,
NET_DEVMEM_BINDING_LIVE);
@@ -230,10 +229,11 @@ void net_devmem_unbind_dmabuf(struct net_devmem_dmabuf_binding *binding)
if (__netif_mp_close_rxq(binding->dev, rxq_idx,
&mp_params))
- busy = true;
+ binding->rxq_busy = true;
}
- if (binding->direction == DMA_FROM_DEVICE && !busy) {
+ if (binding->direction == DMA_FROM_DEVICE &&
+ !binding->rxq_busy) {
net_devmem_dmabuf_binding_unmap(binding);
WRITE_ONCE(binding->dev, NULL);
}
@@ -692,7 +692,7 @@ static int mp_dmabuf_devmem_nl_fill(void *mp_priv, struct sk_buff *rsp,
}
static void mp_dmabuf_devmem_uninstall(void *mp_priv,
- struct netdev_rx_queue *rxq)
+ struct netdev_rx_queue *rxq, bool busy)
{
struct net_devmem_dmabuf_binding *binding = mp_priv;
struct netdev_rx_queue *bound_rxq;
@@ -702,8 +702,10 @@ static void mp_dmabuf_devmem_uninstall(void *mp_priv,
if (bound_rxq != rxq)
continue;
+ if (busy)
+ binding->rxq_busy = true;
xa_erase(&binding->bound_rxqs, xa_idx);
- if (xa_empty(&binding->bound_rxqs)) {
+ if (!binding->rxq_busy && xa_empty(&binding->bound_rxqs)) {
net_devmem_dmabuf_binding_unmap(binding);
ASSERT_EXCLUSIVE_WRITER(binding->dev);
WRITE_ONCE(binding->dev, NULL);
diff --git a/net/core/devmem.h b/net/core/devmem.h
index 4036aab286c4d..cd65c16c4337d 100644
--- a/net/core/devmem.h
+++ b/net/core/devmem.h
@@ -83,6 +83,7 @@ struct net_devmem_dmabuf_binding {
struct net_iov **tx_vec;
unsigned int niov_shift;
+ bool rxq_busy;
struct work_struct unbind_w;
};
diff --git a/net/core/netdev_rx_queue.c b/net/core/netdev_rx_queue.c
index dc918f6cd4eeb..78eee3d243f75 100644
--- a/net/core/netdev_rx_queue.c
+++ b/net/core/netdev_rx_queue.c
@@ -338,7 +338,8 @@ int netif_mp_close_rxq(struct net_device *dev, unsigned int rxq_idx,
}
void __netif_mp_uninstall_rxq(struct netdev_rx_queue *rxq,
- const struct pp_memory_provider_params *p)
+ const struct pp_memory_provider_params *p,
+ bool busy)
{
struct pp_memory_provider_params tmp = *p;
@@ -347,7 +348,7 @@ void __netif_mp_uninstall_rxq(struct netdev_rx_queue *rxq,
memset(&rxq->mp_params, 0, sizeof(rxq->mp_params));
if (tmp.mp_ops->uninstall)
- tmp.mp_ops->uninstall(tmp.mp_priv, rxq);
+ tmp.mp_ops->uninstall(tmp.mp_priv, rxq, busy);
}
/* Clean up memory provider state when a queue lease is torn down. If
@@ -362,10 +363,11 @@ static void netif_rxq_cleanup_unlease(struct netdev_rx_queue *phys_rxq)
{
unsigned int rxq_idx = get_netdev_rx_queue_index(phys_rxq);
struct pp_memory_provider_params p = phys_rxq->mp_params;
+ int err;
if (!p.mp_ops)
return;
- __netif_mp_close_rxq(phys_rxq->dev, rxq_idx, &p);
- __netif_mp_uninstall_rxq(phys_rxq, &p);
+ err = __netif_mp_close_rxq(phys_rxq->dev, rxq_idx, &p);
+ __netif_mp_uninstall_rxq(phys_rxq, &p, !!err);
}
--
2.56.1.915.g69d5ec7298-goog
next prev parent reply other threads:[~2026-12-04 23:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 23:10 [PATCH net-next v5 0/6] net: devmem: support leased RX and TX queues on netdev unregister Mina Almasry
2026-12-04 23:10 ` [PATCH net-next v5 1/6] net: guard leased queue ops against physical " Mina Almasry
2026-12-04 23:10 ` [PATCH net-next v5 2/6] net: devmem: fold net_devmem_lookup_dmabuf() into net_devmem_get_binding() Mina Almasry
2026-12-04 23:10 ` [PATCH net-next v5 3/6] net: devmem: resolve leased RX queues to physical device on bind Mina Almasry
2026-12-04 23:10 ` [PATCH net-next v5 4/6] net: devmem: synchronize and unmap all device bindings on unregister Mina Almasry
2026-12-04 23:10 ` Mina Almasry [this message]
2026-12-04 23:10 ` [PATCH net-next v5 6/6] selftests: net: add leased devmem RX and TX netdev unregister tests Mina Almasry
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=20261204231030.3815575-6-almasrymina@google.com \
--to=almasrymina@google.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=bestswngs@gmail.com \
--cc=bobbyeshleman@meta.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dw@davidwei.uk \
--cc=edumazet@kernel.org \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=io-uring@vger.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 \
--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