mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeremiah Mahler <jmmahler@gmail.com>
To: Xunlei Pang <pang.xunlei@linaro.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] time: Fix sign bug in ntp mult overflow warning
Date: Tue, 2 Dec 2014 13:31:04 -0800	[thread overview]
Message-ID: <20141202213104.GA14149@hudson.localdomain> (raw)
In-Reply-To: <CADcy93Wf9q1hyL43UwVjfCrWyn_PHSHJgLnzHvianjkxUxr2Sg@mail.gmail.com>

Xunlei,

On Tue, Dec 02, 2014 at 11:00:26PM +0800, Xunlei Pang wrote:
> On 2 December 2014 at 17:32, Jeremiah Mahler <jmmahler@gmail.com> wrote:
> > John,
> >
> > On Mon, Nov 24, 2014 at 08:35:45PM -0800, John Stultz wrote:
> >> In commit 6067dc5a8c2b ("time: Avoid possible NTP adjustment mult
> >> @@ -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.
> 
> Hi Jeremiah,
> 
> The result of a positive number plus a positive number may overflow,
> for example, u32  (0xFFFF_FFF0 + 0x20) will be 0x10,
> that's what this patch is dealing with.
> 
> Thanks,
> Xunlei
> >
> > --
> > - Jeremiah Mahler

Oh, got it.  That makes sense now.  Thanks :)

-- 
- Jeremiah Mahler

      reply	other threads:[~2014-12-02 21:31 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   ` [PATCH] time: Fix sign bug in ntp " Jeremiah Mahler
2014-12-02 15:00     ` Xunlei Pang
2014-12-02 21:31       ` Jeremiah Mahler [this message]

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=20141202213104.GA14149@hudson.localdomain \
    --to=jmmahler@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pang.xunlei@linaro.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

all inboxes | Powered by JetHome®