[PATCH RFC] nvme-multipath: optimize path selection in queue-depth policy

Xose Vazquez Perez xose.vazquez at gmail.com
Wed May 6 07:15:41 PDT 2026


Move the zero-depth check inside the optimized path case to enable early
exit. It avoids redundant condition checks for non-optimized paths, and
eliminates the per-iteration check at the end of the loop, improving the
performance.

Cc: Aviv Coro <aviv.coro at ibm.com>
Cc: Bart Van Assche <bvanassche at acm.org>
Cc: Benjamin Marzinski <bmarzins at redhat.com>
Cc: Brian Bunker <brian at purestorage.com>
Cc: Caleb Sander <csander at purestorage.com>
Cc: Chaitanya Kulkarni <kch at nvidia.com>
Cc: Chris Leech <cleech at redhat.com>
Cc: Christophe Varoqui <christophe.varoqui at opensvc.com>
Cc: Christoph Hellwig <hch at lst.de>
Cc: Clayton Skaggs <claytons at netapp.com>
Cc: Constantine Gavrilov <cgavrilov at infinidat.com>
Cc: Daniel Wagner <wagi at kernel.org>
Cc: David Santamaría Rogado <howl.nsp at gmail.com>
Cc: Dmitry V. Levin <ldv at strace.io>
Cc: Ewan D. Milne <emilne at redhat.com>
Cc: Ewan Milne <emilne at redhat.com>
Cc: Hannes Reinecke <hare at suse.de>
Cc: James Smart <jsmart2021 at gmail.com>
Cc: Jens Axboe <axboe at kernel.dk>
Cc: John Meneghini <jmeneghi at redhat.com>
Cc: Jyoti Rani <jrani at purestorage.com>
Cc: Keith Busch <kbusch at kernel.org>
Cc: Li Xiaokeng <lixiaokeng at huawei.com>
Cc: Marco Patalano <mpatalan at redhat.com>
Cc: Martin Belanger <martin.belanger at dell.com>
Cc: Martin George <Martin.George at netapp.com>
Cc: Martin Wilck <mwilck at suse.com>
Cc: Matthias Rudolph <Matthias.Rudolph at hitachivantara.com>
Cc: Maurizio Lombardi <mlombard at arkamax.eu>
Cc: NetApp RDAC team <ng-eseries-upstream-maintainers at netapp.com>
Cc: Nilay Shroff <nilay at linux.ibm.com>
Cc: Randy Jennings <randyj at purestorage.com>
Cc: Sagi Grimberg <sagi at grimberg.me>
Cc: Simon Schricker <sschricker at suse.de>
Cc: Steven Schremmer <Steve.Schremmer at netapp.com>
Cc: Thomas Song <tsong at purestorage.com>
Cc: Uday Shankar <ushankar at purestorage.com>
Cc: Vasuki Manikarnike <vasuki.manikarnike at hpe.com>
Cc: Wayne Berthiaume <Wayne.Berthiaume at dell.com>
Cc: Zou Ming <zouming.zouming at huawei.com>
Cc: BLOCK-ML <linux-block at vger.kernel.org>
Cc: DM_DEVEL-ML <dm-devel at lists.linux.dev>
Cc: NVME-ML <linux-nvme at lists.infradead.org>
Cc: SCSI-ML <linux-scsi at vger.kernel.org>
Signed-off-by: Xose Vazquez Perez <xose.vazquez at gmail.com>
---
Status: Compile-tested only. UNTESTED on real hardware.

[I do not have access to this kind of hardware]

Feedback and testing are highly welcome.
---
 drivers/nvme/host/multipath.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 263161cb8ac0..7d212f6e865d 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -409,6 +409,8 @@ static struct nvme_ns *nvme_queue_depth_path(struct nvme_ns_head *head)
 				min_depth_opt = depth;
 				best_opt = ns;
 			}
+			if (min_depth_opt == 0)
+				goto out;
 			break;
 		case NVME_ANA_NONOPTIMIZED:
 			if (depth < min_depth_nonopt) {
@@ -419,11 +421,8 @@ static struct nvme_ns *nvme_queue_depth_path(struct nvme_ns_head *head)
 		default:
 			break;
 		}
-
-		if (min_depth_opt == 0)
-			return best_opt;
 	}
-
+out:
 	return best_opt ? best_opt : best_nonopt;
 }
 
-- 
2.54.0




More information about the Linux-nvme mailing list