Skip to content

Commit

Permalink
NVMe: CPU hot plug notification
Browse files Browse the repository at this point in the history
Registers with hot cpu notification to rebalance, and potentially allocate
additional, io queues.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
  • Loading branch information
Keith Busch authored and Matthew Wilcox committed Apr 10, 2014
1 parent 42f6142 commit 33b1e95
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions drivers/block/nvme-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2002,6 +2002,19 @@ static size_t db_bar_size(struct nvme_dev *dev, unsigned nr_io_queues)
return 4096 + ((nr_io_queues + 1) * 8 * dev->db_stride);
}

static int nvme_cpu_notify(struct notifier_block *self,
unsigned long action, void *hcpu)
{
struct nvme_dev *dev = container_of(self, struct nvme_dev, nb);
switch (action) {
case CPU_ONLINE:
case CPU_DEAD:
nvme_assign_io_queues(dev);
break;
}
return NOTIFY_OK;
}

static int nvme_setup_io_queues(struct nvme_dev *dev)
{
struct nvme_queue *adminq = raw_nvmeq(dev, 0);
Expand Down Expand Up @@ -2080,6 +2093,11 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
nvme_free_queues(dev, nr_io_queues + 1);
nvme_assign_io_queues(dev);

dev->nb.notifier_call = &nvme_cpu_notify;
result = register_hotcpu_notifier(&dev->nb);
if (result)
goto free_queues;

return 0;

free_queues:
Expand Down Expand Up @@ -2357,6 +2375,7 @@ static void nvme_dev_shutdown(struct nvme_dev *dev)
int i;

dev->initialized = 0;
unregister_hotcpu_notifier(&dev->nb);

spin_lock(&dev_list_lock);
list_del_init(&dev->node);
Expand Down
1 change: 1 addition & 0 deletions include/linux/nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ struct nvme_dev {
struct kref kref;
struct miscdevice miscdev;
struct work_struct reset_work;
struct notifier_block nb;
char name[12];
char serial[20];
char model[40];
Expand Down

0 comments on commit 33b1e95

Please sign in to comment.