From: Jeremiah Mahler <jmmahler@gmail.com>
To: John Stultz <john.stultz@linaro.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
"pang.xunlei" <pang.xunlei@linaro.org>,
Fengguang Wu <fengguang.wu@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] time: Fix sign bug in ntp mult overflow warning
Date: Tue, 2 Dec 2014 01:32:28 -0800 [thread overview]
Message-ID: <20141202093228.GA8792@hudson.localdomain> (raw)
In-Reply-To: <1416890145-30048-1-git-send-email-john.stultz@linaro.org>
John,
On Mon, Nov 24, 2014 at 08:35:45PM -0800, John Stultz wrote:
> In commit 6067dc5a8c2b ("time: Avoid possible NTP adjustment mult
> overflow") a new check was added to watch for adjustments that could
> cause a mult overflow.
>
> Unfortunately the check compares a signed with unsigned value and
> ignored the case where the adjustment was negative, which causes
> spurious warn-ons on some systems (and seems like it would result in
> problematic time adjustments there as well, due to the early
> return).
>
> Thus this patch adds a check to make sure the adjustment is positive
> before we check for an overflow, and resovles the issue in my
> testing.
>
> Cc: pang.xunlei <pang.xunlei@linaro.org>
> Cc: Fengguang Wu <fengguang.wu@intel.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@kernel.org>
> Reported-by: Fengguang Wu <fengguang.wu@intel.com>
> Debugged-by: pang.xunlei <pang.xunlei@linaro.org>
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> ---
> kernel/time/timekeeping.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
> index 29a7d67..2dc0646 100644
> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -1330,7 +1330,7 @@ static __always_inline void timekeeping_apply_adjustment(struct timekeeper *tk,
> *
> * XXX - TODO: Doc ntp_error calculation.
> */
> - if (tk->tkr.mult + mult_adj < mult_adj) {
> + if ((mult_adj > 0) && (tk->tkr.mult + mult_adj < mult_adj)) {
> /* NTP adjustment caused clocksource mult overflow */
> WARN_ON_ONCE(1);
> return;
This change does quiet the warning but I think it does so for the wrong
reason.
mult_adj is a signed number and tk->tkr.mult is an unsigned number.
Adding the check that (mult_adj > 0) limits the test to only positive
numbers. A positive number plus a positive number will never be less
than either of the two positive numbers. The test is always false.
--
- Jeremiah Mahler
next prev parent reply other threads:[~2014-12-02 9:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-22 18:45 [time] WARNING: CPU: 0 PID: 1 at kernel/time/timekeeping.c:1337 update_wall_time() Fengguang Wu
2014-11-22 18:47 ` Fengguang Wu
2014-11-25 4:35 ` [PATCH] time: Fix sign bug in ntp mult overflow warning John Stultz
2014-11-25 6:21 ` [tip:timers/core] time: Fix sign bug in NTP " tip-bot for John Stultz
2014-12-02 9:32 ` Jeremiah Mahler [this message]
2014-12-02 15:00 ` [PATCH] time: Fix sign bug in ntp " Xunlei Pang
2014-12-02 21:31 ` Jeremiah Mahler
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=20141202093228.GA8792@hudson.localdomain \
--to=jmmahler@gmail.com \
--cc=fengguang.wu@intel.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=pang.xunlei@linaro.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®