On Fri, Jun 14, 2019 at 11:55 AM tip-bot for Thomas Gleixner <tipbot@xxxxxxxxx> wrote: > > Commit-ID: e3ff9c3678b4d80e22d2557b68726174578eaf52 > Gitweb: https://git.kernel.org/tip/e3ff9c3678b4d80e22d2557b68726174578eaf52 > Author: Thomas Gleixner <tglx@xxxxxxxxxxxxx> > AuthorDate: Thu, 13 Jun 2019 21:40:45 +0200 > Committer: Thomas Gleixner <tglx@xxxxxxxxxxxxx> > CommitDate: Fri, 14 Jun 2019 11:51:44 +0200 > > timekeeping: Repair ktime_get_coarse*() granularity > > Jason reported that the coarse ktime based time getters advance only once > per second and not once per tick as advertised. > > The code reads only the monotonic base time, which advances once per > second. The nanoseconds are accumulated on every tick in xtime_nsec up to > a second and the regular time getters take this nanoseconds offset into > account, but the ktime_get_coarse*() implementation fails to do so. > > Add the accumulated xtime_nsec value to the monotonic base time to get the > proper per tick advancing coarse tinme. Acked-by: Arnd Bergmann <arnd@xxxxxxxx> (too late, I know) I checked what code is actually affected. Fortunately there are only a very small number of callers that I could find: arch/powerpc/xmon/xmon.c: ktime_get_coarse_boottime_ts64(&uptime); drivers/iio/industrialio-core.c: return ktime_to_ns(ktime_get_coarse_real()); drivers/power/supply/ab8500_fg.c: time64_t now = ktime_get_boottime_seconds(); drivers/net/wireless/intel/ipw2x00/ipw2100.c: time64_t now = ktime_get_boottime_seconds(); Only two of these even read the sub-second portion, and the iio file only calls this function if CLOCK_REALTIME_COARSE was passed from user space. I don't think any harm was done so far by this bug, so it's not surprising we never noticed. Arnd
![]() |