Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH] net/rds: drop the device reference for ODP memory regions
@ 2026-11-04  2:28 Wentao Liang
  2026-11-04  2:33 ` netdev-bot+sinfo
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Wentao Liang @ 2026-11-04  2:28 UTC (permalink / raw)
  To: Allison Henderson, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman
  Cc: netdev, linux-rdma, rds-devel

rds_ib_get_mr() takes a reference on the rds_ib_device with
rds_ib_get_device().  The FRMR path stores it in ibmr->device and
rds_ib_free_mr() drops it when the MR is freed.

The ODP path allocates the ibmr with kzalloc_obj() and returns it
without recording the device.  rds_ib_odp_mr_worker() only deregisters
the MR and frees the ibmr, so the reference taken for every ODP MR is
never dropped and the rds_ib_device can no longer be released.

Store the reference in ibmr->device and drop it in the worker after
the MR has been deregistered, which also keeps the device and its PD
alive for as long as the MR exists.

Fixes: 2eafa1746f17 ("net/rds: Handle ODP mr registration/unregistration")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 net/rds/ib_rdma.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/rds/ib_rdma.c b/net/rds/ib_rdma.c
index db7e92e7bd29..8cd8295f66a3 100644
--- a/net/rds/ib_rdma.c
+++ b/net/rds/ib_rdma.c
@@ -591,6 +591,7 @@ void *rds_ib_get_mr(struct scatterlist *sg, unsigned long nents,
 		}
 		ibmr->u.mr = ib_mr;
 		ibmr->odp = 1;
+		ibmr->device = rds_ibdev;
 
 		sge.addr = virt_addr;
 		sge.length = length;
@@ -697,5 +698,6 @@ static void rds_ib_odp_mr_worker(struct work_struct  *work)
 
 	ibmr = container_of(work, struct rds_ib_mr, work.work);
 	ib_dereg_mr(ibmr->u.mr);
+	rds_ib_dev_put(ibmr->device);
 	kfree(ibmr);
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-05  2:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04  2:28 [PATCH] net/rds: drop the device reference for ODP memory regions Wentao Liang
2026-11-04  2:33 ` netdev-bot+sinfo
2026-11-04  7:11 ` Krzysztof Kozlowski
2026-11-04 22:15 ` Allison Henderson
2026-11-05  2:28 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox