Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: vulab@iscas.ac.cn
Cc: achender@kernel.org, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	rds-devel@oss.oracle.com
Subject: Re: [PATCH] net/rds: drop the device reference for ODP memory regions
Date: Sun, 08 Nov 2026 03:04:37 +0000	[thread overview]
Message-ID: <179410707739.994134.10076645291252563935@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.

Critical: 0 · High: 1 · Medium: 0 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The patch adds rds_ib_dev_put(ibmr->device) to
  rds_ib_odp_mr_worker() (net/rds/ib_rdma.c:701).

--

net/rds: drop the device reference for ODP memory regions

The ODP path in rds_ib_get_mr() takes a reference on the rds_ib_device
but never stores or drops it, so the reference leaks. This patch stores
the device in ibmr->device. It drops the reference in
rds_ib_odp_mr_worker() after the MR has been deregistered.

> 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

[ ... ]

> @@ -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]

Can this put now race with unloading the rds_rdma module?

After this change, the ODP worker on rds_ib_mr_wq can drop the last
rds_ib_device reference. The final put queues module code on rds_wq,
and rds_wq belongs to rds core:

net/rds/ib.c:rds_ib_dev_put() {
	...
	if (refcount_dec_and_test(&rds_ibdev->refcount))
		queue_work(rds_wq, &rds_ibdev->free_work);
}

The exit path flushes rds_wq only once, in rds_ib_unregister_client().
That happens before rds_ib_mr_wq is drained:

rds_ib_exit()
    rds_ib_unregister_client()
        ib_unregister_client(&rds_ib_client);
        /* wait for rds_ib_dev_free() to complete */
        flush_workqueue(rds_wq);
    rds_ib_destroy_nodev_conns();
    ...
    rds_ib_mr_exit()
        destroy_workqueue(rds_ib_mr_wq);

An ODP worker can still be pending when that flush runs. For example,
closing an RDS socket that owns an ODP MR goes through:

rds_release()
    rds_rdma_drop_keys()
        __rds_put_mr_final()
            rds_destroy_mr()
                rds_ib_free_mr()
                    queue_delayed_work(rds_ib_mr_wq, &ibmr->work, 0);
    ...
    rds_trans_put(rs->rs_transport);

Once rds_trans_put() drops the module reference, rmmod rds_rdma can go
ahead while that worker is still queued.

ODP workers can also be queued after the rds_wq flush. Messages on
nodev connections that carry op_odp_mr go through
rds_ib_destroy_nodev_conns() -> rds_conn_destroy() -> rds_rdma_free_op().

The worker might run on its own, or be drained by destroy_workqueue() in
rds_ib_mr_exit(). Either way, if it drops the final reference,
rds_ib_dev_free() is queued on rds_wq and nothing waits for it.

Could that work then run after the rds_rdma module text has been freed,
and touch the pools and PD after the module is gone?

Before this patch the ODP reference was leaked, so this ordering could
not happen. The comment above rds_ib_mr_exit() says the pool flushing
work queue should be idle by then, and that no longer seems to hold.

Would it make sense to flush rds_ib_mr_wq before the
flush_workqueue(rds_wq) in rds_ib_unregister_client()? Another option
would be to flush rds_wq again after rds_ib_mr_exit().

>  	kfree(ibmr);
>  }

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261104022810.1484182-1-vulab%40iscas.ac.cn

      parent reply	other threads:[~2026-11-08  3:04 UTC|newest]

Thread overview: 5+ 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-08  3:04 ` netdev-bot+sashiko [this message]

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=179410707739.994134.10076645291252563935@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=achender@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rds-devel@oss.oracle.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox