[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.21.1804191256200.1563@nanos.tec.linutronix.de>
Date: Thu, 19 Apr 2018 13:05:39 +0200 (CEST)
From: Thomas Gleixner <tglx@...utronix.de>
To: Imre Deak <imre.deak@...el.com>
cc: LKML <linux-kernel@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>
Subject: Re: Early timeouts due to inaccurate jiffies during system
suspend/resume
On Thu, 19 Apr 2018, Imre Deak wrote:
> Hi,
>
> while checking bug [1], I noticed that jiffies based timing loops like
>
> expire = jiffies + timeout + 1;
> while (!time_after(jiffies, expire))
> do_something;
>
> can last shorter than expected (that is less than timeout).
Yes, that can happen when the timer interrupt is delayed long enough for
whatever reason. If you need accurate timing then you need to use
ktime_get().
> After some ftracing it seems like jiffies gets stale due to a missed
> LAPIC timer interrupt after the interrupt is armed in
> lapic_next_deadline() and before jiffies is sampled at 2. above.
> Eventually the interrupt does get delivered, at which point jiffies gets
> updated via tick_do_update_jiffies64() with a >1 ticks increment.
> Between lapic_next_deadline() and the - late - delivery of the interrupt
> the CPU on which the interrupt is armed doesn't go idle.
That's odd. I have no real explanation for that.
Thanks,
tglx
Powered by blists - more mailing lists