Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1239654 > unrolled thread

Re: [tip:timers/urgent] time: Fix timekeeping_freqadjust()' s incorrect use of abs() instead of abs64()

Started byNuno Gonçalves <nunojpg@gmail.com>
First post2015-10-05 17:20 +0200
Last post2015-10-06 10:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [tip:timers/urgent] time: Fix timekeeping_freqadjust()' s  incorrect use of abs() instead of abs64() Nuno Gonçalves <nunojpg@gmail.com> - 2015-10-05 17:20 +0200
    Re: [tip:timers/urgent] time: Fix timekeeping_freqadjust()' s  incorrect use of abs() instead of abs64() Greg KH <greg@kroah.com> - 2015-10-06 10:10 +0200

#1239654 — Re: [tip:timers/urgent] time: Fix timekeeping_freqadjust()' s incorrect use of abs() instead of abs64()

FromNuno Gonçalves <nunojpg@gmail.com>
Date2015-10-05 17:20 +0200
SubjectRe: [tip:timers/urgent] time: Fix timekeeping_freqadjust()' s incorrect use of abs() instead of abs64()
Message-ID<qgfIv-2DV-31@gated-at.bofh.it>
On Sun, Sep 13, 2015 at 12:07 PM, tip-bot for John Stultz
<tipbot@zytor.com> wrote:
> Commit-ID:  2619d7e9c92d524cb155ec89fd72875321512e5b
> Gitweb:     http://git.kernel.org/tip/2619d7e9c92d524cb155ec89fd72875321512e5b
> Author:     John Stultz <john.stultz@linaro.org>
> AuthorDate: Wed, 9 Sep 2015 16:07:30 -0700
> Committer:  Ingo Molnar <mingo@kernel.org>
> CommitDate: Sun, 13 Sep 2015 10:30:47 +0200
>
> time: Fix timekeeping_freqadjust()'s incorrect use of abs() instead of abs64()
>
> 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:
>
>   dc491596f639 ("timekeeping: 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.
>
> Reported-by: Nuno Gonçalves <nunojpg@gmail.com>
> Tested-by: Nuno Goncalves <nunojpg@gmail.com>
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> Cc: <stable@vger.kernel.org> # v3.17+
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Miroslav Lichvar <mlichvar@redhat.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Prarit Bhargava <prarit@redhat.com>
> Cc: Richard Cochran <richardcochran@gmail.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Link: http://lkml.kernel.org/r/1441840051-20244-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 f6ee2e6..3739ac6 100644
> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -1614,7 +1614,7 @@ static __always_inline void timekeeping_freqadjust(struct timekeeper *tk,
>         negative = (tick_error < 0);
>
>         /* Sort out the magnitude of the correction */
> -       tick_error = abs(tick_error);
> +       tick_error = abs64(tick_error);
>         for (adj = 0; tick_error > interval; adj++)
>                 tick_error >>= 1;
>

I think this got lost on its way to the linux-stable queue (or I don't
understand the stable rules).

Thanks,
Nuno
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1240232

FromGreg KH <greg@kroah.com>
Date2015-10-06 10:10 +0200
Message-ID<qgvtU-iV-7@gated-at.bofh.it>
In reply to#1239654
On Mon, Oct 05, 2015 at 04:10:28PM +0100, Nuno Gonçalves wrote:
> On Sun, Sep 13, 2015 at 12:07 PM, tip-bot for John Stultz
> <tipbot@zytor.com> wrote:
> > Commit-ID:  2619d7e9c92d524cb155ec89fd72875321512e5b
> > Gitweb:     http://git.kernel.org/tip/2619d7e9c92d524cb155ec89fd72875321512e5b
> > Author:     John Stultz <john.stultz@linaro.org>
> > AuthorDate: Wed, 9 Sep 2015 16:07:30 -0700
> > Committer:  Ingo Molnar <mingo@kernel.org>
> > CommitDate: Sun, 13 Sep 2015 10:30:47 +0200
> >
> > time: Fix timekeeping_freqadjust()'s incorrect use of abs() instead of abs64()
> >
> > 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:
> >
> >   dc491596f639 ("timekeeping: 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.
> >
> > Reported-by: Nuno Gonçalves <nunojpg@gmail.com>
> > Tested-by: Nuno Goncalves <nunojpg@gmail.com>
> > Signed-off-by: John Stultz <john.stultz@linaro.org>
> > Cc: <stable@vger.kernel.org> # v3.17+
> > Cc: Linus Torvalds <torvalds@linux-foundation.org>
> > Cc: Miroslav Lichvar <mlichvar@redhat.com>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Prarit Bhargava <prarit@redhat.com>
> > Cc: Richard Cochran <richardcochran@gmail.com>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Link: http://lkml.kernel.org/r/1441840051-20244-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 f6ee2e6..3739ac6 100644
> > --- a/kernel/time/timekeeping.c
> > +++ b/kernel/time/timekeeping.c
> > @@ -1614,7 +1614,7 @@ static __always_inline void timekeeping_freqadjust(struct timekeeper *tk,
> >         negative = (tick_error < 0);
> >
> >         /* Sort out the magnitude of the correction */
> > -       tick_error = abs(tick_error);
> > +       tick_error = abs64(tick_error);
> >         for (adj = 0; tick_error > interval; adj++)
> >                 tick_error >>= 1;
> >
> 
> I think this got lost on its way to the linux-stable queue (or I don't
> understand the stable rules).

It's still in the "todo" queue, along with 159 other patches that I have
yet to get to :(

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web