[PATCH] nvmet-rdma: Avoid o(n^2) loop in delete_ctrl

Christoph Hellwig hch at lst.de
Sun May 5 22:50:20 PDT 2024


On Sun, May 05, 2024 at 01:39:44PM +0300, Sagi Grimberg wrote:
> From: Sagi Grimberg <sagi.grimberg at vastdata.com>
> 
> When deleting a nvmet-rdma ctrl, we essentially loop over all
> queues that belong to the controller and schedule a removal of
> each. Instead of restarting the loop every time a queue is found,
> do a simple safe list traversal.
> 
> This addresses an unneeded time spent scheduling queue removal in
> cases there a lot of queues.

I think the original reason for this was to avoid lock order dependencies
and/or deadlocks, I wish I would have documented that better.  Looking at
the current version __nvmet_rdma_queue_disconnect I can't find any
obvious problem, but rdma_disconnect is a bit of a block box from
the driver POV.  Did you test this extensively with lockdep enabled?

> +	list_for_each_entry_safe(queue, tmp, &nvmet_rdma_queue_list, queue_list) {

Nit: overly long line here.  Maybe just rename tmp to n?




More information about the Linux-nvme mailing list