Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvme-pci: add module parameter for io queue depth

Adjust io queue depth more easily, and make sure io queue depth >= 2.

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>

authored by

weiping zhang and committed by
Sagi Grimberg
b27c1e68 2ee0e4ed

+22 -2
+22 -2
drivers/nvme/host/pci.c
··· 35 35 36 36 #include "nvme.h" 37 37 38 - #define NVME_Q_DEPTH 1024 39 38 #define SQ_SIZE(depth) (depth * sizeof(struct nvme_command)) 40 39 #define CQ_SIZE(depth) (depth * sizeof(struct nvme_completion)) 41 40 ··· 55 56 module_param(max_host_mem_size_mb, uint, 0444); 56 57 MODULE_PARM_DESC(max_host_mem_size_mb, 57 58 "Maximum Host Memory Buffer (HMB) size per controller (in MiB)"); 59 + 60 + static int io_queue_depth_set(const char *val, const struct kernel_param *kp); 61 + static const struct kernel_param_ops io_queue_depth_ops = { 62 + .set = io_queue_depth_set, 63 + .get = param_get_int, 64 + }; 65 + 66 + static int io_queue_depth = 1024; 67 + module_param_cb(io_queue_depth, &io_queue_depth_ops, &io_queue_depth, 0644); 68 + MODULE_PARM_DESC(io_queue_depth, "set io queue depth, should >= 2"); 58 69 59 70 struct nvme_dev; 60 71 struct nvme_queue; ··· 112 103 struct nvme_host_mem_buf_desc *host_mem_descs; 113 104 void **host_mem_desc_bufs; 114 105 }; 106 + 107 + static int io_queue_depth_set(const char *val, const struct kernel_param *kp) 108 + { 109 + int n = 0, ret; 110 + 111 + ret = kstrtoint(val, 10, &n); 112 + if (ret != 0 || n < 2) 113 + return -EINVAL; 114 + 115 + return param_set_int(val, kp); 116 + } 115 117 116 118 static inline unsigned int sq_idx(unsigned int qid, u32 stride) 117 119 { ··· 1913 1893 dev->ctrl.cap = lo_hi_readq(dev->bar + NVME_REG_CAP); 1914 1894 1915 1895 dev->q_depth = min_t(int, NVME_CAP_MQES(dev->ctrl.cap) + 1, 1916 - NVME_Q_DEPTH); 1896 + io_queue_depth); 1917 1897 dev->db_stride = 1 << NVME_CAP_STRIDE(dev->ctrl.cap); 1918 1898 dev->dbs = dev->bar + 4096; 1919 1899