From: sashiko-bot@kernel.org
To: "Aibing Chen" <chenaibing@cmss.chinamobile.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH net v4] net/rds: defer CM id destruction to a workqueue
Date: Mon, 30 Nov 2026 09:42:49 +0000 [thread overview]
Message-ID: <sashiko-outbox-240799@kernel.org> (raw)
In-Reply-To: <20261129094231.1368-1-chenaibing@cmss.chinamobile.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] net/rds: rds_ib_probe_pending used before declaration in
rds_ib_destroy_id_work()
- [Medium] net/rds: silent TCP fallback and lost -EAGAIN when
rds_ib_laddr_check_cm() hits cap
- [Medium] net/rds: deferred cm_id destroy cap breaks
rds_trans_get_preferred()
--
commit 5d5ae2e4ce33977f5f5c4a838c5ab4ec75ae672a
Author: Aibing Chen <chenaibing@cmss.chinamobile.com>
net/rds: defer CM id destruction to a workqueue
This commit defers rdma_destroy_id() in rds_ib_laddr_check_cm() to rds_wq
to avoid taking handler_mutex while holding rds_trans_sem, caps pending
probe destroys at 64, and flushes rds_wq in rds_ib_exit().
> diff --git a/net/rds/ib.c b/net/rds/ib.c
> index 4ea9838d090c3..b83220de964ca 100644
> --- a/net/rds/ib.c
> +++ b/net/rds/ib.c
> @@ -391,6 +391,31 @@ static void rds6_ib_ic_info(struct socket *sock, unsigned int len,
> }
> #endif
>
> +struct rds_ib_destroy_work {
> + struct work_struct work;
> + struct rdma_cm_id *cm_id;
> +};
> +
> +static void rds_ib_destroy_id_work(struct work_struct *work)
> +{
> + struct rds_ib_destroy_work *w =
> + container_of(work, struct rds_ib_destroy_work, work);
> +
> + rdma_destroy_id(w->cm_id);
> + kfree(w);
> +
> + /* Matched by the decrement in this function. */
> + atomic_dec(&rds_ib_probe_pending);
> +}
> +
> +/*
> + * Bound the number of probe cm_ids pending destruction on rds_wq: each
> + * holds a rdma_id_private, a cma_dev reference and an ephemeral
> + * RDMA_PS_TCP port until the worker runs.
> + */
> +#define RDS_IB_MAX_PROBE_PENDING 64
> +static atomic_t rds_ib_probe_pending = ATOMIC_INIT(0);
[Severity: High]
Does rds_ib_destroy_id_work() reference rds_ib_probe_pending before it is
declared, breaking compilation when CONFIG_RDS_RDMA is enabled? Also, the
comment above atomic_dec() says "Matched by the decrement in this
function" rather than the increment in rds_ib_laddr_check_cm().
> @@ -411,14 +436,42 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
> #endif
> struct sockaddr_in sin;
> struct sockaddr *sa;
> + struct rds_ib_destroy_work *w;
> bool isv4;
>
> + /*
> + * Bound the probe backlog: each queued destroy pins the cm_id, a
> + * cma_dev reference and an ephemeral RDMA_PS_TCP port until the
> + * worker runs.
> + */
> + if (atomic_inc_return(&rds_ib_probe_pending) > RDS_IB_MAX_PROBE_PENDING) {
> + atomic_dec(&rds_ib_probe_pending);
> + return -EAGAIN;
> + }
[Severity: Medium]
Can returning -EAGAIN here cause rds_trans_get_preferred() to silently
demote an IPoIB socket to rds_tcp_transport?
rds_trans_get_preferred() checks only whether trans->laddr_check() == 0,
so any non-zero return from rds_ib_laddr_check() is treated as a transport
mismatch rather than a transient error:
net/rds/transport.c:rds_trans_get_preferred() {
...
for (i = 0; i < RDS_TRANS_COUNT; i++) {
trans = transports[i];
if (trans && (trans->laddr_check(net, addr, scope_id) == 0) &&
(!trans->t_owner || try_module_get(trans->t_owner))) {
ret = trans;
break;
}
}
...
}
Once 64 probe destroys are queued on the single-threaded rds_wq (from
concurrent binds or new connections calling rds_trans_get_preferred() in
__rds_conn_create()), rds_trans_get_preferred() falls through from
RDS_TRANS_IB to RDS_TRANS_TCP, where rds_tcp_laddr_check() accepts any
local IPv4 or IPv6 address and permanently binds IPoIB sockets to TCP
(or fails rds_bind() with -EADDRNOTAVAIL / -ENOPROTOOPT when rds_tcp is
not used, and leaves conn->c_loopback unset in __rds_conn_create()).
> + isv4 = ipv6_addr_v4mapped(addr);
> +
> + w = kzalloc_obj(*w, GFP_KERNEL);
> + if (!w) {
> + atomic_dec(&rds_ib_probe_pending);
> + return -ENOMEM;
> + }
> +
> /* Create a CMA ID restricted to IB devices and try to bind it. */
> cm_id = rdma_create_id(&init_net, rds_rdma_cm_event_handler,
> NULL, RDMA_PS_TCP, IB_QPT_RC);
> - if (IS_ERR(cm_id))
> + if (IS_ERR(cm_id)) {
> + kfree(w);
> + atomic_dec(&rds_ib_probe_pending);
> return PTR_ERR(cm_id);
> + }
> +
> + /*
> + * The id is destroyed from rds_wq: rds_trans_get_preferred() calls this
> + * function with rds_trans_sem held for reading, and rdma_destroy_id()
> + * takes handler_mutex, which the CM callback path acquires before
> + * taking rds_trans_sem.
> + */
> ret = rdma_restrict_node_type(cm_id, RDMA_NODE_IB_CA);
> if (ret)
> goto out;
> @@ -484,7 +537,9 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
> cm_id->device ? cm_id->device->node_type : -1);
>
> out:
> - rdma_destroy_id(cm_id);
> + INIT_WORK(&w->work, rds_ib_destroy_id_work);
> + w->cm_id = cm_id;
> + queue_work(rds_wq, &w->work);
[Severity: Medium]
As reported by Allison Henderson on v4 [1], could rds_trans_get_preferred()
take the module reference under rds_trans_sem and drop rds_trans_sem before
calling trans->laddr_check(), instead of deferring rdma_destroy_id() to
rds_wq?
Destroying the probe cm_id synchronously with rds_trans_sem released avoids
taking handler_mutex under rds_trans_sem without needing workqueue deferral
or the 64-probe cap that breaks transport selection in
rds_trans_get_preferred(). In addition, because the probe cm_id is created
with a NULL context and never listens, its callbacks in
rds_rdma_cm_event_handler_cmn() never acquire rds_trans_sem, so the commit
message should describe the issue as a class-level lockdep report rather
than a runtime deadlock.
[1] https://lore.kernel.org/r/d83709308a038467b3a4849d814978b84328d2bc.camel@kernel.org
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129094231.1368-1-chenaibing@cmss.chinamobile.com?part=1
next prev parent reply other threads:[~2026-11-30 9:42 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 15:05 [PATCH] RDMA/cma: add rdma_destroy_id_wq() and use it from RDS Aibing Chen
2026-11-15 0:18 ` Jason Gunthorpe
2026-11-16 6:47 ` Allison Henderson
2026-11-15 15:05 ` sashiko-bot
2026-11-16 7:54 ` [PATCH net v2] net/rds: defer CM id destruction to a workqueue Aibing Chen
2026-11-17 6:15 ` Allison Henderson
2026-11-17 7:54 ` sashiko-bot
2026-11-17 8:21 ` [PATCH net v3] " Aibing Chen
2026-11-17 8:33 ` sashiko-bot
2026-11-21 8:37 ` netdev-bot+sashiko
2026-11-29 9:42 ` [PATCH net v4] " Aibing Chen
2026-11-29 16:08 ` kernel test robot
2026-11-29 20:25 ` kernel test robot
2026-11-30 9:42 ` sashiko-bot [this message]
2026-11-17 8:35 ` [PATCH net v2] " netdev-bot+sashiko
2026-11-19 6:33 ` Allison Henderson
-- strict thread matches above, loose matches on Subject: below --
2026-11-22 14:51 [PATCH net v4] " Aibing Chen
2026-11-23 14:52 ` sashiko-bot
2026-11-23 15:35 ` netdev-bot+sashiko
2026-11-26 2:36 ` Allison Henderson
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-240799@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=chenaibing@cmss.chinamobile.com \
--cc=linux-rdma@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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