Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932561AbcLHXrr (ORCPT ); Thu, 8 Dec 2016 18:47:47 -0500 Received: from ozlabs.org ([103.22.144.67]:49277 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752444AbcLHXrl (ORCPT ); Thu, 8 Dec 2016 18:47:41 -0500 Date: Fri, 9 Dec 2016 10:39:22 +1100 From: David Gibson To: Thomas Gleixner Cc: LKML , John Stultz , Peter Zijlstra , Ingo Molnar , Liav Rehana , Chris Metcalf , Richard Cochran , Parit Bhargava , Laurent Vivier , "Christopher S. Hall" Subject: Re: [patch 2/6] timekeeping: Make the conversion call chain consistently unsigned Message-ID: <20161208233922.GK13139@umbus.fritz.box> References: <20161208202623.883855034@linutronix.de> <20161208204228.765843099@linutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gwtGiOGliFx8mAnm" Content-Disposition: inline In-Reply-To: <20161208204228.765843099@linutronix.de> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4831 Lines: 159 --gwtGiOGliFx8mAnm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 08, 2016 at 08:49:34PM -0000, Thomas Gleixner wrote: > Propagating a unsigned value through signed variables and functions makes > absolutely no sense and is just prone to (re)introduce subtle signed > vs. unsigned issues as happened recently. >=20 > Clean it up. >=20 > Signed-off-by: Thomas Gleixner Reviewed-by: David Gibson > --- > kernel/time/timekeeping.c | 26 +++++++++++++------------- > 1 file changed, 13 insertions(+), 13 deletions(-) >=20 > --- a/kernel/time/timekeeping.c > +++ b/kernel/time/timekeeping.c > @@ -311,7 +311,7 @@ static inline u64 timekeeping_delta_to_n > return nsec + arch_gettimeoffset(); > } > =20 > -static inline s64 timekeeping_get_ns(struct tk_read_base *tkr) > +static inline u64 timekeeping_get_ns(struct tk_read_base *tkr) > { > cycle_t delta; > =20 > @@ -319,8 +319,8 @@ static inline s64 timekeeping_get_ns(str > return timekeeping_delta_to_ns(tkr, delta); > } > =20 > -static inline s64 timekeeping_cycles_to_ns(struct tk_read_base *tkr, > - cycle_t cycles) > +static inline u64 timekeeping_cycles_to_ns(struct tk_read_base *tkr, > + cycle_t cycles) > { > cycle_t delta; > =20 > @@ -623,7 +623,7 @@ static void timekeeping_forward_now(stru > { > struct clocksource *clock =3D tk->tkr_mono.clock; > cycle_t cycle_now, delta; > - s64 nsec; > + u64 nsec; > =20 > cycle_now =3D tk->tkr_mono.read(clock); > delta =3D clocksource_delta(cycle_now, tk->tkr_mono.cycle_last, tk->tkr= _mono.mask); > @@ -652,7 +652,7 @@ int __getnstimeofday64(struct timespec64 > { > struct timekeeper *tk =3D &tk_core.timekeeper; > unsigned long seq; > - s64 nsecs =3D 0; > + u64 nsecs; > =20 > do { > seq =3D read_seqcount_begin(&tk_core.seq); > @@ -692,7 +692,7 @@ ktime_t ktime_get(void) > struct timekeeper *tk =3D &tk_core.timekeeper; > unsigned int seq; > ktime_t base; > - s64 nsecs; > + u64 nsecs; > =20 > WARN_ON(timekeeping_suspended); > =20 > @@ -735,7 +735,7 @@ ktime_t ktime_get_with_offset(enum tk_of > struct timekeeper *tk =3D &tk_core.timekeeper; > unsigned int seq; > ktime_t base, *offset =3D offsets[offs]; > - s64 nsecs; > + u64 nsecs; > =20 > WARN_ON(timekeeping_suspended); > =20 > @@ -779,7 +779,7 @@ ktime_t ktime_get_raw(void) > struct timekeeper *tk =3D &tk_core.timekeeper; > unsigned int seq; > ktime_t base; > - s64 nsecs; > + u64 nsecs; > =20 > do { > seq =3D read_seqcount_begin(&tk_core.seq); > @@ -804,8 +804,8 @@ void ktime_get_ts64(struct timespec64 *t > { > struct timekeeper *tk =3D &tk_core.timekeeper; > struct timespec64 tomono; > - s64 nsec; > unsigned int seq; > + u64 nsec; > =20 > WARN_ON(timekeeping_suspended); > =20 > @@ -893,8 +893,8 @@ void ktime_get_snapshot(struct system_ti > unsigned long seq; > ktime_t base_raw; > ktime_t base_real; > - s64 nsec_raw; > - s64 nsec_real; > + u64 nsec_raw; > + u64 nsec_real; > cycle_t now; > =20 > WARN_ON_ONCE(timekeeping_suspended); > @@ -1052,7 +1052,7 @@ int get_device_system_crosststamp(int (* > cycle_t cycles, now, interval_start; > unsigned int clock_was_set_seq =3D 0; > ktime_t base_real, base_raw; > - s64 nsec_real, nsec_raw; > + u64 nsec_real, nsec_raw; > u8 cs_was_changed_seq; > unsigned long seq; > bool do_interp; > @@ -1365,7 +1365,7 @@ void getrawmonotonic64(struct timespec64 > struct timekeeper *tk =3D &tk_core.timekeeper; > struct timespec64 ts64; > unsigned long seq; > - s64 nsecs; > + u64 nsecs; > =20 > do { > seq =3D read_seqcount_begin(&tk_core.seq); >=20 >=20 --=20 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 --gwtGiOGliFx8mAnm Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYSe8qAAoJEGw4ysog2bOSA04QAJ9EPT3oWMVaMp/l60Nx3qvf fdhNw9tT1fIs+kkf+gvyHF2ohJNhCswauyJI0abOCYILP5TPDBVXY+4TdhWd2P2N Fctvp9Yx8tqTxEmMrraCvrOx79PByFgNOMjCRmLb40+dLd25XKLtMHHRu+woQJXd 2eAzvQpCbuttVFp1Yq/l+AABNONmTHv5iTqUpKEOL02KEHFzh9AAKfm6+DgEaO8H dHP8iCCg/VNnt6y5hxSiyi7N7+A5VwijMkUjA/TaPoyPateBo/RkwOjmL6MiAxBx iTm/OXNNnXFqlxM8WqATzEjj2UWGNG8zfbCsAdJa4boegSVTGWg4mB0l3G44wRMn kXmDEb8nQz9RWElVtA7jh1LZgs+3yA+q5mkiqn/8/a14tT3KY0yDHvbzpioMiPfR 5CK8pTGgmApiPbwkAjbzv90dDBP3URbEr6F6gA66vAZfXzLhxIOIdmKBNLSMsgnY klhiReN3D/8kQRsWYYxJHOkP4L+vPYrI7PpC9ufZlHGOIV/LzFZwmZMHrreFDT4V SO8sjJGTpgKtVpRuGLSAOhneGv/DibiMm6R1b5ZheawKmkKIwC49JfD/k6YQclyy kuxwHkWhzgKvdr/fgmAIPzC+3vInMKX3yaoylg28gXITFMGECNZnCC5G64j4OuWQ c98TWTCAEoKSBkd81NRS =cP7M -----END PGP SIGNATURE----- --gwtGiOGliFx8mAnm--