examples/perf: use NVMe Maximum Queue Entries as the default queue size

For perf tests with large I/O size, the NVMe driver may split one
request to several entries based on stripe and maximum transfer size,
so take user's input of queue depth as default queue size of NVMe
queue pair is not accurate. Here the patch evaluate users' input
and report an error when queue entries more than hardware's limit.

Change-Id: I66922a3d673dc97796d7fbe6e86cf5037a45b37d
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/379969
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Changpeng Liu 2017-09-26 04:28:44 -04:00 committed by Jim Harris
parent bd5ce60f82
commit c5d8b108f2

View File

@ -186,6 +186,8 @@ register_ns(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ns *ns)
{
struct ns_entry *entry;
const struct spdk_nvme_ctrlr_data *cdata;
uint32_t max_xfer_size, entries;
struct spdk_nvme_io_qpair_opts opts;
cdata = spdk_nvme_ctrlr_get_data(ctrlr);
@ -205,6 +207,20 @@ register_ns(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ns *ns)
return;
}
max_xfer_size = spdk_nvme_ns_get_max_io_xfer_size(ns);
spdk_nvme_ctrlr_get_default_io_qpair_opts(ctrlr, &opts, sizeof(opts));
/* NVMe driver may add additional entries based on
* stripe size and maximum transfer size, we assume
* 1 more entry be used for stripe.
*/
entries = (g_io_size_bytes - 1) / max_xfer_size + 2;
if ((g_queue_depth * entries) > opts.io_queue_size) {
printf("WARNING: controller IO queue size %u less than required\n",
opts.io_queue_size);
printf("You can try with smaller IO size or queue depth\n");
return;
}
entry = malloc(sizeof(struct ns_entry));
if (entry == NULL) {
perror("ns_entry malloc");
@ -1190,7 +1206,11 @@ probe_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
pci_id.vendor_id, pci_id.device_id);
}
opts->io_queue_size = g_queue_depth + 1;
/* Set io_queue_size to UINT16_MAX, NVMe driver
* will then reduce this to MQES to maximize
* the io_queue_size as much as possible.
*/
opts->io_queue_size = UINT16_MAX;
return true;
}