mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tip-bot for John Stultz <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com,
	fengguang.wu@intel.com, pang.xunlei@linaro.org, mingo@kernel.org,
	tglx@linutronix.de, john.stultz@linaro.org
Subject: [tip:timers/core] time: Fix sign bug in NTP mult overflow warning
Date: Mon, 24 Nov 2014 22:21:35 -0800	[thread overview]
Message-ID: <tip-cb2aa63469f81426c7406227be70b628b42f7a05@git.kernel.org> (raw)
In-Reply-To: <1416890145-30048-1-git-send-email-john.stultz@linaro.org>

Commit-ID:  cb2aa63469f81426c7406227be70b628b42f7a05
Gitweb:     http://git.kernel.org/tip/cb2aa63469f81426c7406227be70b628b42f7a05
Author:     John Stultz <john.stultz@linaro.org>
AuthorDate: Mon, 24 Nov 2014 20:35:45 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 25 Nov 2014 07:18:34 +0100

time: Fix sign bug in NTP mult overflow warning

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.

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>
Link: http://lkml.kernel.org/r/1416890145-30048-1-git-send-email-john.stultz@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.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;

  reply	other threads:[~2014-11-25  6:21 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-bot for John Stultz [this message]
2014-12-02  9:32   ` Jeremiah Mahler
2014-12-02 15:00     ` 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=tip-cb2aa63469f81426c7406227be70b628b42f7a05@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=fengguang.wu@intel.com \
    --cc=hpa@zytor.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@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®