From: John Stultz <john.stultz@linaro.org>
To: lkml <linux-kernel@vger.kernel.org>
Cc: John Stultz <john.stultz@linaro.org>,
"pang.xunlei" <pang.xunlei@linaro.org>,
Fengguang Wu <fengguang.wu@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>
Subject: [PATCH] time: Fix sign bug in ntp mult overflow warning
Date: Mon, 24 Nov 2014 20:35:45 -0800 [thread overview]
Message-ID: <1416890145-30048-1-git-send-email-john.stultz@linaro.org> (raw)
In-Reply-To: <20141122184506.GC29361@wfg-t540p.sh.intel.com>
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;
--
1.9.1
next prev parent reply other threads:[~2014-11-25 4:36 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 ` John Stultz [this message]
2014-11-25 6:21 ` [tip:timers/core] time: Fix sign bug in NTP mult overflow warning tip-bot for John Stultz
2014-12-02 9:32 ` [PATCH] time: Fix sign bug in ntp " 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=1416890145-30048-1-git-send-email-john.stultz@linaro.org \
--to=john.stultz@linaro.org \
--cc=fengguang.wu@intel.com \
--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®