Skip to contentSkip to conversation

nvme-multipath: optimize path selection in queue-depth policy

RFC PATCH In review Xose Vazquez Perez 2 participants 2 messages May 6

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 nvme-multipath: optimize path selection in queue-depth policy

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 <[email protected]>
Cc Bart Van Assche <[email protected]>
Cc Benjamin Marzinski <[email protected]>
Cc Brian Bunker <[email protected]>
Cc Caleb Sander <[email protected]>
Cc Chaitanya Kulkarni <[email protected]>
Cc Chris Leech <[email protected]>
Cc Christophe Varoqui <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Clayton Skaggs <[email protected]>
Cc Constantine Gavrilov <[email protected]>
Cc Daniel Wagner <[email protected]>
Cc David Santamaría Rogado <[email protected]>
Cc Dmitry V. Levin <[email protected]>
Cc Ewan D. Milne <[email protected]>
Cc Ewan Milne <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc James Smart <[email protected]>
Cc Jens Axboe <[email protected]>
Cc John Meneghini <[email protected]>
Cc Jyoti Rani <[email protected]>
Cc Keith Busch <[email protected]>
Cc Li Xiaokeng <[email protected]>
Cc Marco Patalano <[email protected]>
Cc Martin Belanger <[email protected]>
Cc Martin George <[email protected]>
Cc Martin Wilck <[email protected]>
Cc Matthias Rudolph <[email protected]>
Cc Maurizio Lombardi <[email protected]>
Cc NetApp RDAC team <[email protected]>
Cc Nilay Shroff <[email protected]>
Cc Randy Jennings <[email protected]>
Cc Sagi Grimberg <[email protected]>
Cc Simon Schricker <[email protected]>
Cc Steven Schremmer <[email protected]>
Cc Thomas Song <[email protected]>
Cc Uday Shankar <[email protected]>
Cc Vasuki Manikarnike <[email protected]>
Cc Wayne Berthiaume <[email protected]>
Cc Zou Ming <[email protected]>
Cc BLOCK-ML <[email protected]>
Cc DM_DEVEL-ML <[email protected]>
Cc NVME-ML <[email protected]>
Cc SCSI-ML <[email protected]>

---
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(-)
drivers/nvme/host/multipath.c +3 -4
index 263161cb8ac0..7d212f6e865d 100644
@@ -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;
 }
 
Signature · 1 line
2.54.0
maintainer
#1 lore raw
Quoted 4 lines · Xose Vazquez Perez

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.

The existing code is already well optimized, and even gcc figures out that the min_depth_opt is only updated in the case as it is.

Quoted 36 lines
Cc Aviv Coro <[email protected]>
Cc Bart Van Assche <[email protected]>
Cc Benjamin Marzinski <[email protected]>
Cc Brian Bunker <[email protected]>
Cc Caleb Sander <[email protected]>
Cc Chaitanya Kulkarni <[email protected]>
Cc Chris Leech <[email protected]>
Cc Christophe Varoqui <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Clayton Skaggs <[email protected]>
Cc Constantine Gavrilov <[email protected]>
Cc Daniel Wagner <[email protected]>
Cc David Santamaría Rogado <[email protected]>
Cc Dmitry V. Levin <[email protected]>
Cc Ewan D. Milne <[email protected]>
Cc Ewan Milne <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc James Smart <[email protected]>
Cc Jens Axboe <[email protected]>
Cc John Meneghini <[email protected]>
Cc Jyoti Rani <[email protected]>
Cc Keith Busch <[email protected]>
Cc Li Xiaokeng <[email protected]>
Cc Marco Patalano <[email protected]>
Cc Martin Belanger <[email protected]>
Cc Martin George <[email protected]>
Cc Martin Wilck <[email protected]>
Cc Matthias Rudolph <[email protected]>
Cc Maurizio Lombardi <[email protected]>
Cc NetApp RDAC team <[email protected]>
Cc Nilay Shroff <[email protected]>
Cc Randy Jennings <[email protected]>
Cc Sagi Grimberg <[email protected]>
Cc Simon Schricker <[email protected]>
Cc Steven Schremmer <[email protected]>
Cc Thomas Song <[email protected]>
Quoted 8 lines
Cc Uday Shankar <[email protected]>
Cc Vasuki Manikarnike <[email protected]>
Cc Wayne Berthiaume <[email protected]>
Cc Zou Ming <[email protected]>
Cc BLOCK-ML <[email protected]>
Cc DM_DEVEL-ML <[email protected]>
Cc NVME-ML <[email protected]>
Cc SCSI-ML <[email protected]>

This is quite an eggregious CC list...

Quoted 3 lines

Status: Compile-tested only. UNTESTED on real hardware.

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

What compelled you to propose this change, then?