From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2088.outbound.protection.outlook.com [40.107.247.88]) by sourceware.org (Postfix) with ESMTPS id 2A4DA38543B0 for ; Thu, 12 Jan 2023 20:32:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A4DA38543B0 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5lswqhpWdiUf4GiELCO9ySMZELlTPbP+4H37o1vt+jY=; b=lclto36ZLCbj5Am2JMbsGoWyYh/ZxDYe48wG4X8qlwLmUziUhRjaUuMg9zh57wEl2OEEN+NmJUH9vLKWb7/RWRKuhJQeUfRk+opmlQRLBXhHGqinjmV8RlvyQlQtnfKZRmdaLV8aLnqP+5ip52aWBcuZKsKloMRWS+h9hB7SR8Y= Received: from ZR0P278CA0170.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:45::12) by AS8PR08MB7920.eurprd08.prod.outlook.com (2603:10a6:20b:53b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Thu, 12 Jan 2023 20:32:18 +0000 Received: from VI1EUR03FT020.eop-EUR03.prod.protection.outlook.com (2603:10a6:910:45:cafe::c) by ZR0P278CA0170.outlook.office365.com (2603:10a6:910:45::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.14 via Frontend Transport; Thu, 12 Jan 2023 20:32:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VI1EUR03FT020.mail.protection.outlook.com (100.127.144.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 20:32:18 +0000 Received: ("Tessian outbound 333ca28169fa:v132"); Thu, 12 Jan 2023 20:32:18 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b81d23c1593959e9 X-CR-MTA-TID: 64aa7808 Received: from fa2c6d1b8ffc.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7B70AF51-42DB-4520-AF8D-1ADE8EF78A7B.1; Thu, 12 Jan 2023 20:32:10 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fa2c6d1b8ffc.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 12 Jan 2023 20:32:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XilT13dArYVHcyoTTEjaYb6mH8Z22Fra83niJRLVDPDnJnvLb3GueKdOWsvVfxedyIL4yFbVfAiqQHtEouHAA4RCYxpRfYd+ixeD5WQQvy6iOD+vJwP4TBAOky6FWGtUzzDe6pWoaiMaieL3lbkz8V5eZEdRCJMX5XoUuunKiYbaIzrIVd7hHBcHQwhUB8B16pGy380NZkq488xCrMKm2pchExrKJD/qIROSl1fEupp+YOSs1TjQghhLIoOHi5l5oy+pwjR4cGISWX9LcQwSy5oOGjaVZk62cuonGXhAf5GzwxE0jMbDCXXDPYScFRHTQXgKRL1jDUQUI3HKp7kaxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5lswqhpWdiUf4GiELCO9ySMZELlTPbP+4H37o1vt+jY=; b=gzd1W3HjLoIXUNWckWWo6xwC4ld4SUus/YLv2KYhhX9DVdxhIZ6aKe0Awxp8h2dV+/e6XxBFagbZ3lF5W7dqiCYqbp7I4znGgOqbsOmH1SS+N3Ew4Ni238tlxECfEAObQ9hnjViCicBiHuuWiX1+7ZOH4ajVT750/flA42dJhtHgvP2DsK41Im1OkwDSN6hU21CPJKC2UGN0AEPddaVUKIvgn6k4bdyOvsM7NCH+eeDOdPmkFA7PxiDy1EceYZ+f98yIJ35CZka2vQNVdMQ2ta8V5ZAylGGRFoiLTk92R3H7pQ4IippfdcJ2TY09zY21e2fPEFTOnPmdVkBRmYsdzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5lswqhpWdiUf4GiELCO9ySMZELlTPbP+4H37o1vt+jY=; b=lclto36ZLCbj5Am2JMbsGoWyYh/ZxDYe48wG4X8qlwLmUziUhRjaUuMg9zh57wEl2OEEN+NmJUH9vLKWb7/RWRKuhJQeUfRk+opmlQRLBXhHGqinjmV8RlvyQlQtnfKZRmdaLV8aLnqP+5ip52aWBcuZKsKloMRWS+h9hB7SR8Y= Received: from PAWPR08MB8982.eurprd08.prod.outlook.com (2603:10a6:102:33f::20) by DB3PR08MB9010.eurprd08.prod.outlook.com (2603:10a6:10:42b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Thu, 12 Jan 2023 20:32:09 +0000 Received: from PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::66e4:4940:d096:4f7]) by PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::66e4:4940:d096:4f7%9]) with mapi id 15.20.5986.018; Thu, 12 Jan 2023 20:32:09 +0000 From: Wilco Dijkstra To: Zack Weinberg , "Tang, Jun" CC: GNU libc development Subject: Re: bug fix for hp-timing.h (aarch64) Thread-Topic: bug fix for hp-timing.h (aarch64) Thread-Index: AQHZJg3QVFAnSPDyTkassNg7m1D9266a2aDggAApOnOAAB+IAIAACcQc Date: Thu, 12 Jan 2023 20:32:07 +0000 Message-ID: References: <31276f46-5376-4c2c-85c7-ffa08e9a771d@app.fastmail.com> In-Reply-To: <31276f46-5376-4c2c-85c7-ffa08e9a771d@app.fastmail.com> Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-traffictypediagnostic: PAWPR08MB8982:EE_|DB3PR08MB9010:EE_|VI1EUR03FT020:EE_|AS8PR08MB7920:EE_ X-MS-Office365-Filtering-Correlation-Id: 9655094e-9f54-4c59-b68c-08daf4dc1994 x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: OCEDDK3dJQcYgip4EP/Cxj+tp4IGqFNZ7NWoD98x/CHHQp8MVXZD4WAaYOTE00yN99q9/vQ5+NmDpPyYgPU2EWDhtFlvcA0kAYACGmR7Ng8qKbJQjhWyRQYjH3rrpKmOKXoLoqaeW+S+Tyr+ltruPfl6l4qiGDIRr2Qq2ZqGQEDxKBr4k8mtDuai2uHWq2AXfgFXLQ89aAHgKa0oUPCKHjy0KMAfwLCC7GMjiipnIqvufOawpOLdK+85ZwrJ4eVlov5SUP+yt+vyFITvKx770Pq9emrOUOmQR/AX5wvDnyjp2lvU7uSzwo505DUnB1+NSWCzzxpSvx5SXK86M4RgQ4nrSlcfuiSuPpGaxAq+aA0m2I5+Nfw7+S/FKKAmLbx1TW15mxW6MxLm4gPbqGoRsw2fvCrKWwF+lggSsvJIvR89jhcJcRsHKy13ZmYroJtxvhRinzXElAk+knCkC+zAfCx7X7wNF8Kt4j75Np5qh0mGF//CNpC0gzTNG1a2oR54PhgnBMg4zPwuEPRCSCualWVfmbfWufxfEvFVniZYUk64E5w1qEVW5lBn6uipb2Ht8FTBKhSZ0NbXom36G4WiTzbei8xT+4cleT4OVxMqnQ2+6iKphHwQKH4psmndG/Q9TVvPc7GC1/Q7LrI9p6bxgkuyY6/h1Xw0wUxcV497cRkSfMi/fe1ohmQ2mpSoErMHqpvnaPXbZUQNp2TDHH4VuA== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAWPR08MB8982.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(346002)(366004)(39860400002)(136003)(376002)(451199015)(5660300002)(33656002)(6506007)(2906002)(122000001)(38100700002)(83380400001)(71200400001)(86362001)(55016003)(7696005)(316002)(110136005)(9686003)(186003)(478600001)(26005)(91956017)(76116006)(8936002)(66946007)(4326008)(64756008)(8676002)(66446008)(66476007)(52536014)(38070700005)(66556008)(41300700001);DIR:OUT;SFP:1101; Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR08MB9010 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VI1EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d6a1aac9-bc70-45d0-50ea-08daf4dc134c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +NDEV5B+lxvLmIbtHP/+tRQbxM4by7VLRg5iXsWe3Lq1omfP1A643iZ0CxmCpJN+aaZqRN3lsFhP9jdYqTcn82rJ9VcVX4JfeUMuKYvwpSUUaLxzpWG5lVT4FdbWpQZVSMwy+V5Hh26CFGIDLbNSIV0wuA2LSkaEQ2qU32nmVHgsANFBUotS7TTmmFOgsX1rMKnelytr9SrPoJ1iXYO3s33e18esexOXSdrYACq2YLgnaBl2bBmGc/C6QfVnGPjTCdKpu+SrqYnEYS/OaJksnL7lH5tkNTzlq695fb8jWJJTh0CFdRlGz0hSzLzni4ILCAETMVSmkZ8AES8Zn3YYeXb2uvgdqQLhwr30F05bQPWUrazGjcovcdmxbCcvbNwGy9WjPG9wMfoZujBFUbxzGOsDaDS0GrvVGMxuVQSegpx3vBjQ5mOWQob4/sWNEn1sYghtzpFMiXuNn1PbgjmCaIiwt95UzMConF8yos1hevggcOdbUUb3xpEI12Ql4L9IC/OGNEod/SnWanCXABrl3n1EvzTsyDDp7SgtIpra4no2AQx9ePKzfhYdNk/3BdLCNqr5cX122v6NzLxKm8+ZNYCNL0sIPmecd4TWhHxublWUChpXu/KEKOzZrqnJVSbGIz3z5E2+/p1xohawQNAMwDOhiD2cH0xXTn2nth6XZtON9NT9K2PKtSpPLvc2+IDugQk4A48rke0f7SXgkvk5Vw== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(39860400002)(376002)(346002)(396003)(451199015)(36840700001)(46966006)(40470700004)(356005)(110136005)(82310400005)(41300700001)(478600001)(2906002)(6506007)(316002)(82740400003)(36860700001)(83380400001)(336012)(33656002)(52536014)(4326008)(8676002)(9686003)(40480700001)(26005)(86362001)(186003)(7696005)(55016003)(40460700003)(81166007)(5660300002)(70206006)(70586007)(47076005)(8936002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 20:32:18.4411 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9655094e-9f54-4c59-b68c-08daf4dc1994 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VI1EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7920 X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_NONE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Zack,=0A= =0A= >> On AArch64 the counter is absolutely solid - it's fixed frequency and sy= stem=0A= >> wide monotonically increasing. So there are no issues with varying clock= =0A= >> frequency or rescheduling to a different core, you get elapsed time at= =0A= >> nanosecond accuracy.=0A= >=0A= > ... but that's not what you _want_ for a benchmark!=A0 You don't want the= time=0A= > to tick up while the benchmark process is preempted (not executing on _an= y_=0A= > core), for instance.=A0 Or am I misunderstanding what this is used for?= =0A= =0A= Basically it is a lower overhead version of clock_get_time (CLOCK_MONOTONIC= )=0A= so you can use it to benchmark even small bits of code (since it doesn't in= sert=0A= extra function calls or affect register allocation in a major way).=0A= =0A= We don't strictly need to scale the result, you could just subtract the cou= nts.=0A= However it makes the result equivalent to clock_get_time and allows one to= =0A= compute bytes copied/ns if needed or compare different CPUs.=0A= =0A= It's hard to account for the effects of interrupts or preemption. And GLIBC= =0A= benchtests aren't all that smart either, so I often end up having to increa= se the=0A= iteration count to average out the OS effects (including frequency scaling)= .=0A= We could improve this, eg. take several samples at lower iteration counts= =0A= and only report the fastest one.=0A= =0A= Cheers,=0A= Wilco=