Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Xose Vazquez Perez <xose.vazquez@gmail.com>
Cc: "Xose Vazquez Perez" <xose.vazquez@gmail.com>,
	"Aviv Coro" <aviv.coro@ibm.com>,
	"Bart Van Assche" <bvanassche@acm.org>,
	"Benjamin Marzinski" <bmarzins@redhat.com>,
	"Brian Bunker" <brian@purestorage.com>,
	"Caleb Sander" <csander@purestorage.com>,
	"Chaitanya Kulkarni" <kch@nvidia.com>,
	"Chris Leech" <cleech@redhat.com>,
	"Christophe Varoqui" <christophe.varoqui@opensvc.com>,
	"Christoph Hellwig" <hch@lst.de>,
	"Clayton Skaggs" <claytons@netapp.com>,
	"Constantine Gavrilov" <cgavrilov@infinidat.com>,
	"Daniel Wagner" <wagi@kernel.org>,
	"David Santamaría Rogado" <howl.nsp@gmail.com>,
	"Dmitry V. Levin" <ldv@strace.io>,
	"Ewan D. Milne" <emilne@redhat.com>,
	"Hannes Reinecke" <hare@suse.de>,
	"James Smart" <jsmart2021@gmail.com>,
	"Jens Axboe" <axboe@kernel.dk>,
	"John Meneghini" <jmeneghi@redhat.com>,
	"Jyoti Rani" <jrani@purestorage.com>,
	"Keith Busch" <kbusch@kernel.org>,
	"Li Xiaokeng" <lixiaokeng@huawei.com>,
	"Marco Patalano" <mpatalan@redhat.com>,
	"Martin Belanger" <martin.belanger@dell.com>,
	"Martin George" <Martin.George@netapp.com>,
	"Martin Wilck" <mwilck@suse.com>,
	"Matthias Rudolph" <Matthias.Rudolph@hitachivantara.com>,
	"Maurizio Lombardi" <mlombard@arkamax.eu>,
	"NetApp RDAC team" <ng-eseries-upstream-maintainers@netapp.com>,
	"Nilay Shroff" <nilay@linux.ibm.com>,
	"Randy Jennings" <randyj@purestorage.com>,
	"Sagi Grimberg" <sagi@grimberg.me>,
	"Simon Schricker" <sschricker@suse.de>,
	"Steven Schremmer" <Steve.Schremmer@netapp.com>,
	"Thomas Song" <tsong@purestorage.com>,
	"Uday Shankar" <ushankar@purestorage.com>,
	"Vasuki Manikarnike" <vasuki.manikarnike@hpe.com>,
	"Wayne Berthiaume" <Wayne.Berthiaume@dell.com>,
	"Zou Ming" <zouming.zouming@huawei.com>,
	BLOCK-ML <linux-block@vger.kernel.org>,
	DM_DEVEL-ML <dm-devel@lists.linux.dev>,
	NVME-ML <linux-nvme@lists.infradead.org>,
	SCSI-ML <linux-scsi@vger.kernel.org>
Subject: [PATCH RFC] nvme-multipath: optimize path selection in queue-depth policy
Date: Wed,  6 May 2026 16:15:41 +0200	[thread overview]
Message-ID: <20260506141544.125089-1-xose.vazquez@gmail.com> (raw)

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


                 reply	other threads:[~2026-05-06 14:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260506141544.125089-1-xose.vazquez@gmail.com \
    --to=xose.vazquez@gmail.com \
    --cc=Martin.George@netapp.com \
    --cc=Matthias.Rudolph@hitachivantara.com \
    --cc=Steve.Schremmer@netapp.com \
    --cc=Wayne.Berthiaume@dell.com \
    --cc=aviv.coro@ibm.com \
    --cc=axboe@kernel.dk \
    --cc=bmarzins@redhat.com \
    --cc=brian@purestorage.com \
    --cc=bvanassche@acm.org \
    --cc=cgavrilov@infinidat.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=claytons@netapp.com \
    --cc=cleech@redhat.com \
    --cc=csander@purestorage.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=emilne@redhat.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=howl.nsp@gmail.com \
    --cc=jmeneghi@redhat.com \
    --cc=jrani@purestorage.com \
    --cc=jsmart2021@gmail.com \
    --cc=kbusch@kernel.org \
    --cc=kch@nvidia.com \
    --cc=ldv@strace.io \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=lixiaokeng@huawei.com \
    --cc=martin.belanger@dell.com \
    --cc=mlombard@arkamax.eu \
    --cc=mpatalan@redhat.com \
    --cc=mwilck@suse.com \
    --cc=ng-eseries-upstream-maintainers@netapp.com \
    --cc=nilay@linux.ibm.com \
    --cc=randyj@purestorage.com \
    --cc=sagi@grimberg.me \
    --cc=sschricker@suse.de \
    --cc=tsong@purestorage.com \
    --cc=ushankar@purestorage.com \
    --cc=vasuki.manikarnike@hpe.com \
    --cc=wagi@kernel.org \
    --cc=zouming.zouming@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox