rdma: force queue size to respect controller capability
PATCH 1/1 rdma: force queue size to respect controller capability
Queue size needs to respect the Maximum Queue Entries Supported advertised by the controller in its Capability register.
--- drivers/nvme/host/rdma.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/nvme/host/rdma.c +8 -0
@@ -1908,6 +1908,14 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, opts->queue_size = ctrl->ctrl.maxcmd; } +if (opts->queue_size > ctrl->ctrl.sqsize) { +/* warn if sqsize is lower than queue_size */ +dev_warn (ctrl->ctrl.device, +"queue_size %zu > ctrl sqsize %u, clamping down\n" , + opts->queue_size, ctrl->ctrl.sqsize); + opts->queue_size = ctrl->ctrl.sqsize; + } +if (opts->nr_io_queues) { ret =nvme_rdma_create_io_queues (ctrl);if (ret)
Signature · 1 line
1.8.3.1
PATCH 1/1 rdma: force queue size to respect controller capability
Quoted 4 lines · Samuel Jones
Queue size needs to respect the Maximum Queue Entries Supported advertised by the controller in its Capability register.
Signed-off-by Samuel Jones <sjones at kalray.eu>
Thanks Samuel,
this looks good:
PATCH 1/1 rdma: force queue size to respect controller capability
In reply to Samuel JonesThanks Samuel,
queued to nvmf-4.9-rc
PATCH 1/1 rdma: force queue size to respect controller capability
In reply to Samuel JonesQuoted 13 lines · Samuel Jones
Queue size needs to respect the Maximum Queue Entries Supported advertised by the controller in its Capability register.
Signed-off-by Samuel Jones <sjones at kalray.eu>--- drivers/nvme/host/rdma.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/nvme/host/rdma.c +0
-0
drivers/nvme/host/rdma.c static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, · line 1917
Quoted 10 lines
drivers/nvme/host/rdma.c +7
-0@@ -1908,6 +1908,14 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, opts->queue_size = ctrl->ctrl.maxcmd; } +if (opts->queue_size > ctrl->ctrl.sqsize) { +/* warn if sqsize is lower than queue_size */ +dev_warn (ctrl->ctrl.device, +"queue_size %zu > ctrl sqsize %u, clamping down\n" , + opts->queue_size, ctrl->ctrl.sqsize); + opts->queue_size = ctrl->ctrl.sqsize; + }
I believe there's an off-by-one (or two) lurking here.
It looks to me like ctrlr->ctrlr.sqsize is intended to be 0's-based:
- sqsize is passed as HSQSIZE in the Connect private data, which is 0's-based
- sqsize is set to opts->queue_size - 1 earlier in nvme_rdma_create_ctrlr()
However, this new change assigns opts->queue_size (non-0's-based value) the current value of ctrlr->ctrlr.sqsize (0's-based value) without any adjustment.
This is probably because there is another bug in nvme_rdma_configure_admin_queue(), where sqsize is set to a value based on CAP.MQES + 1. MQES is a 0's-based value, so if sqsize is also supposed to be 0's based, no addition should be necessary.
I think it is currently working only in the case where the original sqsize is already smaller than MQES, because then the min of MQES and sqsize will pick sqsize, which is already 0's based from the initial queue_size - 1 assignment.
If I'm not missing anything, the correct fix should be removing the + 1 adjustment of MQES as well as changing this patch to consider the 0's based nature of sqsize:
if (opts->queue_size > ctrlr->ctrlr->sqsize + 1) {
...
opts->queue_size = ctrlr->ctrlr.sqsize + 1;
}Thanks,
-- Daniel
Sagi Grimberg
maintainerPATCH 1/1 rdma: force queue size to respect controller capability
Quoted 21 lines
I believe there's an off-by-one (or two) lurking here.
It looks to me like
ctrlr->ctrlr.sqsizeis intended to be 0's-based:
- sqsize is passed as HSQSIZE in the Connect private data, which is 0's-based
- sqsize is set toopts->queue_size- 1 earlier innvme_rdma_create_ctrlr()However, this new change assigns
opts->queue_size(non-0's-based value) the current value ofctrlr->ctrlr.sqsize(0's-based value) without any adjustment.This is probably because there is another bug in
nvme_rdma_configure_admin_queue(), where sqsize is set to a value based on CAP.MQES + 1. MQES is a 0's-based value, so if sqsize is also supposed to be 0's based, no addition should be necessary.I think it is currently working only in the case where the original sqsize is already smaller than MQES, because then the min of MQES and sqsize will pick sqsize, which is already 0's based from the initial
queue_size- 1 assignment.
Quoted 8 lines
If I'm not missing anything, the correct fix should be removing the + 1 adjustment of MQES as well as changing this patch to consider the 0's based nature of sqsize:
if (opts->queue_size > ctrlr->ctrlr->sqsize + 1) { ... opts->queue_size = ctrlr->ctrlr.sqsize + 1; }
Your correct Daniel. I'll fix that in the patch itself.
Thanks!
PATCH 1/1 rdma: force queue size to respect controller capability
Sagi,
Was the +1 issue resolved differently? I?m looking at the current code and I still see MQES + 1 being used.
I?m running into an issue where my target reports a MQES of 3fh.
The original ctrl->ctrl.sqsize comes from the create ctrl which sets a 0 based size.
ctrl->ctrl.sqsize = opts->queue_size - 1;
When host does the
ctrl->ctrl.sqsize =
min_t(int, NVME_CAP_MQES(ctrl->cap) + 1, ctrl->ctrl.sqsize); the comparison is min_t(40h, 7fh)
So sqsize is now set as a 1 based value. When the IO q is created, the target rejects it since it is larger than the max size.
Darren Trapp
Senior Director - Engineering
darren.trapp at cavium.com <mailto:darren.trapp at caviumnetworks.com> T 949-389-6273
M 949-212-8576
26650 Aliso Viejo Pkwy, Aliso Viejo, CA 92656 www.qlogic.com <http://www.qlogic.com/>
<http://www.qlogic.com/>
Quoted 21 lines · Linux-nvme on behalf of Sagi Grimberg
I believe there's an off-by-one (or two) lurking here.
It looks to me like
ctrlr->ctrlr.sqsizeis intended to be 0's-based:
- sqsize is passed as HSQSIZE in the Connect private data, which is 0's-based
- sqsize is set toopts->queue_size- 1 earlier innvme_rdma_create_ctrlr()However, this new change assigns
opts->queue_size(non-0's-based value) the current value ofctrlr->ctrlr.sqsize(0's-based value) without any adjustment.This is probably because there is another bug in
nvme_rdma_configure_admin_queue(), where sqsize is set to a value based on CAP.MQES + 1. MQES is a 0's-based value, so if sqsize is also supposed to be 0's based, no addition should be necessary.I think it is currently working only in the case where the original sqsize is already smaller than MQES, because then the min of MQES and sqsize will pick sqsize, which is already 0's based from the initial
queue_size- 1 assignment.
Quoted 8 lines
If I'm not missing anything, the correct fix should be removing the + 1 adjustment of MQES as well as changing this patch to consider the 0's based nature of sqsize:
if (opts->queue_size > ctrlr->ctrlr->sqsize + 1) { ... opts->queue_size = ctrlr->ctrlr.sqsize + 1; }
Your correct Daniel. I'll fix that in the patch itself.
Thanks!
_______________________________________________
Linux-nvme mailing list
Linux-nvme at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerPATCH 1/1 rdma: force queue size to respect controller capability
Quoted 9 lines
Sagi,
Was the +1 issue resolved differently? I?m looking at the current code and I still see MQES + 1 being used.
I?m running into an issue where my target reports a MQES of 3fh.
The original
ctrl->ctrl.sqsizecomes from the create ctrl which sets a 0 based size.ctrl->ctrl.sqsize = opts->queue_size - 1;
Quoted 7 lines
When host does the
ctrl->ctrl.sqsize = min_t(int, NVME_CAP_MQES(ctrl->cap) + 1, ctrl->ctrl.sqsize);the comparison is
min_t(40h, 7fh)So sqsize is now set as a 1 based value. When the IO q is created, the target rejects it since it is larger than the max size.
Hey Darren,
You're right, we are wrongly taking MQES + 1. Not sure how this slipped.
I'll send a patch, thanks for reporting!