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>
This commit is contained in:
parent
3cb967c039
commit
9ecdc94621
@ -221,12 +221,7 @@ static void cancel_cmdid_data(struct nvme_queue *nvmeq, int cmdid)
|
|||||||
|
|
||||||
static struct nvme_queue *get_nvmeq(struct nvme_ns *ns)
|
static struct nvme_queue *get_nvmeq(struct nvme_ns *ns)
|
||||||
{
|
{
|
||||||
int qid, cpu = get_cpu();
|
return ns->dev->queues[get_cpu() + 1];
|
||||||
if (cpu < ns->dev->queue_count)
|
|
||||||
qid = cpu + 1;
|
|
||||||
else
|
|
||||||
qid = (cpu % rounddown_pow_of_two(ns->dev->queue_count)) + 1;
|
|
||||||
return ns->dev->queues[qid];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void put_nvmeq(struct nvme_queue *nvmeq)
|
static void put_nvmeq(struct nvme_queue *nvmeq)
|
||||||
@ -1316,6 +1311,11 @@ static int __devinit nvme_setup_io_queues(struct nvme_dev *dev)
|
|||||||
dev->queue_count++;
|
dev->queue_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (; i < num_possible_cpus(); i++) {
|
||||||
|
int target = i % rounddown_pow_of_two(dev->queue_count - 1);
|
||||||
|
dev->queues[i + 1] = dev->queues[target + 1];
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user