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

Keith Busch kbusch at kernel.org
Tue Jun 2 03:13:02 PDT 2026


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.



More information about the Linux-nvme mailing list