All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>,
	"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Arnd Bergmann <arnd@arndb.de>,
	Clemens Ladisch <clemens@ladisch.de>,
	Waiman Long <longman@redhat.com>,
	Sultan Alsawaf <sultan@kerneltoast.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: linux-tip-commits@vger.kernel.org
Subject: Re: [tip:timers/urgent] timekeeping: Repair ktime_get_coarse*() granularity
Date: Fri, 14 Jun 2019 13:18:14 +0200	[thread overview]
Message-ID: <CAK8P3a0B2NSdVf+qOrg=ds7_mhJqBTCqznALQpNQuQ-fNDR+wg@mail.gmail.com> (raw)
In-Reply-To: <tip-e3ff9c3678b4d80e22d2557b68726174578eaf52@git.kernel.org>

On Fri, Jun 14, 2019 at 11:55 AM tip-bot for Thomas Gleixner
<tipbot@zytor.com> wrote:
>
> Commit-ID:  e3ff9c3678b4d80e22d2557b68726174578eaf52
> Gitweb:     https://git.kernel.org/tip/e3ff9c3678b4d80e22d2557b68726174578eaf52
> Author:     Thomas Gleixner <tglx@linutronix.de>
> AuthorDate: Thu, 13 Jun 2019 21:40:45 +0200
> Committer:  Thomas Gleixner <tglx@linutronix.de>
> 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@arndb.de> (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

  reply	other threads:[~2019-06-14 11:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-07 14:14 infinite loop in read_hpet from ktime_get_boot_fast_ns Jason A. Donenfeld
2019-06-11 21:09 ` Thomas Gleixner
2019-06-11 21:40   ` Waiman Long
2019-06-12  9:02   ` Peter Zijlstra
2019-06-12  9:44     ` Jason A. Donenfeld
2019-06-12 12:28       ` Peter Zijlstra
2019-06-12 12:31         ` Peter Zijlstra
2019-06-12 12:58         ` Jason A. Donenfeld
2019-06-12 15:27           ` Peter Zijlstra
2019-06-12 19:46         ` Arnd Bergmann
2019-06-18 17:34         ` Jason A. Donenfeld
2019-06-12 14:01       ` Arnd Bergmann
2019-06-13 15:18         ` Jason A. Donenfeld
2019-06-13 15:40           ` Arnd Bergmann
2019-06-13 16:17             ` Jason A. Donenfeld
2019-06-13 16:26               ` Thomas Gleixner
2019-06-13 16:34                 ` Jason A. Donenfeld
2019-06-13 16:41                   ` Jason A. Donenfeld
2019-06-13 19:53                   ` Thomas Gleixner
2019-06-14  9:14                     ` Jason A. Donenfeld
2019-06-14  9:44                       ` Thomas Gleixner
2019-06-14  9:56                         ` Jason A. Donenfeld
2019-06-14  9:48                       ` [PATCH] timekeeping: add get_jiffies_boot_64() for jiffies including sleep Jason A. Donenfeld
2019-06-14  9:55                     ` [tip:timers/urgent] timekeeping: Repair ktime_get_coarse*() granularity tip-bot for Thomas Gleixner
2019-06-14 11:18                       ` Arnd Bergmann [this message]
2019-06-12  9:29   ` infinite loop in read_hpet from ktime_get_boot_fast_ns Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK8P3a0B2NSdVf+qOrg=ds7_mhJqBTCqznALQpNQuQ-fNDR+wg@mail.gmail.com' \
    --to=arnd@arndb.de \
    --cc=Jason@zx2c4.com \
    --cc=clemens@ladisch.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sultan@kerneltoast.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.