[PATCH] powerpc/powernv/idle: Round up latency and residency values

Subsystems: cpu idle time management framework, the rest

STALE3206d

5 messages, 4 authors, 2017-11-14 · open the first message on its own page

[PATCH] powerpc/powernv/idle: Round up latency and residency values

From: Vaidyanathan Srinivasan <hidden>
Date: 2017-08-23 18:58:56

On PowerNV platforms, firmware provides exit latency and
target residency for each of the idle states in nano
seconds.  Cpuidle framework expects the values in micro
seconds.  Round up to nearest micro seconds to avoid errors
in cases where the values are defined as fractional micro
seconds.

Default idle state of 'snooze' has exit latency of zero.  If
other states have fractional micro second exit latency, they
would get rounded down to zero micro second and make cpuidle
framework choose deeper idle state when snooze loop is the
right choice.

Reported-by: Anton Blanchard <redacted>
Signed-off-by: Vaidyanathan Srinivasan <redacted>
---
 drivers/cpuidle/cpuidle-powernv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c
index 42896a67aeae..5f3922392059 100644
--- a/drivers/cpuidle/cpuidle-powernv.c
+++ b/drivers/cpuidle/cpuidle-powernv.c
@@ -383,9 +383,9 @@ static int powernv_add_idle_states(void)
 		 * Firmware passes residency and latency values in ns.
 		 * cpuidle expects it in us.
 		 */
-		exit_latency = latency_ns[i] / 1000;
+		exit_latency = DIV_ROUND_UP(latency_ns[i], 1000);
 		if (!rc)
-			target_residency = residency_ns[i] / 1000;
+			target_residency = DIV_ROUND_UP(residency_ns[i], 1000);
 		else
 			target_residency = 0;
 
-- 
2.13.5

Re: [PATCH] powerpc/powernv/idle: Round up latency and residency values

From: Gautham R Shenoy <hidden>
Date: 2017-08-24 04:35:33

Hi Vaidy,
On Thu, Aug 24, 2017 at 12:28:41AM +0530, Vaidyanathan Srinivasan
wrote:

Cc'ing Rafael and linux-pm list.
On PowerNV platforms, firmware provides exit latency and
target residency for each of the idle states in nano
seconds.  Cpuidle framework expects the values in micro
seconds.  Round up to nearest micro seconds to avoid errors
in cases where the values are defined as fractional micro
seconds.

Default idle state of 'snooze' has exit latency of zero.  If
other states have fractional micro second exit latency, they
would get rounded down to zero micro second and make cpuidle
framework choose deeper idle state when snooze loop is the
right choice.

Reported-by: Anton Blanchard <redacted>
Signed-off-by: Vaidyanathan Srinivasan <redacted>
This looks good to me.

Reviewed-by: Gautham R. Shenoy <redacted>
quoted hunk
---
 drivers/cpuidle/cpuidle-powernv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c
index 42896a67aeae..5f3922392059 100644
--- a/drivers/cpuidle/cpuidle-powernv.c
+++ b/drivers/cpuidle/cpuidle-powernv.c
@@ -383,9 +383,9 @@ static int powernv_add_idle_states(void)
 		 * Firmware passes residency and latency values in ns.
 		 * cpuidle expects it in us.
 		 */
-		exit_latency = latency_ns[i] / 1000;
+		exit_latency = DIV_ROUND_UP(latency_ns[i], 1000);
 		if (!rc)
-			target_residency = residency_ns[i] / 1000;
+			target_residency = DIV_ROUND_UP(residency_ns[i], 1000);
 		else
 			target_residency = 0;
-- 
2.13.5

Re: [PATCH] powerpc/powernv/idle: Round up latency and residency values

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2017-08-24 10:28:20

Vaidyanathan Srinivasan [off-list ref] writes:
On PowerNV platforms, firmware provides exit latency and
target residency for each of the idle states in nano
seconds.  Cpuidle framework expects the values in micro
seconds.  Round up to nearest micro seconds to avoid errors
in cases where the values are defined as fractional micro
seconds.

Default idle state of 'snooze' has exit latency of zero.  If
other states have fractional micro second exit latency, they
would get rounded down to zero micro second and make cpuidle
framework choose deeper idle state when snooze loop is the
right choice.

Reported-by: Anton Blanchard <redacted>
Signed-off-by: Vaidyanathan Srinivasan <redacted>
This sounds like a fairly bad bug, does it need a Fixes / Cc stable tag?

cheers

Re: [PATCH] powerpc/powernv/idle: Round up latency and residency values

From: Vaidyanathan Srinivasan <hidden>
Date: 2017-08-24 13:07:56

* Michael Ellerman [off-list ref] [2017-08-24 20:28:19]:
Vaidyanathan Srinivasan [off-list ref] writes:
quoted
On PowerNV platforms, firmware provides exit latency and
target residency for each of the idle states in nano
seconds.  Cpuidle framework expects the values in micro
seconds.  Round up to nearest micro seconds to avoid errors
in cases where the values are defined as fractional micro
seconds.

Default idle state of 'snooze' has exit latency of zero.  If
other states have fractional micro second exit latency, they
would get rounded down to zero micro second and make cpuidle
framework choose deeper idle state when snooze loop is the
right choice.

Reported-by: Anton Blanchard <redacted>
Signed-off-by: Vaidyanathan Srinivasan <redacted>
This sounds like a fairly bad bug, does it need a Fixes / Cc stable tag?
Yes, we will need this on stable kernel that runs on POWER9.  On older
platforms the latencies are larger and hence no impact :)

I will post to stable after this fix hits your -next tree.

--Vaidy

Re: powerpc/powernv/idle: Round up latency and residency values

From: Michael Ellerman <hidden>
Date: 2017-11-14 11:12:00

On Wed, 2017-08-23 at 18:58:41 UTC, Vaidyanathan Srinivasan wrote:
On PowerNV platforms, firmware provides exit latency and
target residency for each of the idle states in nano
seconds.  Cpuidle framework expects the values in micro
seconds.  Round up to nearest micro seconds to avoid errors
in cases where the values are defined as fractional micro
seconds.

Default idle state of 'snooze' has exit latency of zero.  If
other states have fractional micro second exit latency, they
would get rounded down to zero micro second and make cpuidle
framework choose deeper idle state when snooze loop is the
right choice.

Reported-by: Anton Blanchard <redacted>
Signed-off-by: Vaidyanathan Srinivasan <redacted>
Reviewed-by: Gautham R. Shenoy <redacted>
Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/8d4e10e9ed9450e18fbbf6a8872be0

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help