Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sbradshaw@micron.com (Sam Bradshaw)
Subject: [PATCH] NVMe: Reduce spinlock contention in IO timeout disposition path
Date: Mon, 17 Nov 2014 14:54:14 -0800	[thread overview]
Message-ID: <546A7C96.8070608@micron.com> (raw)

When workload queue depths exceed hardware queue depths, the kthread is 
constantly woken to resubmit queued IOs as cmdids free up.  The kthread 
routine also walks the entire list of cmdids to disposition any timeouts 
for each queue.  This sequence introduces latency variation by extending 
queue spinlock hold times and is unnecessarily coupled with kthread 
wakeups.  This patch causes the kthread routine to only disposition cmdid 
timouts if a minimum duration has passed since the last timeout check.

Since multiple devices share a single kthread, this patch has the added 
benefit of improved latency consistency by reducing the unnecessary 
spinlock contention introduced by "noisy neighbors" which trigger high 
rates of kthread wakes.

Signed-off-by: Sam Bradshaw <sbradshaw at micron.com>
---
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index 00fa5d2..399d3ac 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -1965,9 +1965,17 @@ static int nvme_submit_async_req(struct nvme_queue *nvmeq)
 static int nvme_kthread(void *data)
 {
 	struct nvme_dev *dev, *next;
+	unsigned long do_check, next_check = jiffies;
 
 	while (!kthread_should_stop()) {
 		set_current_state(TASK_INTERRUPTIBLE);
+
+		do_check = 0;
+		if (time_after(jiffies, next_check)) {
+			do_check = 1;
+			next_check = jiffies + HZ;
+		}
+
 		spin_lock(&dev_list_lock);
 		list_for_each_entry_safe(dev, next, &dev_list, node) {
 			int i;
@@ -1992,7 +2000,8 @@ static int nvme_kthread(void *data)
 				if (nvmeq->q_suspended)
 					goto unlock;
 				nvme_process_cq(nvmeq);
-				nvme_cancel_ios(nvmeq, true);
+				if (do_check)
+					nvme_cancel_ios(nvmeq, true);
 				nvme_resubmit_bios(nvmeq);
 				nvme_resubmit_iods(nvmeq);
 

                 reply	other threads:[~2014-11-17 22:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=546A7C96.8070608@micron.com \
    --to=sbradshaw@micron.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox