nvme: queue-depth multipath iopolicy
v4 cover nvme: queue-depth multipath iopolicy
Sorry this took so long. I've fixed everything up and rebased this (again) onto nvme-6.10 so as to pick up Keith's 'io accounting on failover fix'. A new build is being tested again for good measure.
I'll send a Tested-by: John Meneghini once the tests are done.
Changes since V3:
Addresssed all review comments, fixed the commit log, and moved nr_counter initialization from nvme_mpath_init_ctlr() to nvme_mpath_init_identify().
Changes since V2:
Add the NVME_MPATH_CNT_ACTIVE flag to eliminate a READ_ONCE in the completion path and increment/decrement the active_nr count on all mpath IOs - including passthru commands.
Send a pr_notice when ever the iopolicy on a subsystem is changed. This is important for support reasons. It is fully expected that users will be changing the iopolicy with active IO in progress.
Squashed everything and rebased to nvme-v6.10
Changes since V1:
I'm re-issuing Ewan's queue-depth patches in preparation for LSFMM
These patches were first show at ALPSS 2023 where I shared the following graphs which measure the IO distribution across 4 active-optimized controllers using the round-robin verses queue-depth iopolicy.
https://people.redhat.com/jmeneghi/ALPSS_2023/NVMe_QD_Multipathing.pdf
Since that time we have continued testing these patches with a number of different nvme-of storage arrays and test bed configurations, and I've codified the tests and methods we use to measure IO distribution
All of my test results, together with the scripts I used to generate these graphs, are available at:
https://github.com/johnmeneghini/iopolicy
Please use the scripts in this repository to do your own testing.
These patches are based on nvme-v6.9
Ewan D. Milne (1):
nvme: multipath: Implemented new iopolicy "queue-depth"
drivers/nvme/host/core.c | 2 +- drivers/nvme/host/multipath.c | 91 +++++++++++++++++++++++++++++++++-- drivers/nvme/host/nvme.h | 8 +++ 3 files changed, 96 insertions(+), 5 deletions(-)
Signature · 1 line
2.39.3
PATCH v4 1/1 nvme: multipath: Implemented new iopolicy "queue-depth"
From: "Ewan D. Milne" <[email protected]>
The round-robin path selector is inefficient in cases where there is a difference in latency between paths. In the presence of one or more high latency paths the round-robin selector continues to use the high latency path equally. This results in a bias towards the highest latency path and can cause a significant decrease in overall performance as IOs pile on the highest latency path. This problem is acute with NVMe-oF controllers.
The queue-depth policy instead sends I/O requests down the path with the least amount of requests in its request queue. Paths with lower latency will clear requests more quickly and have less requests in their queues compared to higher latency paths. The goal of this path selector is to make more use of lower latency paths which will bring down overall IO latency and increase throughput and performance.
[emilne: patch developed by Thomas Song @ Pure Storage, fixed whitespace
and compilation warnings, updated MODULE_PARM description, and fixed potential issue with ->current_path[] being used]
--- drivers/nvme/host/core.c | 2 +- drivers/nvme/host/multipath.c | 91 +++++++++++++++++++++++++++++++++-- drivers/nvme/host/nvme.h | 8 +++ 3 files changed, 96 insertions(+), 5 deletions(-)
drivers/nvme/host/core.c +1 -1
@@ -110,7 +110,7 @@ struct workqueue_struct *nvme_delete_wq;EXPORT_SYMBOL_GPL (nvme_delete_wq);static LIST_HEAD (nvme_subsystems); -static DEFINE_MUTEX (nvme_subsystems_lock); +DEFINE_MUTEX (nvme_subsystems_lock);static DEFINE_IDA (nvme_instance_ida);static dev_t nvme_ctrl_base_chr_devt;
drivers/nvme/host/multipath.c +87 -4
158 lines not on this page · raw message
drivers/nvme/host/nvme.h +8 -0
@@ -50,6 +50,8 @@ extern struct workqueue_struct *nvme_wq;extern struct workqueue_struct *nvme_reset_wq;extern struct workqueue_struct *nvme_delete_wq; +extern struct mutex nvme_subsystems_lock; +/* * List of workarounds for devices that required behavior not specified in * the standard.
@@ -195,6 +197,7 @@ enum {NVME_REQ_CANCELLED = (1 <<0 ),NVME_REQ_USERCMD = (1 <<1 ),NVME_MPATH_IO_STATS = (1 <<2 ), + NVME_MPATH_CNT_ACTIVE = (1 << 3), };static inline struct nvme_request *nvme_req (struct request *req)
@@ -359,6 +362,7 @@ struct nvme_ctrl {size_t ana_log_size;struct timer_list anatt_timer;struct work_struct ana_work; +atomic_t nr_active;#endif #ifdef CONFIG_NVME_HOST_AUTH
@@ -407,6 +411,7 @@ static inline enum nvme_ctrl_state nvme_ctrl_state(struct nvme_ctrl *ctrl)enum nvme_iopolicy {NVME_IOPOLICY_NUMA ,NVME_IOPOLICY_RR , +NVME_IOPOLICY_QD , };struct nvme_subsystem {
@@ -1061,6 +1066,9 @@ static inline bool nvme_disk_is_ns_head(struct gendisk *disk) {return false; } +static inline void nvme_subsys_iopolicy_update (struct nvme_subsystem *subsys,int iopolicy) +{ +}#endif /* CONFIG_NVME_MULTIPATH */ struct nvme_zone_info {
Signature · 1 line
2.39.3
Keith Busch
maintainerRe: [PATCH v4 1/1] nvme: multipath: Implemented new iopolicy "queue-depth"
drivers/nvme/host/multipath.c static ssize_t nvme_subsys_iopolicy_show(struct device *dev, · line 873
Quoted 11 lines · John Meneghini
drivers/nvme/host/multipath.c +11
-0+static void nvme_subsys_iopolicy_update (struct nvme_subsystem *subsys,int iopolicy) +{ +struct nvme_ctrl *ctrl; +int old_iopolicy =READ_ONCE (subsys->iopolicy); + +WRITE_ONCE (subsys->iopolicy, iopolicy); + +/* iopolicy changes reset the counters and clear the mpath by design */ +mutex_lock (&nvme_subsystems_lock); +list_for_each_entry (ctrl, &subsys->ctrls, subsys_entry) { +atomic_set (&ctrl->nr_active,0 );
Can you me understand why this is a desirable feature? Unless you quiesce everything at some point, you'll always have more unaccounted requests on whichever path has higher latency. That sounds like it defeats the goals of this io policy.
drivers/nvme/host/nvme.h static inline bool nvme_disk_is_ns_head(struct gendisk *disk) · line 1072
Quoted 8 lines
drivers/nvme/host/nvme.h +3
-0@@ -1061,6 +1066,9 @@ static inline bool nvme_disk_is_ns_head(struct gendisk *disk) {return false; } +static inline void nvme_subsys_iopolicy_update (struct nvme_subsystem *subsys,int iopolicy) +{ +}#endif /* CONFIG_NVME_MULTIPATH */
You can remove this stub function since the only caller resides in a CONFIG_NVME_MULTIPATH file.
Re: [PATCH v4 1/1] nvme: multipath: Implemented new iopolicy "queue-depth"
Quoted 17 lines · Keith Busch
drivers/nvme/host/multipath.c static ssize_t nvme_subsys_iopolicy_show(struct device *dev, · line 873
Quoted 11 lines · John Meneghini
drivers/nvme/host/multipath.c +11
-0+static void nvme_subsys_iopolicy_update (struct nvme_subsystem *subsys,int iopolicy) +{ +struct nvme_ctrl *ctrl; +int old_iopolicy =READ_ONCE (subsys->iopolicy); + +WRITE_ONCE (subsys->iopolicy, iopolicy); + +/* iopolicy changes reset the counters and clear the mpath by design */ +mutex_lock (&nvme_subsystems_lock); +list_for_each_entry (ctrl, &subsys->ctrls, subsys_entry) { +atomic_set (&ctrl->nr_active,0 );Can you me understand why this is a desirable feature? Unless you quiesce everything at some point, you'll always have more unaccounted requests on whichever path has higher latency. That sounds like it defeats the goals of this io policy.
This is true. And as a matter of practice I never change the IO policy when IOs are in flight. I always stop the IO first. But we can't stop any user from changing the IO policy again and again. So I'm not sure what to do.
If you'd like I add the 'if (old_iopolicy == iopolicy) return;' here, but that's not going to solve the problem of inaccurate counters when users start flipping io policies around. with IO inflight. There is no synchronization between io submission across controllers and changing the policy so I expect changing between round-robin and queue-depth with IO inflight suffers from the same problem... though not as badly.
I'd rather take this patch now and figure out how to fix the problem with another patch in the future. Maybe we can check the io stats and refuse to change the policy of they are not zero....
Quoted 12 lines
drivers/nvme/host/nvme.h static inline bool nvme_disk_is_ns_head(struct gendisk *disk) · line 1072
Quoted 8 lines
drivers/nvme/host/nvme.h +3
-0@@ -1061,6 +1066,9 @@ static inline bool nvme_disk_is_ns_head(struct gendisk *disk) {return false; } +static inline void nvme_subsys_iopolicy_update (struct nvme_subsystem *subsys,int iopolicy) +{ +}#endif /* CONFIG_NVME_MULTIPATH */ You can remove this stub function since the only caller resides in a
CONFIG_NVME_MULTIPATHfile.
I can do that. Since I have to spin a version 5 patch, do you want me to make the change above?
Is there anything else?
/John
Keith Busch
maintainerRe: [PATCH v4 1/1] nvme: multipath: Implemented new iopolicy "queue-depth"
Quoted 29 lines · John Meneghini
Quoted 17 lines · Keith Busch
drivers/nvme/host/multipath.c static ssize_t nvme_subsys_iopolicy_show(struct device *dev, · line 873
Quoted 11 lines · John Meneghini
drivers/nvme/host/multipath.c +11
-0+static void nvme_subsys_iopolicy_update (struct nvme_subsystem *subsys,int iopolicy) +{ +struct nvme_ctrl *ctrl; +int old_iopolicy =READ_ONCE (subsys->iopolicy); + +WRITE_ONCE (subsys->iopolicy, iopolicy); + +/* iopolicy changes reset the counters and clear the mpath by design */ +mutex_lock (&nvme_subsystems_lock); +list_for_each_entry (ctrl, &subsys->ctrls, subsys_entry) { +atomic_set (&ctrl->nr_active,0 );Can you me understand why this is a desirable feature? Unless you quiesce everything at some point, you'll always have more unaccounted requests on whichever path has higher latency. That sounds like it defeats the goals of this io policy.
This is true. And as a matter of practice I never change the IO policy when IOs are in flight. I always stop the IO first. But we can't stop any user from changing the IO policy again and again. So I'm not sure what to do.
If you'd like I add the 'if (
old_iopolicy== iopolicy) return;' here, but that's not going to solve the problem of inaccurate counters when users start flipping io policies around. with IO inflight. There is no synchronization between io submission across controllers and changing the policy so I expect changing between round-robin and queue-depth with IO inflight suffers from the same problem... though not as badly.
Quoted 3 lines
I'd rather take this patch now and figure out how to fix the problem with another patch in the future. Maybe we can check the io stats and refuse to change the policy of they are not zero....
The idea of tagging the nvme_req()->flags on submission means the completion handling the nr_active counter is symmetric with the submission side: you don't ever need to reset nr_active because everything is accounted for.
Sagi Grimberg
maintainerRe: [PATCH v4 1/1] nvme: multipath: Implemented new iopolicy "queue-depth"
Quoted 28 lines · Keith Busch
Quoted 27 lines · John Meneghini
Quoted 16 lines · Keith Busch
drivers/nvme/host/multipath.c static ssize_t nvme_subsys_iopolicy_show(struct device *dev, · line 873
Quoted 11 lines · John Meneghini
drivers/nvme/host/multipath.c +11
-0+static void nvme_subsys_iopolicy_update (struct nvme_subsystem *subsys,int iopolicy) +{ +struct nvme_ctrl *ctrl; +int old_iopolicy =READ_ONCE (subsys->iopolicy); + +WRITE_ONCE (subsys->iopolicy, iopolicy); + +/* iopolicy changes reset the counters and clear the mpath by design */ +mutex_lock (&nvme_subsystems_lock); +list_for_each_entry (ctrl, &subsys->ctrls, subsys_entry) { +atomic_set (&ctrl->nr_active,0 );Can you me understand why this is a desirable feature? Unless you quiesce everything at some point, you'll always have more unaccounted requests on whichever path has higher latency. That sounds like it defeats the goals of this io policy.
This is true. And as a matter of practice I never change the IO policy when IOs are in flight. I always stop the IO first. But we can't stop any user from changing the IO policy again and again. So I'm not sure what to do.
If you'd like I add the 'if (
old_iopolicy== iopolicy) return;' here, but that's not going to solve the problem of inaccurate counters when users start flipping io policies around. with IO inflight. There is no synchronization between io submission across controllers and changing the policy so I expect changing between round-robin and queue-depth with IO inflight suffers from the same problem... though not as badly.
Quoted 7 lines
Quoted 3 lines
I'd rather take this patch now and figure out how to fix the problem with another patch in the future. Maybe we can check the io stats and refuse to change the policy of they are not zero....
The idea of tagging the nvme_req()->flags on submission means the completion handling the
nr_activecounter is symmetric with the submission side: you don't ever need to resetnr_activebecause everything is accounted for.
Agree. We should probably remove it from the patch.
Re: [PATCH v4 1/1] nvme: multipath: Implemented new iopolicy "queue-depth"
In reply to John MeneghiniQuoted 28 lines · John Meneghini
From: "Ewan D. Milne" <[email protected]>
The round-robin path selector is inefficient in cases where there is a difference in latency between paths. In the presence of one or more high latency paths the round-robin selector continues to use the high latency path equally. This results in a bias towards the highest latency path and can cause a significant decrease in overall performance as IOs pile on the highest latency path. This problem is acute with NVMe-oF controllers.
The queue-depth policy instead sends I/O requests down the path with the least amount of requests in its request queue. Paths with lower latency will clear requests more quickly and have less requests in their queues compared to higher latency paths. The goal of this path selector is to make more use of lower latency paths which will bring down overall IO latency and increase throughput and performance.
Signed-off-by Thomas Song <[email protected]>[emilne: patch developed by Thomas Song @ Pure Storage, fixed whitespace
and compilation warnings, updatedMODULE_PARMdescription, and fixed potential issue with ->current_path[] being used]Signed-off-by Ewan D. Milne <[email protected]>[jmeneghi: vairious changes and improvements, addressed review comments]Signed-off-by John Meneghini <[email protected]>Tested-by Marco Patalano <[email protected]>Reviewed-by Randy Jennings <[email protected]>Tested-by Jyoti Rani <[email protected]>
Quoted 6 lines
--- drivers/nvme/host/core.c | 2 +- drivers/nvme/host/multipath.c | 91 +++++++++++++++++++++++++++++++++-- drivers/nvme/host/nvme.h | 8 +++ 3 files changed, 96 insertions(+), 5 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich