diff options
author | Matthew Wilcox <matthew.r.wilcox@intel.com> | 2011-03-16 16:52:19 -0400 |
---|---|---|
committer | Matthew Wilcox <matthew.r.wilcox@intel.com> | 2011-11-04 15:53:01 -0400 |
commit | 9ecdc946212f7cd592986b2c519b470404caa6b8 (patch) | |
tree | 5d953e07ff82f8a97b5d4d5c14b0eb6db401d1a2 /drivers/block/nvme.c | |
parent | 3cb967c03926edd2c414082f4cc0feb7b372edae (diff) |
NVMe: Simplify queue lookup
Fill in all the num_possible_cpus() entries with duplicate pointers.
This reduces the complexity of the frequently-called get_nvmeq(), as
well as avoiding a bug in it when there are fewer queues than CPUs.
Reported-by: Shane Michael Matthews <shane.matthews@intel.com>
Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Diffstat (limited to 'drivers/block/nvme.c')
-rw-r--r-- | drivers/block/nvme.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c index 8d3c0b79ac2b..f94f1731478f 100644 --- a/drivers/block/nvme.c +++ b/drivers/block/nvme.c | |||
@@ -221,12 +221,7 @@ static void cancel_cmdid_data(struct nvme_queue *nvmeq, int cmdid) | |||
221 | 221 | ||
222 | static struct nvme_queue *get_nvmeq(struct nvme_ns *ns) | 222 | static struct nvme_queue *get_nvmeq(struct nvme_ns *ns) |
223 | { | 223 | { |
224 | int qid, cpu = get_cpu(); | 224 | return ns->dev->queues[get_cpu() + 1]; |
225 | if (cpu < ns->dev->queue_count) | ||
226 | qid = cpu + 1; | ||
227 | else | ||
228 | qid = (cpu % rounddown_pow_of_two(ns->dev->queue_count)) + 1; | ||
229 | return ns->dev->queues[qid]; | ||
230 | } | 225 | } |
231 | 226 | ||
232 | static void put_nvmeq(struct nvme_queue *nvmeq) | 227 | static void put_nvmeq(struct nvme_queue *nvmeq) |
@@ -1316,6 +1311,11 @@ static int __devinit nvme_setup_io_queues(struct nvme_dev *dev) | |||
1316 | dev->queue_count++; | 1311 | dev->queue_count++; |
1317 | } | 1312 | } |
1318 | 1313 | ||
1314 | for (; i < num_possible_cpus(); i++) { | ||
1315 | int target = i % rounddown_pow_of_two(dev->queue_count - 1); | ||
1316 | dev->queues[i + 1] = dev->queues[target + 1]; | ||
1317 | } | ||
1318 | |||
1319 | return 0; | 1319 | return 0; |
1320 | } | 1320 | } |
1321 | 1321 | ||