From owner-freebsd-hackers@freebsd.org Fri Mar 1 01:55:18 2019 Return-Path: Delivered-To: freebsd-hackers@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 D5E30152253A for ; Fri, 1 Mar 2019 01:55:17 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic307-4.consmr.mail.bf2.yahoo.com (sonic307-4.consmr.mail.bf2.yahoo.com [74.6.134.43]) (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 754C56D7EF for ; Fri, 1 Mar 2019 01:55:17 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: jT3IWfoVM1kZB7yR6G7_dt2A3l7AF_OhcbajmfnevZx6kFf3qqShpcHcmhpji.s HYDTKXOD9qz2AmFDVp8lAyy6UQ7Kpv1wvkjn33_flUtR1fbNRvyOqFhZADXPzfbd6zaqtL21zkzE bYNrmkdzyYuxPQB5dOayqklxAKJ1Ziigkg7A.bBwGTiitUpu.QPT3ArPZlpXF3bgB7.bTNOKaG15 6Zvba2h.5iLAAVXnWSS1Ds1U9NfN8..8456D5Sum0MrLakh.84UuXaZcsZXsjzZwRNzVdrLulNwl SZBRRzeUIR7L.hcfizvvInDZQTeVXonKm.qS1ZDm3Fz_1yACFsQoThkB5l8Uz4hKC3SxCQDqgrYV AtIFQeNKbLnL3h9yXyitzdZnRa3zhhkg2cvmkvneeCakN51Hbtq31kOAfrUaeY_p9wwNZDfFaueN I108fd3coL.vYEfk7iYUAk.lp.ik14.dEH1.4oLLHpMehLL8yk6mwd0oh9GsAZ_XazXax1zB2jXQ I_CjXlKy8.QVLggrWZispV9aEcBkgsKLhky1TfjyyLj_bze4fItbAAfuRCMRv9axu25osG8sYPtZ gEdYgi5YQsVKaRHclic5zM1Pfy74zq_U72phYCWHYH1VupGv50rxyxKPb3VyT7W2oV4g4hTanOX. tGT_QTUHpjcqb8VuaEc_gzYW8kJogZ4XN0KGkHiF7vw56KxjDh4561k9tq09vM0fMqksh8XFRW92 4_7v0JIA.adzqKwWZLduBkabtKGQtY0Zxf5LdFoyvhbAM3TS5efDOpFKAs0fB2sPuQdjgj8bNUf3 B94uga..BVVd905ybHOJhTiMJm13Kk1YAktKbNoTKu_D6def5NomYv1MjyzXSBPYWXJxk10VOS2j DXZoBPSQtSIcBWbogQJK5Yc8gCciF0BwbDhVcbh_um1dxFODs4Ln7vBGCqvuT9QbA90I7E9FeZqx yPuUeyqPwKIfX8IZpbtx9EWc73HTpPVUDMbkidYKd6sjoVOkF2mI5HK5pJjUIhRyIfAKjP50wM9I A1bBnbAmiqOnfHQLXLD7BR5NLryHCHwZ0yqaFfJqs0JOUE5sB8aRcBe3M6qmaLUuLv1MEjkeEFA- - Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.bf2.yahoo.com with HTTP; Fri, 1 Mar 2019 01:55:09 +0000 Received: from c-67-170-167-181.hsd1.or.comcast.net (EHLO [192.168.1.113]) ([67.170.167.181]) by smtp425.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 7611b58950e303ae4e9242192a9f1369; Fri, 01 Mar 2019 01:55:06 +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 [patched failed] From: Mark Millard In-Reply-To: <20190228150811.GU2420@kib.kiev.ua> Date: Thu, 28 Feb 2019 17:55:04 -0800 Cc: freebsd-hackers Hackers , FreeBSD PowerPC ML Content-Transfer-Encoding: quoted-printable Message-Id: <962D78C3-65BE-40C1-BB50-A0088223C17B@yahoo.com> References: <20190228145542.GT2420@kib.kiev.ua> <20190228150811.GU2420@kib.kiev.ua> To: Konstantin Belousov X-Mailer: Apple Mail (2.3445.102.3) X-Rspamd-Queue-Id: 754C56D7EF X-Spamd-Bar: ------ X-Spamd-Result: default: False [-6.99 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.99)[-0.991,0] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Mar 2019 01:55:18 -0000 [The PowerMac becomes non-responsive for significant periods of time.] On 2019-Feb-28, at 07:08, Konstantin Belousov = wrote: > 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; > + bt->sec +=3D x >> 32; > + bintime_addx(bt, x << 32); > + } > + 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; > + bt->sec +=3D x >> 32; > + bintime_addx(bt, x << 32); > + } > + bintime_addx(bt, scale * delta); > atomic_thread_fence_acq(); > } while (gen =3D=3D 0 || gen !=3D th->th_generation); > } The PowerPC G5 ends up not responsive for long periods and responsive for only very short periods, such as being able to type in a few letters and have them show up at the time. I've only barely started investigating what is going on and I'll be rechecking my instrumented variant for stupid mistakes and such. I"ll try your un-instrumented binuptime as well. As stands I'll be updating the kernel via booting a 2nd disk that is not being experimented with. My information gathering may not be very timely. =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)