[PATCH v2] nvme-tcp: lockdep: use dynamic lockdep keys per socket instance
Shin'ichiro Kawasaki
shinichiro.kawasaki at wdc.com
Wed Jun 3 19:26:35 PDT 2026
On Jun 03, 2026 / 17:49, Nilay Shroff wrote:
> On 6/3/26 4:55 PM, Shin'ichiro Kawasaki wrote:
> > static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue)
> > @@ -1813,7 +1818,12 @@ 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);
> > +
> > +#ifdef CONFIG_DEBUG_LOCK_ALLOC
> > + lockdep_register_key(&queue->nvme_tcp_sk_key);
> > + lockdep_register_key(&queue->nvme_tcp_slock_key);
> > + nvme_tcp_reclassify_socket(queue);
> > +#endif
> > /* Single syn retry */
> > tcp_sock_set_syncnt(queue->sock->sk, 1);
> > @@ -1921,6 +1931,11 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid,
> > err_destroy_mutex:
> > 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
> > return ret;
> > }
>
> I think we shouldn't call lockdep_unregister_key() from under err_destroy_mutex
> label, and instead it should be moved just before the err_destroy_mutex label.
> The reason being, when the code jumps to err_destroy_mutex label, it hasn't
> yet registered those lockdep keys.
Thanks for pointing it out. I overlooked the label. Will send out v3 moving the
lockdep_unregister_key() calls before the err_destroy_mutex label.
More information about the Linux-nvme
mailing list