From 564a232c059913d91b491e04c2b2d670b8f94615 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Wed, 1 May 2013 16:38:23 -0400 Subject: [PATCH] NVMe: Set TASK_INTERRUPTIBLE before processing queues The kthread has two tasks; handling timeouts (for which it runs once per second), and submitting queued BIOs. If a BIO happens to be queued after the thread has processed the queue but before it calls schedule_timeout(), the thread will sleep for a second before submitting it, which can cause performance problems in some rare cases (that will become more common in a subsequent patch). Signed-off-by: Arjan van de Ven Tested-by: Keith Busch Signed-off-by: Matthew Wilcox --- drivers/block/nvme-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index 40908a06bd5e..358d17700c20 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c @@ -1291,7 +1291,7 @@ static int nvme_kthread(void *data) struct nvme_dev *dev; while (!kthread_should_stop()) { - __set_current_state(TASK_RUNNING); + set_current_state(TASK_INTERRUPTIBLE); spin_lock(&dev_list_lock); list_for_each_entry(dev, &dev_list, node) { int i; @@ -1308,7 +1308,6 @@ static int nvme_kthread(void *data) } } spin_unlock(&dev_list_lock); - set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(round_jiffies_relative(HZ)); } return 0; -- 2.11.0