From patchwork Tue Jun 16 12:42:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Butler X-Patchwork-Id: 39640 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ACDBA388B02F; Tue, 16 Jun 2020 12:42:56 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40077.outbound.protection.outlook.com [40.107.4.77]) by sourceware.org (Postfix) with ESMTPS id 9B48B383F84F for ; Tue, 16 Jun 2020 12:42:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9B48B383F84F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Alex.Butler@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=G0riiAJ+cnD1lsZYdBtHI5mmlHQMhikjuRM8d9V/2L8=; b=aHWQvmgv39tjKowg3yKSoJnXEnQFd2+C2WPArTDkqUhh1+H6YokODy1PkgaATA3vzfdaIC9hzaX3Uup3JkRB34m7JepRYokUtV1DHVrug94bZ9MAvZrLzszNypglGGO/7bNPQPb9tax7IdOKn4cDz0OqEAbFqcILTJlG4NOd1VY= Received: from DB6PR0402CA0005.eurprd04.prod.outlook.com (2603:10a6:4:91::15) by VI1PR08MB5470.eurprd08.prod.outlook.com (2603:10a6:803:136::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.22; Tue, 16 Jun 2020 12:42:49 +0000 Received: from DB5EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:91:cafe::a) by DB6PR0402CA0005.outlook.office365.com (2603:10a6:4:91::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19 via Frontend Transport; Tue, 16 Jun 2020 12:42:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT050.mail.protection.outlook.com (10.152.21.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.18 via Frontend Transport; Tue, 16 Jun 2020 12:42:49 +0000 Received: ("Tessian outbound 299e58e1e4d2:v59"); Tue, 16 Jun 2020 12:42:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 04cedddd5150897c X-CR-MTA-TID: 64aa7808 Received: from 9cb401cb418e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CE95F66A-5C9B-4ED4-BD47-96713EC7CA6E.1; Tue, 16 Jun 2020 12:42:44 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9cb401cb418e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 16 Jun 2020 12:42:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WqgPqepw2MmueT7ZF225VFg4K7IEvzPpyoNc2HMKxWmIYWb+yRpi42vUerToYxiLAuzhxYjXTJ6cEkeIzlIaV8biTlGypPz+dgjN/jWpwlCoohYvBCQB169QNM5e7/bHuylnlJ2gXJa47L4ZWfGfErpSpGx7YzxIIKlXMzGCr/gLmQt2JQ4y5T/PJFY6MTTv1lg+40w3pjQIGBnsxwrz39ySY5Wv4q1BIuN3xFUdj3cWijLaX2CSiJHObn4s3tn1fHc5nWW0kxpyy+45XdMFN3TGO2wUuF1XqvdL1VwXmwBiBwrsee3WP6P/d1hl5IDOP+SqXHDeOXPiIZJ5oIgTkQ== 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-SenderADCheck; bh=G0riiAJ+cnD1lsZYdBtHI5mmlHQMhikjuRM8d9V/2L8=; b=lz7bpTj7e49dacK3yQXLsi5tksr2dOvQ+8VAPniCLiOpsnT8VcWr8nuVnC7+fZmotuxiullrQvpMEubNAHvLt1lh3gp4tVZmtCQnfnlpEu0579KIb1Hf/LZ6mx+MVT5AIs0xtWHmFpuR6rUGcwcMeUec6F+/CEmzlrh6IIgeAJJQgvLlYRJPJNv06kmXJb6/0zcj2OcsBZT96TaMGZfeGv8ClKK4H1BaZwFU4LcYAV7QPaHuhb6973+VuEqz94MTBykoqbUdOTSrRvfGw2XiXYEM9pg/YMjJI3T/m5PHf3jdKAkUedf1CyTEtP0aU+f3+wa5igW+AriMK7QldDOgmA== 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=G0riiAJ+cnD1lsZYdBtHI5mmlHQMhikjuRM8d9V/2L8=; b=aHWQvmgv39tjKowg3yKSoJnXEnQFd2+C2WPArTDkqUhh1+H6YokODy1PkgaATA3vzfdaIC9hzaX3Uup3JkRB34m7JepRYokUtV1DHVrug94bZ9MAvZrLzszNypglGGO/7bNPQPb9tax7IdOKn4cDz0OqEAbFqcILTJlG4NOd1VY= Received: from VI1PR08MB3663.eurprd08.prod.outlook.com (2603:10a6:803:85::26) by VI1PR08MB3024.eurprd08.prod.outlook.com (2603:10a6:803:45::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.25; Tue, 16 Jun 2020 12:42:39 +0000 Received: from VI1PR08MB3663.eurprd08.prod.outlook.com ([fe80::dda9:2735:3473:b60c]) by VI1PR08MB3663.eurprd08.prod.outlook.com ([fe80::dda9:2735:3473:b60c%6]) with mapi id 15.20.3088.028; Tue, 16 Jun 2020 12:42:38 +0000 From: Alex Butler To: "libc-alpha@sourceware.org" Subject: [PATCH] aarch64: MTE compatible strcmp Thread-Topic: [PATCH] aarch64: MTE compatible strcmp Thread-Index: AQHWQ9tc+sAU8nYGVEOVDtn1SnCbVQ== Date: Tue, 16 Jun 2020 12:42:38 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; x-originating-ip: [82.70.46.126] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 851db849-1e94-435b-fca5-08d811f2c747 x-ms-traffictypediagnostic: VI1PR08MB3024:|VI1PR08MB5470: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:10000;OLM:10000; x-forefront-prvs: 04362AC73B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: /fbp0PmpxgZHcEqWfecX1ga1wm55o89ZYAGxY4F0pxEYICdMSdcU5sW4cNSgklEan56wamrR4wTGjBqIwdSpnRmqW0duQtVzrP/ImDu8o4RP+xlhot06fYR99OMfR23YEJABY19p9byLa07k5+SpijLgYxMOl7WUhuo4ffFApqFUqnq+mL8azTuUlRtauYCLLrGlYkHHpGUpRZBnmC/hVehVDHTRR9wXdyMm05cklcrygKGhy+hRE97GBG28GjESKetfZXnPzaTGxUJDomLdc34rL1Xx9wbRfgbH8ZddJ5bqFDJzDYe091ZQ/K41eNYxY99zeMbdjIDlAab5Wip3+96rrHq+/jQDo1qXy0ChO4ySDTM4gD2dT2jaP5r5oTzNGGqU2nX2xkINNthPCW5qJA== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB3663.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(396003)(346002)(376002)(39860400002)(136003)(66446008)(66556008)(91956017)(19627405001)(66616009)(64756008)(66476007)(76116006)(55016002)(7696005)(478600001)(5660300002)(9686003)(66946007)(26005)(86362001)(52536014)(6506007)(33656002)(6916009)(186003)(8676002)(316002)(99936003)(71200400001)(8936002)(83380400001)(2906002)(17423001)(156123004); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: 1JdeXbMon9ZlM7M+umuH1VwvmC44/Wr7DIlKfrfFs8qfbiC2cO2i/VGK4B/TjyufKfShtSvjC9ew7uWIvllqNMW86q9gazQKCiynBvpEu4tzruGQNJwCV1Wycfg2Uc/MNxjhZp4AK6SbY3tv7jj3vUqgPcTHZX3CoDtQ/DykwUMMQN1SHUiZh5Y9Iir1UG7cIxky9V4i6IhNt6ztoSIBVTDUKipDEh7R68AtI9UkCZdcCFs5sGelgSkAkZhnD416j4AQfBWH96KdrgCs/DjdjmRFPomOYd3H1RLjW+sJ7yJzBdvFUzUKsXQtpwzSev9RVibHZGiTfaoMULIs4TBp793Anhw+HjFShs9oRXkhkK5d8fX/QCpswjJ05sWRJx/+WaWhqAw7CnHrF2VftScOWAVj/+Nq+msNPfezh7fmJmUM/nf2fTUof+QEGhodxvk2DASf7LT+Xey02aYaREBaB4jnas88Xw5kh+5ll1/I2TY= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3024 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT050.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(376002)(39860400002)(136003)(346002)(396003)(46966005)(52536014)(66616009)(6916009)(356005)(336012)(33656002)(70206006)(82310400002)(70586007)(7696005)(19627405001)(55016002)(81166007)(9686003)(26005)(316002)(186003)(6506007)(47076004)(8936002)(478600001)(235185007)(82740400003)(99936003)(86362001)(30864003)(5660300002)(83380400001)(8676002)(2906002)(17423001)(156123004)(559001)(579004); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: f8f8ac50-a56c-4cf3-f870-08d811f2c0e4 X-Forefront-PRVS: 04362AC73B X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XfWN++dsepaXdeGYEZOEDSSXx1qEWh5DNSt5kqnGad8Lkpvui3FnHJ883MG/m+RerU48Dg6klV0fLdUqdZtMWn1sRKnD546Mt2vaoZ8PfUmbfoxDfD2hzKW9uYlwxo2Oe1W4mFVAmNoVAZhqFhlfmiYrotft1LwVzlOvdxDCX0KrMAJMeCaop2rNrxa+O6DJvKWuIbOt6zNHM92lT5xnB7pmIMxxg9Yyj3PXUeiGC5OBO5Sez1eRH1uIoplw7gqjHUCGTWgr+npChIqag42r6BjPAe0JTS3fAxNipo3VUMjXmh4loR3riGSTz7WsyiQzk0ymRsepYsZWqP3h0oh4BclpPLy+RdiEsc0vHDzMpeK+h9gGnTA020vpOGmwduBgvHyg2fUObrFJu3NNhbPmtLkhiNPWRnsA9WfPoeL3waWonAyYCc/8URoLtz7w8w2x X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2020 12:42:49.5991 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 851db849-1e94-435b-fca5-08d811f2c747 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5470 X-Spam-Status: No, score=-17.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This patch adds an MTE compatible implementation of strcmp. Please see the benchmark results for the performance uplift. | length | align1 | align2 | uplift A72 | uplift A53 | uplift N1 | | 1 | 1 | 1 | 0.87x | 1.03x | 1.06x | | 1 | 1 | 1 | 0.95x | 1.03x | 0.90x | | 1 | 1 | 1 | 0.95x | 1.03x | 0.90x | | 2 | 2 | 2 | 0.95x | 1.03x | 1.08x | | 2 | 2 | 2 | 0.95x | 1.08x | 1.08x | | 2 | 2 | 2 | 0.83x | 1.03x | 1.08x | | 3 | 3 | 3 | 0.95x | 1.03x | 1.17x | | 3 | 3 | 3 | 0.95x | 1.03x | 1.08x | | 3 | 3 | 3 | 0.95x | 1.04x | 1.08x | | 4 | 4 | 4 | 0.61x | 1.10x | 0.95x | | 4 | 4 | 4 | 0.95x | 1.03x | 1.05x | | 4 | 4 | 4 | 0.95x | 1.02x | 1.08x | | 5 | 5 | 5 | 0.59x | 1.09x | 0.95x | | 5 | 5 | 5 | 0.59x | 1.10x | 0.95x | | 5 | 5 | 5 | 0.59x | 1.10x | 0.95x | | 6 | 6 | 6 | 0.62x | 1.08x | 0.95x | | 6 | 6 | 6 | 0.62x | 1.10x | 0.78x | | 6 | 6 | 6 | 0.62x | 1.10x | 0.95x | | 7 | 7 | 7 | 0.62x | 1.09x | 0.95x | | 7 | 7 | 7 | 0.62x | 1.10x | 0.95x | | 7 | 7 | 7 | 0.62x | 1.11x | 1.01x | | 8 | 8 | 8 | 1.68x | 0.95x | 0.96x | | 8 | 8 | 8 | 0.93x | 0.96x | 1.03x | | 8 | 8 | 8 | 0.95x | 0.92x | 1.03x | | 9 | 9 | 9 | 0.62x | 1.10x | 0.96x | | 9 | 9 | 9 | 0.62x | 1.10x | 0.95x | | 9 | 9 | 9 | 0.60x | 1.10x | 0.98x | | 10 | 10 | 10 | 0.59x | 1.10x | 0.96x | | 10 | 10 | 10 | 0.59x | 1.10x | 0.96x | | 10 | 10 | 10 | 0.59x | 1.09x | 0.96x | | 11 | 11 | 11 | 0.59x | 1.10x | 0.96x | | 11 | 11 | 11 | 0.59x | 1.10x | 0.96x | | 11 | 11 | 11 | 0.59x | 1.10x | 0.96x | | 12 | 12 | 12 | 0.98x | 1.06x | 1.00x | | 12 | 12 | 12 | 0.62x | 1.10x | 0.80x | | 12 | 12 | 12 | 0.61x | 1.10x | 0.96x | | 13 | 13 | 13 | 1.00x | 1.05x | 1.00x | | 13 | 13 | 13 | 1.00x | 1.07x | 1.00x | | 13 | 13 | 13 | 1.00x | 1.05x | 1.00x | | 14 | 14 | 14 | 1.00x | 1.07x | 1.00x | | 14 | 14 | 14 | 1.01x | 1.05x | 1.00x | | 14 | 14 | 14 | 1.00x | 1.07x | 1.00x | | 15 | 15 | 15 | 0.99x | 1.05x | 1.12x | | 15 | 15 | 15 | 1.00x | 1.07x | 1.12x | | 15 | 15 | 15 | 1.00x | 1.05x | 1.12x | | 16 | 16 | 16 | 1.00x | 1.03x | 1.01x | | 16 | 16 | 16 | 1.76x | 1.00x | 0.97x | | 16 | 16 | 16 | 1.86x | 1.00x | 0.97x | | 17 | 17 | 17 | 1.00x | 1.06x | 1.00x | | 17 | 17 | 17 | 1.00x | 1.06x | 1.01x | | 17 | 17 | 17 | 1.00x | 1.05x | 1.00x | | 18 | 18 | 18 | 1.00x | 1.07x | 1.00x | | 18 | 18 | 18 | 1.01x | 1.05x | 1.00x | | 18 | 18 | 18 | 1.00x | 1.06x | 1.00x | | 19 | 19 | 19 | 1.00x | 1.05x | 1.00x | | 19 | 19 | 19 | 1.01x | 1.06x | 1.00x | | 19 | 19 | 19 | 1.00x | 1.06x | 1.00x | | 20 | 20 | 20 | 1.03x | 1.07x | 1.04x | | 20 | 20 | 20 | 1.00x | 1.07x | 1.00x | | 20 | 20 | 20 | 0.99x | 1.06x | 1.00x | | 21 | 21 | 21 | 1.03x | 1.07x | 1.04x | | 21 | 21 | 21 | 1.03x | 1.07x | 1.04x | | 21 | 21 | 21 | 1.05x | 1.07x | 1.04x | | 22 | 22 | 22 | 1.03x | 1.08x | 1.04x | | 22 | 22 | 22 | 1.03x | 1.07x | 1.04x | | 22 | 22 | 22 | 1.03x | 1.07x | 1.04x | | 23 | 23 | 23 | 1.02x | 1.07x | 1.03x | | 23 | 23 | 23 | 1.03x | 1.07x | 1.04x | | 23 | 23 | 23 | 1.03x | 1.07x | 1.04x | | 24 | 24 | 24 | 1.04x | 1.04x | 1.05x | | 24 | 24 | 24 | 1.00x | 1.03x | 0.82x | | 24 | 24 | 24 | 1.01x | 0.98x | 1.01x | | 25 | 25 | 25 | 1.03x | 1.07x | 1.04x | | 25 | 25 | 25 | 1.03x | 1.07x | 1.04x | | 25 | 25 | 25 | 1.03x | 1.07x | 1.04x | | 26 | 26 | 26 | 1.03x | 1.07x | 1.04x | | 26 | 26 | 26 | 1.03x | 1.07x | 1.04x | | 26 | 26 | 26 | 1.03x | 1.07x | 1.04x | | 27 | 27 | 27 | 1.03x | 1.07x | 1.04x | | 27 | 27 | 27 | 1.03x | 1.07x | 1.04x | | 27 | 27 | 27 | 1.03x | 1.08x | 1.04x | | 28 | 28 | 28 | 1.05x | 1.09x | 1.06x | | 28 | 28 | 28 | 1.03x | 1.08x | 1.04x | | 28 | 28 | 28 | 1.02x | 1.07x | 1.04x | | 29 | 29 | 29 | 1.06x | 1.09x | 1.09x | | 29 | 29 | 29 | 1.06x | 1.09x | 1.06x | | 29 | 29 | 29 | 1.06x | 1.08x | 1.06x | | 30 | 30 | 30 | 1.06x | 1.09x | 1.06x | | 30 | 30 | 30 | 1.06x | 1.09x | 1.05x | | 30 | 30 | 30 | 1.07x | 1.09x | 1.06x | | 31 | 31 | 31 | 1.06x | 1.09x | 1.06x | | 31 | 31 | 31 | 1.06x | 1.09x | 1.06x | | 31 | 31 | 31 | 1.06x | 1.09x | 1.05x | | 4 | 0 | 0 | 0.94x | 0.96x | 1.01x | | 4 | 0 | 0 | 0.94x | 0.96x | 1.00x | | 4 | 0 | 0 | 0.94x | 0.95x | 0.90x | | 4 | 0 | 0 | 0.94x | 0.96x | 0.90x | | 4 | 0 | 0 | 0.94x | 0.96x | 0.91x | | 4 | 0 | 0 | 0.94x | 0.96x | 0.91x | | 4 | 0 | 1 | 0.92x | 0.93x | 0.73x | | 4 | 1 | 2 | 0.87x | 0.98x | 0.84x | | 8 | 0 | 0 | 1.00x | 1.00x | 0.76x | | 8 | 0 | 0 | 1.00x | 0.96x | 0.75x | | 8 | 0 | 0 | 0.92x | 0.90x | 1.01x | | 8 | 0 | 0 | 0.94x | 0.96x | 1.00x | | 8 | 0 | 0 | 0.94x | 0.97x | 1.01x | | 8 | 0 | 0 | 0.94x | 0.90x | 0.99x | | 8 | 0 | 2 | 0.86x | 0.95x | 0.78x | | 8 | 2 | 3 | 0.99x | 0.96x | 1.22x | | 16 | 0 | 0 | 1.01x | 1.02x | 1.01x | | 16 | 0 | 0 | 1.00x | 0.97x | 1.01x | | 16 | 0 | 0 | 1.00x | 1.00x | 0.76x | | 16 | 0 | 0 | 1.00x | 1.00x | 0.97x | | 16 | 0 | 0 | 1.00x | 1.00x | 0.97x | | 16 | 0 | 0 | 1.00x | 1.00x | 0.97x | | 16 | 0 | 3 | 0.86x | 1.00x | 0.88x | | 16 | 3 | 4 | 1.00x | 0.93x | 1.10x | | 32 | 0 | 0 | 1.07x | 1.04x | 1.08x | | 32 | 0 | 0 | 1.08x | 1.04x | 1.08x | | 32 | 0 | 0 | 1.04x | 1.05x | 1.05x | | 32 | 0 | 0 | 1.04x | 0.96x | 1.05x | | 32 | 0 | 0 | 1.04x | 0.96x | 1.05x | | 32 | 0 | 0 | 1.04x | 0.98x | 1.05x | | 32 | 0 | 4 | 0.91x | 1.03x | 0.93x | | 32 | 4 | 5 | 0.94x | 1.00x | 1.00x | | 64 | 0 | 0 | 1.12x | 1.03x | 1.16x | | 64 | 0 | 0 | 1.11x | 1.03x | 1.16x | | 64 | 0 | 0 | 1.11x | 1.04x | 1.15x | | 64 | 0 | 0 | 1.11x | 1.03x | 1.15x | | 64 | 0 | 0 | 1.11x | 1.03x | 1.02x | | 64 | 0 | 0 | 1.11x | 1.03x | 1.02x | | 64 | 0 | 5 | 1.05x | 1.19x | 1.15x | | 64 | 5 | 6 | 1.04x | 1.14x | 1.12x | | 128 | 0 | 0 | 1.11x | 0.99x | 1.18x | | 128 | 0 | 0 | 1.11x | 0.99x | 1.18x | | 128 | 0 | 0 | 1.09x | 0.99x | 1.18x | | 128 | 0 | 0 | 1.09x | 0.99x | 1.18x | | 128 | 0 | 0 | 1.09x | 0.99x | 1.18x | | 128 | 0 | 0 | 1.09x | 0.99x | 1.18x | | 128 | 0 | 6 | 1.15x | 1.04x | 1.26x | | 128 | 6 | 7 | 1.22x | 1.05x | 1.27x | | 256 | 0 | 0 | 1.13x | 1.00x | 1.19x | | 256 | 0 | 0 | 1.13x | 1.00x | 1.19x | | 256 | 0 | 0 | 1.12x | 0.99x | 1.19x | | 256 | 0 | 0 | 1.12x | 1.00x | 1.19x | | 256 | 0 | 0 | 1.12x | 1.00x | 1.19x | | 256 | 0 | 0 | 1.12x | 0.99x | 1.19x | | 256 | 0 | 7 | 1.53x | 1.08x | 1.33x | | 256 | 7 | 8 | 1.51x | 1.07x | 1.33x | | 512 | 0 | 0 | 1.16x | 1.00x | 1.19x | | 512 | 0 | 0 | 1.15x | 1.00x | 1.19x | | 512 | 0 | 0 | 1.15x | 1.00x | 1.19x | | 512 | 0 | 0 | 1.15x | 1.00x | 1.19x | | 512 | 0 | 0 | 1.18x | 1.00x | 1.19x | | 512 | 0 | 0 | 1.16x | 1.00x | 1.19x | | 512 | 0 | 8 | 1.15x | 1.00x | 1.19x | | 512 | 8 | 9 | 1.35x | 1.10x | 1.37x | | 1024 | 0 | 0 | 1.19x | 1.00x | 1.19x | | 1024 | 0 | 0 | 1.20x | 1.00x | 1.19x | | 1024 | 0 | 0 | 1.19x | 1.00x | 1.19x | | 1024 | 0 | 0 | 1.16x | 1.00x | 1.19x | | 1024 | 0 | 0 | 1.16x | 1.00x | 1.19x | | 1024 | 0 | 0 | 1.17x | 1.00x | 1.19x | | 1024 | 0 | 9 | 1.39x | 1.12x | 1.40x | | 1024 | 9 | 10 | 1.34x | 1.11x | 1.35x | | 16 | 1 | 2 | 0.96x | 0.96x | 1.08x | | 16 | 2 | 1 | 0.86x | 0.95x | 0.97x | | 16 | 1 | 2 | 0.97x | 0.96x | 1.08x | | 16 | 2 | 1 | 0.86x | 0.95x | 0.97x | | 16 | 1 | 2 | 0.95x | 0.95x | 1.19x | | 16 | 2 | 1 | 0.86x | 0.95x | 1.07x | | 32 | 2 | 4 | 0.91x | 0.98x | 1.00x | | 32 | 4 | 2 | 0.92x | 0.93x | 0.97x | | 32 | 2 | 4 | 0.89x | 0.96x | 1.00x | | 32 | 4 | 2 | 0.92x | 0.92x | 0.97x | | 32 | 2 | 4 | 0.91x | 0.96x | 1.00x | | 32 | 4 | 2 | 0.92x | 1.00x | 0.97x | | 64 | 3 | 6 | 1.00x | 1.11x | 1.10x | | 64 | 6 | 3 | 1.03x | 1.15x | 1.09x | | 64 | 3 | 6 | 1.01x | 1.11x | 1.11x | | 64 | 6 | 3 | 1.03x | 1.15x | 1.09x | | 64 | 3 | 6 | 1.00x | 1.11x | 1.10x | | 64 | 6 | 3 | 1.02x | 1.16x | 1.09x | | 128 | 4 | 8 | 1.17x | 1.03x | 1.23x | | 128 | 8 | 4 | 1.17x | 1.06x | 1.26x | | 128 | 4 | 8 | 1.20x | 1.05x | 1.24x | | 128 | 8 | 4 | 1.16x | 1.04x | 1.26x | | 128 | 4 | 8 | 1.16x | 1.03x | 1.24x | | 128 | 8 | 4 | 1.15x | 1.04x | 1.26x | | 256 | 5 | 10 | 1.52x | 1.07x | 1.31x | | 256 | 10 | 5 | 1.48x | 1.07x | 1.31x | | 256 | 5 | 10 | 1.52x | 1.07x | 1.33x | | 256 | 10 | 5 | 1.47x | 1.07x | 1.30x | | 256 | 5 | 10 | 1.52x | 1.07x | 1.33x | | 256 | 10 | 5 | 1.48x | 1.08x | 1.30x | | 512 | 6 | 12 | 1.26x | 1.10x | 1.37x | | 512 | 12 | 6 | 1.33x | 1.11x | 1.35x | | 512 | 6 | 12 | 1.27x | 1.10x | 1.37x | | 512 | 12 | 6 | 1.33x | 1.11x | 1.35x | | 512 | 6 | 12 | 1.27x | 1.10x | 1.37x | | 512 | 12 | 6 | 1.33x | 1.11x | 1.35x | | 1024 | 7 | 14 | 1.39x | 1.12x | 1.45x | | 1024 | 14 | 7 | 1.32x | 1.13x | 1.41x | | 1024 | 7 | 14 | 1.39x | 1.12x | 1.45x | | 1024 | 14 | 7 | 1.32x | 1.13x | 1.42x | | 1024 | 7 | 14 | 1.39x | 1.12x | 1.45x | | 1024 | 14 | 7 | 1.33x | 1.13x | 1.41x | This patch passes the tests with no regressions. 8< --- 8< --- 8< Add support for MTE to strcmp. Regression tested with xcheck and benchmarked with glibc's benchtests on the Cortex-A53, Cortex-A72, and Neoverse N1. The existing implementation assumes that any access to the pages in which the string resides is safe. This assumption is not true when MTE is enabled. This patch updates the algorithm to ensure that accesses remain within the bounds of an MTE tag (16-byte chunks) and improves overall performance. Co-authored-by: Branislav Rankov Co-authored-by: Wilco Dijkstra From 2d8bba6aa91151b31472fc1444d7563fac35dfb5 Mon Sep 17 00:00:00 2001 From: Alex Butler Date: Fri, 12 Jun 2020 13:51:43 +0100 Subject: [PATCH] aarch64: add MTE compatible strcmp --- sysdeps/aarch64/strcmp.S | 234 +++++++++++++++++++++++++---------------------- 1 file changed, 125 insertions(+), 109 deletions(-) diff --git a/sysdeps/aarch64/strcmp.S b/sysdeps/aarch64/strcmp.S index d044c29..77d7218 100644 --- a/sysdeps/aarch64/strcmp.S +++ b/sysdeps/aarch64/strcmp.S @@ -18,14 +18,14 @@ /* Assumptions: * - * ARMv8-a, AArch64 + * ARMv8-a, AArch64. + * MTE compatible. */ #include #define REP8_01 0x0101010101010101 #define REP8_7f 0x7f7f7f7f7f7f7f7f -#define REP8_80 0x8080808080808080 /* Parameters and result. */ #define src1 x0 @@ -39,146 +39,162 @@ #define data2w w3 #define has_nul x4 #define diff x5 +#define off1 x5 #define syndrome x6 -#define tmp1 x7 -#define tmp2 x8 -#define tmp3 x9 -#define zeroones x10 -#define pos x11 +#define tmp x6 +#define data3 x7 +#define zeroones x8 +#define shift x9 +#define off2 x10 + +/* On big-endian early bytes are at MSB and on little-endian LSB. + LS_FW means shifting towards early bytes. */ +#ifdef __AARCH64EB__ +# define LS_FW lsl +#else +# define LS_FW lsr +#endif - /* Start of performance-critical section -- one 64B cache line. */ -ENTRY_ALIGN(strcmp, 6) +/* NUL detection works on the principle that (X - 1) & (~X) & 0x80 + (=> (X - 1) & ~(X | 0x7f)) is non-zero iff a byte is zero, and + can be done in parallel across the entire word. + Since carry propagation makes 0x1 bytes before a NUL byte appear + NUL too in big-endian, byte-reverse the data before the NUL check. */ +ENTRY(strcmp) DELOUSE (0) DELOUSE (1) - eor tmp1, src1, src2 - mov zeroones, #REP8_01 - tst tmp1, #7 + sub off2, src2, src1 + mov zeroones, REP8_01 + and tmp, src1, 7 + tst off2, 7 b.ne L(misaligned8) - ands tmp1, src1, #7 - b.ne L(mutual_align) - /* NUL detection works on the principle that (X - 1) & (~X) & 0x80 - (=> (X - 1) & ~(X | 0x7f)) is non-zero iff a byte is zero, and - can be done in parallel across the entire word. */ + cbnz tmp, L(mutual_align) + + .p2align 4 + L(loop_aligned): - ldr data1, [src1], #8 - ldr data2, [src2], #8 + ldr data2, [src1, off2] + ldr data1, [src1], 8 L(start_realigned): - sub tmp1, data1, zeroones - orr tmp2, data1, #REP8_7f - eor diff, data1, data2 /* Non-zero if differences found. */ - bic has_nul, tmp1, tmp2 /* Non-zero if NUL terminator. */ +#ifdef __AARCH64EB__ + rev tmp, data1 + sub has_nul, tmp, zeroones + orr tmp, tmp, REP8_7f +#else + sub has_nul, data1, zeroones + orr tmp, data1, REP8_7f +#endif + bics has_nul, has_nul, tmp /* Non-zero if NUL terminator. */ + ccmp data1, data2, 0, eq + b.eq L(loop_aligned) +#ifdef __AARCH64EB__ + rev has_nul, has_nul +#endif + eor diff, data1, data2 orr syndrome, diff, has_nul - cbz syndrome, L(loop_aligned) - /* End of performance-critical section -- one 64B cache line. */ - L(end): -#ifndef __AARCH64EB__ +#ifndef __AARCH64EB__ rev syndrome, syndrome rev data1, data1 - /* The MS-non-zero bit of the syndrome marks either the first bit - that is different, or the top bit of the first zero byte. - Shifting left now will bring the critical information into the - top bits. */ - clz pos, syndrome rev data2, data2 - lsl data1, data1, pos - lsl data2, data2, pos - /* But we need to zero-extend (char is unsigned) the value and then - perform a signed 32-bit subtraction. */ - lsr data1, data1, #56 - sub result, data1, data2, lsr #56 - RET -#else - /* For big-endian we cannot use the trick with the syndrome value - as carry-propagation can corrupt the upper bits if the trailing - bytes in the string contain 0x01. */ - /* However, if there is no NUL byte in the dword, we can generate - the result directly. We can't just subtract the bytes as the - MSB might be significant. */ - cbnz has_nul, 1f - cmp data1, data2 - cset result, ne - cneg result, result, lo - RET -1: - /* Re-compute the NUL-byte detection, using a byte-reversed value. */ - rev tmp3, data1 - sub tmp1, tmp3, zeroones - orr tmp2, tmp3, #REP8_7f - bic has_nul, tmp1, tmp2 - rev has_nul, has_nul - orr syndrome, diff, has_nul - clz pos, syndrome - /* The MS-non-zero bit of the syndrome marks either the first bit - that is different, or the top bit of the first zero byte. +#endif + clz shift, syndrome + /* The most-significant-non-zero bit of the syndrome marks either the + first bit that is different, or the top bit of the first zero byte. Shifting left now will bring the critical information into the top bits. */ - lsl data1, data1, pos - lsl data2, data2, pos + lsl data1, data1, shift + lsl data2, data2, shift /* But we need to zero-extend (char is unsigned) the value and then perform a signed 32-bit subtraction. */ - lsr data1, data1, #56 - sub result, data1, data2, lsr #56 - RET -#endif + lsr data1, data1, 56 + sub result, data1, data2, lsr 56 + ret + + .p2align 4 L(mutual_align): /* Sources are mutually aligned, but are not currently at an alignment boundary. Round down the addresses and then mask off - the bytes that preceed the start point. */ - bic src1, src1, #7 - bic src2, src2, #7 - lsl tmp1, tmp1, #3 /* Bytes beyond alignment -> bits. */ - ldr data1, [src1], #8 - neg tmp1, tmp1 /* Bits to alignment -64. */ - ldr data2, [src2], #8 - mov tmp2, #~0 -#ifdef __AARCH64EB__ - /* Big-endian. Early bytes are at MSB. */ - lsl tmp2, tmp2, tmp1 /* Shift (tmp1 & 63). */ -#else - /* Little-endian. Early bytes are at LSB. */ - lsr tmp2, tmp2, tmp1 /* Shift (tmp1 & 63). */ -#endif - orr data1, data1, tmp2 - orr data2, data2, tmp2 + the bytes that precede the start point. */ + bic src1, src1, 7 + ldr data2, [src1, off2] + ldr data1, [src1], 8 + neg shift, src2, lsl 3 /* Bits to alignment -64. */ + mov tmp, -1 + LS_FW tmp, tmp, shift + orr data1, data1, tmp + orr data2, data2, tmp b L(start_realigned) L(misaligned8): /* Align SRC1 to 8 bytes and then compare 8 bytes at a time, always - checking to make sure that we don't access beyond page boundary in - SRC2. */ - tst src1, #7 - b.eq L(loop_misaligned) + checking to make sure that we don't access beyond the end of SRC2. */ + cbz tmp, L(src1_aligned) L(do_misaligned): - ldrb data1w, [src1], #1 - ldrb data2w, [src2], #1 - cmp data1w, #1 - ccmp data1w, data2w, #0, cs /* NZCV = 0b0000. */ + ldrb data1w, [src1], 1 + ldrb data2w, [src2], 1 + cmp data1w, 0 + ccmp data1w, data2w, 0, ne /* NZCV = 0b0000. */ b.ne L(done) - tst src1, #7 + tst src1, 7 b.ne L(do_misaligned) -L(loop_misaligned): - /* Test if we are within the last dword of the end of a 4K page. If - yes then jump back to the misaligned loop to copy a byte at a time. */ - and tmp1, src2, #0xff8 - eor tmp1, tmp1, #0xff8 - cbz tmp1, L(do_misaligned) - ldr data1, [src1], #8 - ldr data2, [src2], #8 - - sub tmp1, data1, zeroones - orr tmp2, data1, #REP8_7f - eor diff, data1, data2 /* Non-zero if differences found. */ - bic has_nul, tmp1, tmp2 /* Non-zero if NUL terminator. */ +L(src1_aligned): + neg shift, src2, lsl 3 + bic src2, src2, 7 + ldr data3, [src2], 8 +#ifdef __AARCH64EB__ + rev data3, data3 +#endif + lsr tmp, zeroones, shift + orr data3, data3, tmp + sub has_nul, data3, zeroones + orr tmp, data3, REP8_7f + bics has_nul, has_nul, tmp + b.ne L(tail) + + sub off1, src2, src1 + + .p2align 4 + +L(loop_unaligned): + ldr data3, [src1, off1] + ldr data2, [src1, off2] +#ifdef __AARCH64EB__ + rev data3, data3 +#endif + sub has_nul, data3, zeroones + orr tmp, data3, REP8_7f + ldr data1, [src1], 8 + bics has_nul, has_nul, tmp + ccmp data1, data2, 0, eq + b.eq L(loop_unaligned) + + lsl tmp, has_nul, shift +#ifdef __AARCH64EB__ + rev tmp, tmp +#endif + eor diff, data1, data2 + orr syndrome, diff, tmp + cbnz syndrome, L(end) +L(tail): + ldr data1, [src1] + neg shift, shift + lsr data2, data3, shift + lsr has_nul, has_nul, shift +#ifdef __AARCH64EB__ + rev data2, data2 + rev has_nul, has_nul +#endif + eor diff, data1, data2 orr syndrome, diff, has_nul - cbz syndrome, L(loop_misaligned) b L(end) L(done): sub result, data1, data2 - RET + ret + END(strcmp) libc_hidden_builtin_def (strcmp) -- 2.7.4