[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.21.1806232212180.8650@nanos.tec.linutronix.de>
Date: Sat, 23 Jun 2018 22:16:16 +0200 (CEST)
From: Thomas Gleixner <tglx@...utronix.de>
To: "Jason A. Donenfeld" <Jason@...c4.com>
cc: joelaf@...gle.com, John Stultz <john.stultz@...aro.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: Accuracy bounds of ktime_get_boot_fast_ns
On Sat, 23 Jun 2018, Jason A. Donenfeld wrote:
> void foobar_create(struct foobar *f)
> {
> f->birthdate = ktime_get_boot_fast_ns();
> }
> bool foobar_has_expired(struct foobar *f)
> {
> return f->birthdate + DEATH_AGE_SEC * NSEC_PER_SEC <=
> ktime_get_boot_fast_ns();
> }
>
> I'm wondering if I can actually get away with this last iteration.
> I've read the comments around the various _fast_ns functions, and they
> all indicate that it might not be totally monotonic with respect to
> all cpus. But I wonder if that actually matters for my use case. For
> example, is it still correct within a 10th or so of a second? Or will
> it occasionally be wrong by massive multi-second leaps, which would
> make it unsuitable for my usage? In other words, I'm wondering if
> there's still a level of accuracy for a certain low degree of
> precision?
The step backwards would be in the low nanoseconds range, so nothing to
worry about. The slope is not adjusted by large jumps, it's a very smooth
adoption through NTP/PTP.
Thanks,
tglx
Powered by blists - more mailing lists