From: sagi@grimberg.me (Sagi Grimberg)
Subject: [PATCH 4/4] nvme-core: support traffic based keep-alive based on controller support
Date: Thu, 27 Sep 2018 18:15:37 -0700 [thread overview]
Message-ID: <20180928011537.30069-5-sagi@grimberg.me> (raw)
In-Reply-To: <20180928011537.30069-1-sagi@grimberg.me>
If the controller supports traffic based keep alive, we restart
the keep alive timer if any admin or io commands was completed
during the kato period. This prevents a possible starvation of
keep alive commands in the presence of heavy traffic as in such
case, we already have a health indication from the host perspective.
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
drivers/nvme/host/core.c | 11 +++++++++++
drivers/nvme/host/nvme.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 6bb6214c0634..54a24987a7d4 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -251,6 +251,7 @@ void nvme_complete_rq(struct request *req)
trace_nvme_complete_rq(req);
+ nvme_req(req)->ctrl->comp_seen = true;
if (unlikely(status != BLK_STS_OK && nvme_req_needs_retry(req))) {
if ((req->cmd_flags & REQ_NVME_MPATH) &&
blk_path_error(status)) {
@@ -841,6 +842,7 @@ static void nvme_keep_alive_end_io(struct request *rq, blk_status_t status)
return;
}
+ ctrl->comp_seen = false;
schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ);
}
@@ -865,6 +867,15 @@ static void nvme_keep_alive_work(struct work_struct *work)
{
struct nvme_ctrl *ctrl = container_of(to_delayed_work(work),
struct nvme_ctrl, ka_work);
+ bool comp_seen = ctrl->comp_seen;
+
+ if ((ctrl->ctratt & NVME_CTRL_ATTR_TBKAS) && comp_seen) {
+ dev_dbg(ctrl->device,
+ "traffic based keep-alive timer expired, reschedule\n");
+ ctrl->comp_seen = false;
+ schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ);
+ return;
+ }
if (nvme_keep_alive(ctrl)) {
/* allocation failure, reset the controller */
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index ee1c4fc0249c..e9aaae257daa 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -145,6 +145,7 @@ enum nvme_ctrl_state {
};
struct nvme_ctrl {
+ bool comp_seen;
enum nvme_ctrl_state state;
bool identified;
spinlock_t lock;
--
2.17.1
next prev parent reply other threads:[~2018-09-28 1:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-28 1:15 [PATCH 0/4] traffic based keep alive support (TP 4024) Sagi Grimberg
2018-09-28 1:15 ` [PATCH 1/4] nvme: introduce ctrl attributes enumeration Sagi Grimberg
2018-09-28 1:15 ` [PATCH 2/4] nvmet: support for traffic based keep-alive Sagi Grimberg
2018-09-28 1:15 ` [PATCH 3/4] nvme-core: cache controller attributes Sagi Grimberg
2018-09-28 1:15 ` Sagi Grimberg [this message]
2018-10-17 7:05 ` [PATCH 4/4] nvme-core: support traffic based keep-alive based on controller support Christoph Hellwig
2018-10-19 0:38 ` Sagi Grimberg
2018-10-19 6:00 ` Christoph Hellwig
2018-10-19 6:30 ` Sagi Grimberg
2018-10-16 1:07 ` [PATCH 0/4] traffic based keep alive support (TP 4024) Sagi Grimberg
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=20180928011537.30069-5-sagi@grimberg.me \
--to=sagi@grimberg.me \
/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;
as well as URLs for NNTP newsgroup(s).