public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] nvme: only consider exit latency when choosing useful non-op power states
@ 2017-06-07  7:25 Kai-Heng Feng
  2017-06-07  7:25 ` [PATCH 2/2] nvme: relax APST default max latency to 100ms Kai-Heng Feng
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kai-Heng Feng @ 2017-06-07  7:25 UTC (permalink / raw)
  To: luto; +Cc: hch, axboe, linux-nvme, linux-kernel, Kai-Heng Feng

When a NVMe is in non-op states, the latency is exlat.
The latency will be enlat + exlat only when the NVMe tries to transit
from operational state right atfer it begins to transit to
non-operational state, which should be a rare case.

Therefore, as Andy Lutomirski suggests, use exlat only when deciding power
states to trainsit to.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/nvme/host/core.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 0f9cc0c55e15..c07d8d4e18c9 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1342,7 +1342,7 @@ static void nvme_configure_apst(struct nvme_ctrl *ctrl)
 	 * transitioning between power states.  Therefore, when running
 	 * in any given state, we will enter the next lower-power
 	 * non-operational state after waiting 50 * (enlat + exlat)
-	 * microseconds, as long as that state's total latency is under
+	 * microseconds, as long as that state's exit latency is under
 	 * the requested maximum latency.
 	 *
 	 * We will not autonomously enter any non-operational state for
@@ -1387,7 +1387,7 @@ static void nvme_configure_apst(struct nvme_ctrl *ctrl)
 		 * lowest-power state, not the number of states.
 		 */
 		for (state = (int)ctrl->npss; state >= 0; state--) {
-			u64 total_latency_us, transition_ms;
+			u64 total_latency_us, exit_latency_us, transition_ms;
 
 			if (target)
 				table->entries[state] = target;
@@ -1408,12 +1408,15 @@ static void nvme_configure_apst(struct nvme_ctrl *ctrl)
 			      NVME_PS_FLAGS_NON_OP_STATE))
 				continue;
 
-			total_latency_us =
-				(u64)le32_to_cpu(ctrl->psd[state].entry_lat) +
-				+ le32_to_cpu(ctrl->psd[state].exit_lat);
-			if (total_latency_us > ctrl->ps_max_latency_us)
+			exit_latency_us =
+				(u64)le32_to_cpu(ctrl->psd[state].exit_lat);
+			if (exit_latency_us > ctrl->ps_max_latency_us)
 				continue;
 
+			total_latency_us =
+				exit_latency_us +
+				le32_to_cpu(ctrl->psd[state].entry_lat);
+
 			/*
 			 * This state is good.  Use it as the APST idle
 			 * target for higher power states.
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] nvme: relax APST default max latency to 100ms
  2017-06-07  7:25 [PATCH 1/2] nvme: only consider exit latency when choosing useful non-op power states Kai-Heng Feng
@ 2017-06-07  7:25 ` Kai-Heng Feng
  2017-06-07  8:22 ` [PATCH 1/2] nvme: only consider exit latency when choosing useful non-op power states Christoph Hellwig
  2017-06-07 15:20 ` Andy Lutomirski
  2 siblings, 0 replies; 4+ messages in thread
From: Kai-Heng Feng @ 2017-06-07  7:25 UTC (permalink / raw)
  To: luto; +Cc: hch, axboe, linux-nvme, linux-kernel, Kai-Heng Feng

Christoph Hellwig suggests we should to make APST work out of the box.
Hence relax the the default max latency to make them able to enter
deepest power state on default.

Here are id-ctrl excerpts from two high latency NVMes:

vid     : 0x14a4
ssvid   : 0x1b4b
mn      : CX2-GB1024-Q11 NVMe LITEON 1024GB
ps    3 : mp:0.1000W non-operational enlat:5000 exlat:5000 rrt:3 rrl:3
          rwt:3 rwl:3 idle_power:- active_power:-
ps    4 : mp:0.0100W non-operational enlat:50000 exlat:100000 rrt:4 rrl:4
          rwt:4 rwl:4 idle_power:- active_power:-

vid     : 0x15b7
ssvid   : 0x1b4b
mn      : A400 NVMe SanDisk 512GB
ps    3 : mp:0.0500W non-operational enlat:51000 exlat:10000 rrt:0 rrl:0
          rwt:0 rwl:0 idle_power:- active_power:-
ps    4 : mp:0.0055W non-operational enlat:1000000 exlat:100000 rrt:0 rrl:0
          rwt:0 rwl:0 idle_power:- active_power:-

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index c07d8d4e18c9..903d5813023a 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -56,7 +56,7 @@ MODULE_PARM_DESC(max_retries, "max number of retries a command may have");
 static int nvme_char_major;
 module_param(nvme_char_major, int, 0);
 
-static unsigned long default_ps_max_latency_us = 25000;
+static unsigned long default_ps_max_latency_us = 100000;
 module_param(default_ps_max_latency_us, ulong, 0644);
 MODULE_PARM_DESC(default_ps_max_latency_us,
 		 "max power saving latency for new devices; use PM QOS to change per device");
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] nvme: only consider exit latency when choosing useful non-op power states
  2017-06-07  7:25 [PATCH 1/2] nvme: only consider exit latency when choosing useful non-op power states Kai-Heng Feng
  2017-06-07  7:25 ` [PATCH 2/2] nvme: relax APST default max latency to 100ms Kai-Heng Feng
@ 2017-06-07  8:22 ` Christoph Hellwig
  2017-06-07 15:20 ` Andy Lutomirski
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2017-06-07  8:22 UTC (permalink / raw)
  To: Kai-Heng Feng; +Cc: luto, hch, axboe, linux-nvme, linux-kernel

Thanks Kai-Heng,

I'll add both patches to the nvme-4.12 branch.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] nvme: only consider exit latency when choosing useful non-op power states
  2017-06-07  7:25 [PATCH 1/2] nvme: only consider exit latency when choosing useful non-op power states Kai-Heng Feng
  2017-06-07  7:25 ` [PATCH 2/2] nvme: relax APST default max latency to 100ms Kai-Heng Feng
  2017-06-07  8:22 ` [PATCH 1/2] nvme: only consider exit latency when choosing useful non-op power states Christoph Hellwig
@ 2017-06-07 15:20 ` Andy Lutomirski
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Lutomirski @ 2017-06-07 15:20 UTC (permalink / raw)
  To: Kai-Heng Feng
  Cc: Andrew Lutomirski, Christoph Hellwig, Jens Axboe, linux-nvme,
	linux-kernel@vger.kernel.org

On Wed, Jun 7, 2017 at 12:25 AM, Kai-Heng Feng
<kai.heng.feng@canonical.com> wrote:
> +                       exit_latency_us =
> +                               (u64)le32_to_cpu(ctrl->psd[state].exit_lat);

Trivial nit: the case is no longer necessary.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-06-07 15:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-07  7:25 [PATCH 1/2] nvme: only consider exit latency when choosing useful non-op power states Kai-Heng Feng
2017-06-07  7:25 ` [PATCH 2/2] nvme: relax APST default max latency to 100ms Kai-Heng Feng
2017-06-07  8:22 ` [PATCH 1/2] nvme: only consider exit latency when choosing useful non-op power states Christoph Hellwig
2017-06-07 15:20 ` Andy Lutomirski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox