[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.21.1906131822300.1791@nanos.tec.linutronix.de>
Date: Thu, 13 Jun 2019 18:26:14 +0200 (CEST)
From: Thomas Gleixner <tglx@...utronix.de>
To: "Jason A. Donenfeld" <Jason@...c4.com>
cc: Arnd Bergmann <arnd@...db.de>,
Peter Zijlstra <peterz@...radead.org>,
LKML <linux-kernel@...r.kernel.org>,
Clemens Ladisch <clemens@...isch.de>,
Sultan Alsawaf <sultan@...neltoast.com>,
Waiman Long <longman@...hat.com>, X86 ML <x86@...nel.org>
Subject: Re: infinite loop in read_hpet from ktime_get_boot_fast_ns
On Thu, 13 Jun 2019, Jason A. Donenfeld wrote:
> Hey Arnd,
>
> On Thu, Jun 13, 2019 at 5:40 PM Arnd Bergmann <arnd@...db.de> wrote:
> > A seqlock is a very cheap synchronization primitive, I would actually
> > guess that this is faster than most implementations of sched_clock()
> > that access a hardware register for reading the time.
>
> It appears to me that ktime_get_coarse_boottime() has a granularity of
> a whole second, which is a lot worse than jiffies. Looking at the
> source, you assign base but don't then add ns like the other
> functions. At first I thought this was an intentional quirk to avoid
> hitting the slow hardware paths. But noticing this poor granularity
> now and observing that there's actually a blank line (\n\n) where the
> nanosecond addition normally would be, I wonder if something was lost
> in cut-and-paste?
>
> I'm still poking around trying to see what's up. As a quick test,
> running this on every packet during a high speed test shows the left
> incrementing many times per second, whereas the right increments once
> per second:
>
> static int x = 0;
> if (!(x++ % 30000))
> pr_err("%llu %llu\n", local_clock(), ktime_get_coarse_boottime());
That does not make sense. The coarse time getters use
tk->tkr_mono.base. base is updated every tick (or if the machine is
completely idle right when the first CPU wakes up again).
timekeeping_get_ns() which is added in ktime_get_boottime() is the time in
ns elapsed since base was updated last, which is less than a tick.
Thanks,
tglx
Powered by blists - more mailing lists