[PATCH 2/2] nvme-tcp: lockdep: use dynamic lockdep keys per socket instance

Shin'ichiro Kawasaki shinichiro.kawasaki at wdc.com
Wed Jun 3 04:00:26 PDT 2026


On Jun 02, 2026 / 11:13, Keith Busch wrote:
> On Sat, May 30, 2026 at 02:20:45PM +0900, Shin'ichiro Kawasaki wrote:
> > -static void nvme_tcp_reclassify_socket(struct socket *sock)
> > +static void nvme_tcp_reclassify_socket(struct nvme_tcp_queue *queue)
> >  {
> > -	struct sock *sk = sock->sk;
> > +	struct sock *sk = queue->sock->sk;
> > +
> > +	lockdep_register_key(&queue->nvme_tcp_sk_key);
> > +	lockdep_register_key(&queue->nvme_tcp_slock_key);
> 
> ...
> 
> > @@ -1468,6 +1473,11 @@ static void nvme_tcp_free_queue(struct nvme_ctrl *nctrl, int qid)
> >  	kfree(queue->pdu);
> >  	mutex_destroy(&queue->send_mutex);
> >  	mutex_destroy(&queue->queue_lock);
> > +
> > +#ifdef CONFIG_DEBUG_LOCK_ALLOC
> > +	lockdep_unregister_key(&queue->nvme_tcp_sk_key);
> > +	lockdep_unregister_key(&queue->nvme_tcp_slock_key);
> > +#endif
> >  }
> >  
> >  static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue)
> > @@ -1813,7 +1823,7 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid,
> >  	}
> >  
> >  	sk_net_refcnt_upgrade(queue->sock->sk);
> > -	nvme_tcp_reclassify_socket(queue->sock);
> > +	nvme_tcp_reclassify_socket(queue);
> 
> On a subsequent error in this function, I think you need to call
> lockdep_unregister_key directly in on of the goto error cases since we
> don't call nvme_tcp_free_queue for this failed queue.

Thank you for point it out. lockdep_unregister_key() calls are required in the
error paths. I will add them in v2.



More information about the Linux-nvme mailing list