Re: [RFC v3 1/3] PM/runtime: Add a new interface to get accounted time

From: Vincent Guittot
Date: Wed Dec 19 2018 - 10:25:23 EST


On Wed, 19 Dec 2018 at 10:58, Ulf Hansson <ulf.hansson@xxxxxxxxxx> wrote:
>
> On Tue, 18 Dec 2018 at 15:55, Vincent Guittot
> <vincent.guittot@xxxxxxxxxx> wrote:
> >
> > Some drivers (like i915/drm) need to get the accounted suspended time.
> > pm_runtime_accounted_time_get() will return the suspended or active
> > accounted time until now.
>
> I suggest to leave the active accounted time out for now. At least
> until we have some users.
>
> That said, perhaps rename the function to something along the lines
> of, pm_runtime_last_suspended_time(), to make it more clear.
>
> >
> > Signed-off-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> > ---
> > drivers/base/power/runtime.c | 26 ++++++++++++++++++++++++++
> > include/linux/pm_runtime.h | 2 ++
> > 2 files changed, 28 insertions(+)
> >
> > diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> > index 7062469..6461469 100644
> > --- a/drivers/base/power/runtime.c
> > +++ b/drivers/base/power/runtime.c
> > @@ -88,6 +88,32 @@ static void __update_runtime_status(struct device *dev, enum rpm_status status)
> > dev->power.runtime_status = status;
> > }
> >
> > +u64 pm_runtime_accounted_time_get(struct device *dev, enum rpm_status status, bool update)
> > +{
> > + u64 now = ktime_to_ns(ktime_get());
>
> I think you should stay on jiffies here - and then switch to ktime in patch 3.

I forgot to reply to this comment
Yes I agree that I should stay in jiffies there


>
> > + u64 delta = 0, time = 0;
> > + unsigned long flags;
> > +
> > + spin_lock_irqsave(&dev->power.lock, flags);