linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Ladislav Michl <ladis@linux-mips.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Linux OMAP Mailing List <linux-omap@vger.kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Biju Das <biju.das@bp.renesas.com>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
	Vincent Guittot <vincent.guittot@linaro.org>
Subject: Re: [PATCH] PM/runtime: Optimize pm_runtime_autosuspend_expiration()
Date: Wed, 06 Feb 2019 11:34:03 +0100	[thread overview]
Message-ID: <4091828.IqCJ3qcF9B@aspire.rjw.lan> (raw)
In-Reply-To: <20190130214017.GA5038@lenoch>

On Wednesday, January 30, 2019 10:40:17 PM CET Ladislav Michl wrote:
> pm_runtime_autosuspend_expiration calls ktime_get_mono_fast_ns
> 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: Tony Lindgren <tony@atomide.com>
> Acked-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
>  This patch is based on top of bleeding-edge branch, where
>  "[PATCH v2 ] PM-runtime: fix deadlock with ktime" is sitting.
>  I expect v3 of that patch, which should not harm this one.
>  It is meant to replace "PM/runtime: Do not needlessly call ktime_get"
>  sent earlier.
> 
>  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 65e2b5f48e0c..7bbe28faca8d 100644
> --- a/drivers/base/power/runtime.c
> +++ b/drivers/base/power/runtime.c
> @@ -145,24 +145,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_get_mono_fast_ns();
> +	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_get_mono_fast_ns())
> +		return expires;	/* Expires in the future */
>  
> - out:
> -	return expires;
> +	return 0;
>  }
>  EXPORT_SYMBOL_GPL(pm_runtime_autosuspend_expiration);
>  
> 

Applied, thanks!



      reply	other threads:[~2019-02-06 10:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30 21:40 [PATCH] PM/runtime: Optimize pm_runtime_autosuspend_expiration() Ladislav Michl
2019-02-06 10:34 ` Rafael J. Wysocki [this message]

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=4091828.IqCJ3qcF9B@aspire.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=biju.das@bp.renesas.com \
    --cc=geert@linux-m68k.org \
    --cc=ladis@linux-mips.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=vincent.guittot@linaro.org \
    /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).