From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by sourceware.org (Postfix) with ESMTPS id A7ACD385482E for ; Tue, 31 Jan 2023 14:47:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A7ACD385482E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=amazon.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1675176452; x=1706712452; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=hfKvynij+gWLnOIDBUWep6Il7TK7O1/2MRlkg7YQjcY=; b=KHcFbz9GvjeBXIC9OOoc4sf6HddGV8llLd0YphqpjwVIp123Un5absih ZS1OVgy/gZ7udTXVwr52DeOTtRfafL6EzFztEyA3T3OrqUDwtqBIeU5Cp B/+V2Fl3p0cYcQEU3CbcsBuGnLy2AUT9KQUbGuPwRrG/zVrOP77JACHOF Y=; X-IronPort-AV: E=Sophos;i="5.97,261,1669075200"; d="scan'208";a="288173788" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1a-m6i4x-93c3b254.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 14:47:31 +0000 Received: from EX13MTAUWA002.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1a-m6i4x-93c3b254.us-east-1.amazon.com (Postfix) with ESMTPS id 58D05E2E0B; Tue, 31 Jan 2023 14:47:30 +0000 (UTC) Received: from EX19D044UWA003.ant.amazon.com (10.13.139.43) by EX13MTAUWA002.ant.amazon.com (10.43.160.12) with Microsoft SMTP Server (TLS) id 15.0.1497.45; Tue, 31 Jan 2023 14:47:27 +0000 Received: from EX19D044UWA004.ant.amazon.com (10.13.139.7) by EX19D044UWA003.ant.amazon.com (10.13.139.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.24; Tue, 31 Jan 2023 14:47:27 +0000 Received: from EX19D044UWA004.ant.amazon.com ([fe80::781f:7190:c095:c260]) by EX19D044UWA004.ant.amazon.com ([fe80::781f:7190:c095:c260%5]) with mapi id 15.02.1118.024; Tue, 31 Jan 2023 14:47:27 +0000 From: "Tang, Jun" To: Zack Weinberg , GNU libc development Subject: RE: bug fix for hp-timing.h (aarch64) Thread-Topic: bug fix for hp-timing.h (aarch64) Thread-Index: Adkl2yuxhhuxivSvTB+TnnsYBV/4yK64twNA Date: Tue, 31 Jan 2023 14:47:26 +0000 Message-ID: <4c349a9a330940a78e0e05de192542b6@amazon.com> References: <8ae95272accb441aad774a5f10d27d57@amazon.com> <3dd92ee4-00b4-4bf2-ae8c-908a29752198@app.fastmail.com> In-Reply-To: <3dd92ee4-00b4-4bf2-ae8c-908a29752198@app.fastmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.13.138.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Zack, After rounds of discussion, the suggested solution is the best option and w= orks for all existing benches. Let me know if I need to submit another req= uest to get this merged > - (Diff) =3D ((End) - (Start)) * (UINT64_C(1000000000) / freq); \ > + (Diff) =3D (((End) - (Start)) * UINT64_C(1000000000)) / freq; \ Regards, Jun -----Original Message----- From: Zack Weinberg =20 Sent: Wednesday, January 11, 2023 11:22 AM To: GNU libc development Subject: Re: bug fix for hp-timing.h (aarch64) On Wed, Jan 11, 2023, at 11:44 AM, Tang, Jun wrote: > On Graviton 3 the frequency is 1050000000 and the original function=20 > hp-timing.h no longer gives the correct answer. The following patch=20 > can fix the bug: Please try this instead: > - (Diff) =3D ((End) - (Start)) * (UINT64_C(1000000000) / freq); \ > + (Diff) =3D (((End) - (Start)) * UINT64_C(1000000000)) / freq; \ This avoids using floating-point arithmetic but should still do the rescale= correctly. (The multiplier and divisor are both guaranteed to be less than 2**32, so, = as long as we do the multiplication in 64-bit arithmetic, we cannot lose bi= ts via overflow.) zw