From: David Gibson <david@gibson.dropbear.id.au>
To: Chris Metcalf <cmetcalf@mellanox.com>
Cc: John Stultz <john.stultz@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Laurent Vivier <lvivier@redhat.com>,
"Christopher S . Hall" <christopher.s.hall@intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] time: Avoid signed overflow in timekeeping_delta_to_ns()
Date: Tue, 15 Nov 2016 11:56:36 +1100 [thread overview]
Message-ID: <20161115005636.GF24747@umbus.fritz.box> (raw)
In-Reply-To: <1479152569-16890-1-git-send-email-cmetcalf@mellanox.com>
[-- Attachment #1: Type: text/plain, Size: 1473 bytes --]
On Mon, Nov 14, 2016 at 02:42:49PM -0500, Chris Metcalf wrote:
> This bugfix was originally made in commit 35a4933a8959 ("time:
> Avoid signed overflow in timekeeping_get_ns()"). When the code was
> refactored in commit 6bd58f09e1d8 ("time: Add cycles to nanoseconds
> translation") the signed overflow fix was lost. Re-introduce it.
>
> Signed-off-by: Chris Metcalf <cmetcalf@mellanox.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> I happened to be looking for an unrelated fix, found this code,
> realized the tip code didn't match the fixed code, and
> backtracked to where it had gone away.
>
> kernel/time/timekeeping.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
> index 37dec7e3db43..57926bc7b7f3 100644
> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -304,8 +304,7 @@ static inline s64 timekeeping_delta_to_ns(struct tk_read_base *tkr,
> {
> s64 nsec;
>
> - nsec = delta * tkr->mult + tkr->xtime_nsec;
> - nsec >>= tkr->shift;
> + nsec = (delta * tkr->mult + tkr->xtime_nsec) >> tkr->shift;
>
> /* If arch requires, add in get_arch_timeoffset() */
> return nsec + arch_gettimeoffset();
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-11-15 2:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-14 19:42 Chris Metcalf
2016-11-14 19:54 ` John Stultz
2016-11-15 21:53 ` Thomas Gleixner
2016-11-15 22:03 ` John Stultz
2016-11-16 1:10 ` John Stultz
2016-11-16 21:20 ` [PATCH v2] " Chris Metcalf
2016-11-15 0:56 ` David Gibson [this message]
2016-11-15 7:58 ` [PATCH] " Laurent Vivier
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=20161115005636.GF24747@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=christopher.s.hall@intel.com \
--cc=cmetcalf@mellanox.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvivier@redhat.com \
--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®