Re: infinite loop in read_hpet from ktime_get_boot_fast_ns

Arnd Bergmann
2019-06-13T15:40:43Z

On Thu, Jun 13, 2019 at 5:19 PM Jason A. Donenfeld <Jason@zx2c4.com> wrote:
>
> Hey Arnd, Peter,
>
> On Wed, Jun 12, 2019 at 4:01 PM Arnd Bergmann <arnd@arndb.de> wrote:
> > Documentation/core-api/timekeeping.rst describes the timekeeping
> > interfaces. I think what you want here is ktime_get_coarse_boottime().
> >
> > Note that "coarse" means "don't access the hardware clocksource"
> > here, which is faster than "fast", but less accurate.
> >
> > This is updated as often as "jiffies_64", but is in nanosecond resolution
> > and takes suspended time into account.
>
> Oh, thanks. Indeed ktime_get_coarse_boottime seems even better. It's
> perhaps a bit slower, in that it has that seqlock, but that might give
> better synchronization between CPUs as well.

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.

Arnd