From owner-freebsd-ppc@freebsd.org Thu Feb 28 22:23:35 2019 Return-Path: Delivered-To: freebsd-ppc@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7888F151C0C8 for ; Thu, 28 Feb 2019 22:23:35 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic313-14.consmr.mail.bf2.yahoo.com (sonic313-14.consmr.mail.bf2.yahoo.com [74.6.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7DD208CC7D for ; Thu, 28 Feb 2019 22:23:34 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: Yxkyu2gVM1mrnnvGcuTlHIEWQmEoiysHtza7GiZuVgBPTgPGxTjxHnSdUHavV4M eAcLDhd9fw49La.wIUuVV44oFuLwX5leMf5Bx7F.2RXevsapGNbikariuAOJXxSKtk1HXlvfW6B8 NOul1933tY7DcJ47v0gNASRLfypf5ADJ1DkWnqswP0atTKHMDQoMfKH6vnKhD_x6InSAdiCltpGJ gqQ1TIUd9DTbN9GhgmugtfiZLhKexAxuT_wAag7OJRW5gGLMcA0NNGgj5H0viSo.Ddxt7MV.8NWd 7vsMkXxMg5Y1Sq2o9iytNVcgeGG_HWOgBj100T4wRXHyCI_H0P_C6hMJtVmUCZ6Bp4WjwzlwTQVW qOypIUWZwBe_mHHCQFbIxnAtBBr.Os0H2pILS.ygyN8hSIYJr0ggUwg6c9JxkCKkNZTMsUKpEJFD nrMRxyaRO9nPj0lQYTk1aiLbKMmJbDgGQp1k7yLwWXZ1r6TZlMiFzXl1TEu21ALhUKHOHQTTIqw8 arwhj4k4Mp9tp8otkUGrkAYGWGK3DQRj6H_H0c3mxeB942XcJQz_DAWrjBLE5fTH0iZOI11.OMTn rHR34j3wZ5VbS6IF0T_4WNtoLg1s.HkMwGntmzi6waotAO4ZJFyHB4FiiOlkzLyewnw8mHWHGyYd 4a9Mc6lHGWkpwbln6Oxmo4BetU0_jpE6KXs3q9U3nOVV1.nrmpZa04Fbss3ZOFW2lqEw8bSjh2MH N8A7h6yPbx4gflOkWFgKovytFtxTqQbtJqpZSzZS74oNQJLdC0R3ZoLQc6Kin_ZwVTR0tvRCGvxz vcZwIzTHFUYnmg8o_trCxy8QhdIAMgv8dZ1ql0BPPtXYSdfWIFMzsHfNROfDDa395OMJe2TZ4AKG YjZBKCqohyhgdnTvxnxj4VDBDXUZ3WcLiB0adreaOXCBOgtlyyB_jpM2XZIfhZyg8tiN7sE9Se7P 8vlwQb3TbNYh2kVsVw5L2s3U8qacQPHPqq_1P88TaKcMqSQ864cVAl1rcJwtcBPZ0iZ2wGD2WaaV IKBwtSXdNLkRR.K6KXuRCfoZNPcfA7214wCtZeObqaSYPKPOxBkPIMNJkn4WGxTTdGrAQxKs- Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.bf2.yahoo.com with HTTP; Thu, 28 Feb 2019 22:23:32 +0000 Received: from c-67-170-167-181.hsd1.or.comcast.net (EHLO [192.168.1.113]) ([67.170.167.181]) by smtp402.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID ea3e99fc12ba6d8e3cb563de5a3d005b; Thu, 28 Feb 2019 22:23:28 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: powerpc64 head -r344018 stuck sleeping problems: th->th_scale * tc_delta(th) overflows unsigned 64 bits sometimes From: Mark Millard In-Reply-To: Date: Thu, 28 Feb 2019 14:23:26 -0800 Cc: freebsd-hackers Hackers , FreeBSD PowerPC ML Content-Transfer-Encoding: quoted-printable Message-Id: <5C2FABEC-C56A-4153-A3FD-D5E1D54F1F6E@yahoo.com> References: <20190228145542.GT2420@kib.kiev.ua> <20190228150811.GU2420@kib.kiev.ua> <0A345E1F-7675-4B4B-8A74-ACD59E90E72F@yahoo.com> To: Konstantin Belousov X-Mailer: Apple Mail (2.3445.102.3) X-Rspamd-Queue-Id: 7DD208CC7D X-Spamd-Bar: +++ X-Spamd-Result: default: False [3.18 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ptr:yahoo.com]; MV_CASE(0.50)[]; FREEMAIL_FROM(0.00)[yahoo.com]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[yahoo.com:+]; MX_GOOD(-0.01)[cached: mta6.am0.yahoodns.net]; DMARC_POLICY_ALLOW(-0.50)[yahoo.com,reject]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[yahoo.com]; ASN(0.00)[asn:26101, ipnet:74.6.128.0/21, country:US]; MID_RHS_MATCH_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[yahoo.com.dwl.dnswl.org : 127.0.5.0]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[yahoo.com:s=s2048]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_SPAM_SHORT(0.99)[0.994,0]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; NEURAL_SPAM_MEDIUM(0.58)[0.583,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(0.68)[0.676,0]; RCVD_IN_DNSWL_NONE(0.00)[124.133.6.74.list.dnswl.org : 127.0.5.0]; IP_SCORE(1.44)[ip: (4.50), ipnet: 74.6.128.0/21(1.53), asn: 26101(1.22), country: US(-0.07)] X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Feb 2019 22:23:35 -0000 [I was distracted and made a stupid mistake. Sorry for the noise.] On 2019-Feb-28, at 13:50, Mark Millard wrote: > [I left implicit that I was summarizing for x!=3D0.] >=20 > On 2019-Feb-28, at 13:46, Mark Millard wrote: >=20 >=20 >=20 >> On 2019-Feb-28, at 07:08, Konstantin Belousov = wrote: >>=20 >>> On Thu, Feb 28, 2019 at 04:55:42PM +0200, Konstantin Belousov wrote: >>>> On Thu, Feb 28, 2019 at 05:06:23AM -0800, Mark Millard via = freebsd-ppc wrote: >>>>> . . . >>>>=20 >>>> . . . >>>=20 >>> Of course I botched the formula, please try this instead: >>>=20 >>> diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c >>> index 2656fb4d22f..fdd4f4f6a52 100644 >>> --- a/sys/kern/kern_tc.c >>> +++ b/sys/kern/kern_tc.c >>> @@ -355,13 +355,22 @@ void >>> binuptime(struct bintime *bt) >>> { >>> struct timehands *th; >>> - u_int gen; >>> + uint64_t scale, x; >>> + u_int delta, gen; >>>=20 >>> do { >>> th =3D timehands; >>> gen =3D atomic_load_acq_int(&th->th_generation); >>> *bt =3D th->th_offset; >>> - bintime_addx(bt, th->th_scale * tc_delta(th)); >>> + scale =3D th->th_scale; >>> + delta =3D tc_delta(th); >>> + if (fls(scale) + fls(delta) > 63) { >>> + x =3D (scale >> 32) * delta; >>> + scale &=3D UINT_MAX; >>=20 >> The following two lines confuse me overall: >>=20 >>> + bt->sec +=3D x >> 32; >>> + bintime_addx(bt, x << 32); >>=20 >> bintime_addx does: >>=20 >> static __inline void >> bintime_addx(struct bintime *_bt, uint64_t _x) >> { >> uint64_t _u; >>=20 >> _u =3D _bt->frac; >> _bt->frac +=3D _x; >> if (_u > _bt->frac) >> _bt->sec++; >> } >>=20 >> So I'd expect: >=20 > I forgot to indicate the context: when x!-0 >=20 >> bintime_addx(bt, x << 32) >>=20 >> to find _u > _bt->frac and to also do _bt->sec++ . >> So overall (as a means of summarizing for >> bt->sec): How I got _u > _bt->frac for that call in general when the call's (x<<32) !=3D 0 I do not know. So ignore my stupid, mistaken questions. >> bt->sec +=3D (x >> 32) + 1; >>=20 >> Is that the intent? >>=20 >>=20 >>> + } >>> + bintime_addx(bt, scale * delta); >>> atomic_thread_fence_acq(); >>> } while (gen =3D=3D 0 || gen !=3D th->th_generation); >>> } >>> @@ -388,13 +397,22 @@ void >>> bintime(struct bintime *bt) >>> { >>> struct timehands *th; >>> - u_int gen; >>> + uint64_t scale, x; >>> + u_int delta, gen; >>>=20 >>> do { >>> th =3D timehands; >>> gen =3D atomic_load_acq_int(&th->th_generation); >>> *bt =3D th->th_bintime; >>> - bintime_addx(bt, th->th_scale * tc_delta(th)); >>> + scale =3D th->th_scale; >>> + delta =3D tc_delta(th); >>> + if (fls(scale) + fls(delta) > 63) { >>> + x =3D (scale >> 32) * delta; >>> + scale &=3D UINT_MAX; >>=20 >> The same for the below two lines: >>=20 >>> + bt->sec +=3D x >> 32; >>> + bintime_addx(bt, x << 32); >>=20 >>=20 >>> + } >>> + bintime_addx(bt, scale * delta); >>> atomic_thread_fence_acq(); >>> } while (gen =3D=3D 0 || gen !=3D th->th_generation); >>> } >>=20 >=20 >=20 =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)