From: sashiko-bot@kernel.org
To: "Wentao Liang" <vulab@iscas.ac.cn>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH] net/rds: drop the device reference for ODP memory regions
Date: Thu, 05 Nov 2026 02:28:17 +0000 [thread overview]
Message-ID: <sashiko-outbox-198462@kernel.org> (raw)
In-Reply-To: <20261104022810.1484182-1-vulab@iscas.ac.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net/rds: rds_ib_odp_mr_worker() queues rds_ib_dev_free() after rds_wq flush
--
commit 867b786572304fe8059ffdca78162ac460e2ac8e
Author: Wentao Liang <vulab@iscas.ac.cn>
net/rds: drop the device reference for ODP memory regions
This patch stores the rds_ib_device reference in ibmr->device when registering
an ODP memory region in rds_ib_get_mr() and drops it in rds_ib_odp_mr_worker()
after deregistering the MR.
> diff --git a/net/rds/ib_rdma.c b/net/rds/ib_rdma.c
> index db7e92e7bd29f..8cd8295f66a39 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);
[Severity: High]
Could dropping ibmr->device from rds_ib_odp_mr_worker() on rds_ib_mr_wq cause
rds_ib_dev_free() to be queued onto rds_wq after rds_ib_unregister_client()
has already flushed rds_wq during module unload?
Unlike FRMRs, which call rds_ib_dev_put() synchronously in rds_ib_free_mr(),
ODP MRs defer teardown to rds_ib_mr_wq:
net/rds/ib_rdma.c:rds_ib_free_mr() {
if (ibmr->odp) {
INIT_DELAYED_WORK(&ibmr->work, rds_ib_odp_mr_worker);
queue_delayed_work(rds_ib_mr_wq, &ibmr->work, 0);
return;
}
}
When the last RDS socket closes via rds_release() -> rds_rdma_drop_keys() ->
rds_ib_free_mr() (or rds_send_drop_to() -> rds_rdma_free_op() ->
rds_ib_free_mr()), rds_ib_flush_mrs() only flushes mr_8k_pool and mr_1m_pool
without flushing rds_ib_mr_wq before rds_release() drops the transport module
reference.
If the rds_rdma module is then unloaded, rds_ib_exit() runs
rds_ib_unregister_client() before rds_ib_mr_exit():
net/rds/ib.c:rds_ib_unregister_client() {
ib_unregister_client(&rds_ib_client);
/* wait for rds_ib_dev_free() to complete */
flush_workqueue(rds_wq);
}
net/rds/ib.c:rds_ib_exit() {
...
rds_ib_unregister_client();
rds_ib_destroy_nodev_conns();
rds_ib_sysctl_exit();
rds_ib_recv_exit();
rds_trans_unregister(&rds_ib_transport);
rds_ib_mr_exit();
}
If rds_ib_odp_mr_worker() is still pending on rds_ib_mr_wq when
rds_ib_unregister_client() runs, rds_ibdev->refcount will not drop to zero in
rds_ib_remove_one(), so rds_ibdev->free_work is not queued yet when
flush_workqueue(rds_wq) returns.
Then, at the end of rds_ib_exit(), rds_ib_mr_exit() calls
destroy_workqueue(rds_ib_mr_wq), which drains rds_ib_odp_mr_worker() and calls
rds_ib_dev_put(ibmr->device):
net/rds/ib.c:rds_ib_dev_put() {
BUG_ON(refcount_read(&rds_ibdev->refcount) == 0);
if (refcount_dec_and_test(&rds_ibdev->refcount))
queue_work(rds_wq, &rds_ibdev->free_work);
}
Wouldn't that queue rds_ibdev->free_work (rds_ib_dev_free) onto rds_wq right
as rds_ib_exit() returns, allowing rds_ib_dev_free() to execute after
rds_ib_mr_wq is destroyed, after ib_unregister_client() has completed, and
after the rds_rdma module is unmapped?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261104022810.1484182-1-vulab@iscas.ac.cn?part=1
next prev parent reply other threads:[~2026-11-05 2:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
2026-11-08 3:04 ` netdev-bot+sashiko
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=sashiko-outbox-198462@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vulab@iscas.ac.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.