[PATCH RFC 2/2] nvmet-rdma: use a separate lockdep class for the listening cm_id

Shin'ichiro Kawasaki shinichiro.kawasaki at wdc.com
Tue Nov 10 21:01:58 PST 2026


Jason, thank you for the comments.

On Nov 09, 2026 / 20:32, Jason Gunthorpe wrote:
> On Sun, Nov 08, 2026 at 09:01:54PM +0900, Shin'ichiro Kawasaki wrote:
> > @@ -1914,6 +1914,8 @@ static int nvmet_rdma_enable_port(struct nvmet_rdma_port *port)
> >  		return PTR_ERR(cm_id);
> >  	}
> >  
> > +	rdma_reclassify_id_for_listen(cm_id);
> > +
> 
> It seems like a flag or new function for the create would make more
> sense,

I see, new function approach sounds better than this patch.

> and if this is the right fix then all the callers with the
> pattern of rdma_create_id() .. rdma_listen() should be fixed too?

I agree that it is ideal to apply the same change to the all the callers.

> 
> I suppose we cannot change the lock class in rdma_listen ?

Oh, this approach sounds the best. It modifies only RDMA driver, and can cover
all the callers. I did a quick trial with the change below, and confirmed it
avoids the WARN. So this approach works well :)  I will wait some more days for
comments. If there is no other voices, I will post this solution as a formal
patch.

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 337a49d1acf7..334f39c2f5e5 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -3949,6 +3949,12 @@ int rdma_listen(struct rdma_cm_id *id, int backlog)
 		container_of(id, struct rdma_id_private, id);
 	int ret;
 
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+	static struct lock_class_key cma_listen_handler_mutex_key;
+	lockdep_set_class(&id_priv->handler_mutex,
+			  &cma_listen_handler_mutex_key);
+#endif
+
 	if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_LISTEN)) {
 		struct sockaddr_in any_in = {
 			.sin_family = AF_INET,



More information about the Linux-nvme mailing list