[PATCH v2] nvme-tcp: lockdep: use dynamic lockdep keys per socket instance
Nilay Shroff
nilay at linux.ibm.com
Wed Jun 3 05:19:24 PDT 2026
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,
--Nilay
More information about the Linux-nvme
mailing list