[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPDyKFqNgnvHM0hpgzy-oY+oj0_q72LDybgZJ5r8BugDM97Oqg@mail.gmail.com>
Date: Tue, 5 Feb 2019 09:09:54 +0100
From: Ulf Hansson <ulf.hansson@...aro.org>
To: Vincent Guittot <vincent.guittot@...aro.org>
Cc: Linux PM <linux-pm@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
"Rafael J. Wysocki" <rjw@...ysocki.net>,
Biju Das <biju.das@...renesas.com>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Thara Gopinath <thara.gopinath@...aro.org>,
Linux-Renesas <linux-renesas-soc@...r.kernel.org>
Subject: Re: [PATCH 2/2] PM-runtime: update time accounting only when enabled
On Mon, 4 Feb 2019 at 17:26, Vincent Guittot <vincent.guittot@...aro.org> wrote:
>
> Update accounting_timestamp field only when PM runtime is enable
> and don't forget to account the last state before disabling it.
>
> Suggested-by: Ulf Hansson <ulf.hansson@...aro.org>
> Signed-off-by: Vincent Guittot <vincent.guittot@...aro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@...aro.org>
Kind regards
Uffe
> ---
> drivers/base/power/runtime.c | 18 ++++++++++--------
> 1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> index 50740da..ed62cca 100644
> --- a/drivers/base/power/runtime.c
> +++ b/drivers/base/power/runtime.c
> @@ -66,11 +66,14 @@ static int rpm_suspend(struct device *dev, int rpmflags);
> */
> void update_pm_runtime_accounting(struct device *dev)
> {
> - u64 now = ktime_get_mono_fast_ns();
> - u64 last = dev->power.accounting_timestamp;
> - u64 delta;
> + u64 now, last, delta;
>
> - dev->power.accounting_timestamp = now;
> + if (dev->power.disable_depth > 0)
> + return;
> +
> + last = dev->power.accounting_timestamp;
> +
> + dev->power.accounting_timestamp = now = ktime_get_mono_fast_ns();
>
> /*
> * Because ktime_get_mono_fast_ns() is not monotonic during
> @@ -82,9 +85,6 @@ void update_pm_runtime_accounting(struct device *dev)
>
> delta = now - last;
>
> - if (dev->power.disable_depth > 0)
> - return;
> -
> if (dev->power.runtime_status == RPM_SUSPENDED)
> dev->power.suspended_time += delta;
> else
> @@ -1298,6 +1298,9 @@ void __pm_runtime_disable(struct device *dev, bool check_resume)
> pm_runtime_put_noidle(dev);
> }
>
> + /* Update time accounting before disabling pm runtime */
> + update_pm_runtime_accounting(dev);
> +
> if (!dev->power.disable_depth++)
> __pm_runtime_barrier(dev);
>
> @@ -1521,7 +1524,6 @@ void pm_runtime_init(struct device *dev)
> dev->power.request_pending = false;
> dev->power.request = RPM_REQ_NONE;
> dev->power.deferred_resume = false;
> - dev->power.accounting_timestamp = 0;
> INIT_WORK(&dev->power.work, pm_runtime_work);
>
> dev->power.timer_expires = 0;
> --
> 2.7.4
>
Powered by blists - more mailing lists