From: Ingo Molnar <mingo@kernel.org>
To: John Stultz <john.stultz@linaro.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
"Nuno Gonçalves" <nunojpg@gmail.com>,
"Miroslav Lichvar" <mlichvar@redhat.com>,
"Prarit Bhargava" <prarit@redhat.com>,
"Richard Cochran" <richardcochran@gmail.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
stable@vger.kernel.org
Subject: Re: [PATCH 1/2] time: Fix timekeeping_freqadjust()'s incorrect use of abs() instead of abs64()
Date: Sun, 13 Sep 2015 10:32:44 +0200 [thread overview]
Message-ID: <20150913083244.GA29934@gmail.com> (raw)
In-Reply-To: <1441840051-20244-1-git-send-email-john.stultz@linaro.org>
* John Stultz <john.stultz@linaro.org> wrote:
> The internal clocksteering done for fine-grained error correction
> uses a logarithmic approximation, so any time adjtimex() adjusts
> the clock steering, timekeeping_freqadjust() quickly approximates
> the correct clock frequency over a series of ticks.
>
> Unfortunately, the logic in timekeeping_freqadjust(), introduced
> in commit dc491596f639438 (Rework frequency adjustments to work
> better w/ nohz), used the abs() function with a s64 error value
> to calculate the size of the approximated adjustment to be made.
>
> Per include/linux/kernel.h: "abs() should not be used for 64-bit
> types (s64, u64, long long) - use abs64()".
>
> Thus on 32-bit platforms, this resulted in the clocksteering to
> take a quite dampended random walk trying to converge on the
> proper frequency, which caused the adjustments to be made much
> slower then intended (most easily observed when large adjustments
> are made).
>
> This patch fixes the issue by using abs64() instead.
> /* Sort out the magnitude of the correction */
> - tick_error = abs(tick_error);
> + tick_error = abs64(tick_error);
Ugh, and we had this bug for almost two years!
Would it be possible to make abs() warn about 64-bit types during build time,
to prevent such mishaps?
Thanks,
Ingo
next prev parent reply other threads:[~2015-09-13 8:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-09 23:07 [PATCH 1/2] time: Fix timekeeping_freqadjust()'s incorrect use of abs() instead of abs64() John Stultz
2015-09-13 8:32 ` Ingo Molnar [this message]
2015-09-14 23:24 ` John Stultz
[not found] ` <tip-2619d7e9c92d524cb155ec89fd72875321512e5b@git.kernel.org>
2015-10-05 15:10 ` [tip:timers/urgent] time: Fix timekeeping_freqadjust()' s " Nuno Gonçalves
2015-10-06 8:05 ` Greg KH
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=20150913083244.GA29934@gmail.com \
--to=mingo@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mlichvar@redhat.com \
--cc=nunojpg@gmail.com \
--cc=prarit@redhat.com \
--cc=richardcochran@gmail.com \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).