linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PM/runtime: Do not needlessly call ktime_get
@ 2019-01-10  9:51 Ladislav Michl
  2019-01-10 16:44 ` Tony Lindgren
  2019-01-10 18:56 ` Vincent Guittot
  0 siblings, 2 replies; 4+ messages in thread
From: Ladislav Michl @ 2019-01-10  9:51 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Ulf Hansson, Vincent Guittot, Linux PM, Tony Lindgren,
	Rafael J. Wysocki, Linux Kernel Mailing List,
	Linux OMAP Mailing List, Linux ARM

pm_runtime_autosuspend_expiration calls ktime_get even when
its returned value may be unused. Therefore get current time
later and remove gotos while there.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
---
 NOTE: Depends on Vincent's "[PATCH v2] PM/runtime: Fix autosuspend_delay
       on 32bits arch"!

 drivers/base/power/runtime.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 457be03b744d..836b1b8784eb 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -129,24 +129,21 @@ static void pm_runtime_cancel_pending(struct device *dev)
 u64 pm_runtime_autosuspend_expiration(struct device *dev)
 {
 	int autosuspend_delay;
-	u64 last_busy, expires = 0;
-	u64 now = ktime_to_ns(ktime_get());
+	u64 expires;
 
 	if (!dev->power.use_autosuspend)
-		goto out;
+		return 0;
 
 	autosuspend_delay = READ_ONCE(dev->power.autosuspend_delay);
 	if (autosuspend_delay < 0)
-		goto out;
-
-	last_busy = READ_ONCE(dev->power.last_busy);
+		return 0;
 
-	expires = last_busy + (u64)autosuspend_delay * NSEC_PER_MSEC;
-	if (expires <= now)
-		expires = 0;	/* Already expired. */
+	expires  = READ_ONCE(dev->power.last_busy);
+	expires += (u64)autosuspend_delay * NSEC_PER_MSEC;
+	if (expires > ktime_to_ns(ktime_get()))
+		return expires;	/* Expires in the future */
 
- out:
-	return expires;
+	return 0;
 }
 EXPORT_SYMBOL_GPL(pm_runtime_autosuspend_expiration);
 
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] PM/runtime: Do not needlessly call ktime_get
  2019-01-10  9:51 [PATCH] PM/runtime: Do not needlessly call ktime_get Ladislav Michl
@ 2019-01-10 16:44 ` Tony Lindgren
  2019-01-10 18:56 ` Vincent Guittot
  1 sibling, 0 replies; 4+ messages in thread
From: Tony Lindgren @ 2019-01-10 16:44 UTC (permalink / raw)
  To: Ladislav Michl
  Cc: Ulf Hansson, Vincent Guittot, Linux PM, Rafael J. Wysocki,
	Rafael J. Wysocki, Linux Kernel Mailing List,
	Linux OMAP Mailing List, Linux ARM

* Ladislav Michl <ladis@linux-mips.org> [190110 09:51]:
> pm_runtime_autosuspend_expiration calls ktime_get even when
> its returned value may be unused. Therefore get current time
> later and remove gotos while there.

Acked-by: Tony Lindgren <tony@atomide.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] PM/runtime: Do not needlessly call ktime_get
  2019-01-10  9:51 [PATCH] PM/runtime: Do not needlessly call ktime_get Ladislav Michl
  2019-01-10 16:44 ` Tony Lindgren
@ 2019-01-10 18:56 ` Vincent Guittot
  2019-01-16 11:57   ` Rafael J. Wysocki
  1 sibling, 1 reply; 4+ messages in thread
From: Vincent Guittot @ 2019-01-10 18:56 UTC (permalink / raw)
  To: Ladislav Michl
  Cc: Ulf Hansson, Linux PM, Tony Lindgren, Rafael J. Wysocki,
	Rafael J. Wysocki, Linux Kernel Mailing List,
	Linux OMAP Mailing List, Linux ARM

On Thu, 10 Jan 2019 at 10:51, Ladislav Michl <ladis@linux-mips.org> wrote:
>
> pm_runtime_autosuspend_expiration calls ktime_get even when
> its returned value may be unused. Therefore get current time
> later and remove gotos while there.
>
> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>

Acked-by: Vincent Guittot <vincent.guittot@linaro.org>

> ---
>  NOTE: Depends on Vincent's "[PATCH v2] PM/runtime: Fix autosuspend_delay
>        on 32bits arch"!
>
>  drivers/base/power/runtime.c | 19 ++++++++-----------
>  1 file changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> index 457be03b744d..836b1b8784eb 100644
> --- a/drivers/base/power/runtime.c
> +++ b/drivers/base/power/runtime.c
> @@ -129,24 +129,21 @@ static void pm_runtime_cancel_pending(struct device *dev)
>  u64 pm_runtime_autosuspend_expiration(struct device *dev)
>  {
>         int autosuspend_delay;
> -       u64 last_busy, expires = 0;
> -       u64 now = ktime_to_ns(ktime_get());
> +       u64 expires;
>
>         if (!dev->power.use_autosuspend)
> -               goto out;
> +               return 0;
>
>         autosuspend_delay = READ_ONCE(dev->power.autosuspend_delay);
>         if (autosuspend_delay < 0)
> -               goto out;
> -
> -       last_busy = READ_ONCE(dev->power.last_busy);
> +               return 0;
>
> -       expires = last_busy + (u64)autosuspend_delay * NSEC_PER_MSEC;
> -       if (expires <= now)
> -               expires = 0;    /* Already expired. */
> +       expires  = READ_ONCE(dev->power.last_busy);
> +       expires += (u64)autosuspend_delay * NSEC_PER_MSEC;
> +       if (expires > ktime_to_ns(ktime_get()))
> +               return expires; /* Expires in the future */
>
> - out:
> -       return expires;
> +       return 0;
>  }
>  EXPORT_SYMBOL_GPL(pm_runtime_autosuspend_expiration);
>
> --
> 2.20.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] PM/runtime: Do not needlessly call ktime_get
  2019-01-10 18:56 ` Vincent Guittot
@ 2019-01-16 11:57   ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2019-01-16 11:57 UTC (permalink / raw)
  To: Vincent Guittot, Ladislav Michl
  Cc: Ulf Hansson, Linux PM, Tony Lindgren, Rafael J. Wysocki,
	Linux Kernel Mailing List, Linux OMAP Mailing List, Linux ARM

On Thursday, January 10, 2019 7:56:19 PM CET Vincent Guittot wrote:
> On Thu, 10 Jan 2019 at 10:51, Ladislav Michl <ladis@linux-mips.org> wrote:
> >
> > pm_runtime_autosuspend_expiration calls ktime_get even when
> > its returned value may be unused. Therefore get current time
> > later and remove gotos while there.
> >
> > Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> 
> Acked-by: Vincent Guittot <vincent.guittot@linaro.org>

Patch applied, thanks!


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-01-16 11:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-10  9:51 [PATCH] PM/runtime: Do not needlessly call ktime_get Ladislav Michl
2019-01-10 16:44 ` Tony Lindgren
2019-01-10 18:56 ` Vincent Guittot
2019-01-16 11:57   ` Rafael J. Wysocki

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).