Message ID | patch-15782-tamar@arm.com |
---|---|
State | Committed |
Commit | e6a8ae900b4141bbce1451da8f173d441662782d |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> 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 0B8C4386CE41 for <patchwork@sourceware.org>; Wed, 8 Jun 2022 14:51:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B8C4386CE41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1654699863; bh=mVU9Y8FVEWLqdSl1X88sYXWEI227BPrEZCIy+VzMPlU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Cj1106ExTlcQQTNApLFFqPAfgBlClFkM6JrCu+QSK6Kw+SqSaEeSwtsE88vXRKkNS Rexn0iTI9mo7+IPfl4qx3YyjlTdsu7tnbyo3bwAH647QHdBox3QQd8xp/makJgl7WZ MOjIqewdPfr2rXzBoR6n8DkEH1+1QfqcEYv9HzbE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60051.outbound.protection.outlook.com [40.107.6.51]) by sourceware.org (Postfix) with ESMTPS id B4007382B275 for <gcc-patches@gcc.gnu.org>; Wed, 8 Jun 2022 14:49:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B4007382B275 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=NXyVa7dT2e5aMubGQkKDFQ8ShkikJ47JNy05h6aM3NZyFyblGjWLv6fGAIzNahOTX2ed9+yhhVXuv/M2RaZctbziD+ngBsVk4LREAZ2u1fj7Hcmc6SHatxc7/rmq7KLcAzgrMLDYdAKtVTpW+zcmBzl8R37HF0qZL5frHwc4ImhLNMtIyhthVqRLNsK4WRfoZjpISh24U7SUxqYsJbuc5hgHsZET0ZXzSNx6LVD2dhKyBkhLDvpFZfxi9W5Qkk4ySEGo1zQoKlwmsMhkMdD4aMW1XhNi/MazrmJGbluWsd5Q235iJZk8/2j26e1yECm2zbTILPB6ehN4PEUyG9sApQ== ARC-Message-Signature: i=2; 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=mVU9Y8FVEWLqdSl1X88sYXWEI227BPrEZCIy+VzMPlU=; b=GHPZ1muLMR49EbFubS8zZKSewVdMAZAiZiBtWZGmjCuVuNq5Tsert247b+ygPHBRfREoHmpPf3bb0Y6EKaYWT2DqAq8p4F3gdErql8DmLluLDLrywbCk0nx9PfB8CpUJCS/1NPHJD/b9mX3uUkXROk9AIcmnz5MlYjgxpPU3VwyzjdzJLGyTBo2P2EiCv7RbYvR/b5IGsQQWija1DhJcnrk/HlPwWnycO0C652mS+MoCatKaLXYbBpXL9ElZp6cyeflKqlQ3MvLZ72JvjJMtjFixLGUjRj4z5f/7ECFldz7zMpdCi9oNwcTdhEfkXYugWnxhhK4aYEmosKWGnJz1+g== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AS9PR0301CA0045.eurprd03.prod.outlook.com (2603:10a6:20b:469::13) by HE1PR0802MB2425.eurprd08.prod.outlook.com (2603:10a6:3:dd::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Wed, 8 Jun 2022 14:49:40 +0000 Received: from VE1EUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:469:cafe::3f) by AS9PR0301CA0045.outlook.office365.com (2603:10a6:20b:469::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.12 via Frontend Transport; Wed, 8 Jun 2022 14:49:39 +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 VE1EUR03FT033.mail.protection.outlook.com (10.152.18.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.12 via Frontend Transport; Wed, 8 Jun 2022 14:49:39 +0000 Received: ("Tessian outbound 1766a3bff204:v120"); Wed, 08 Jun 2022 14:49:38 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0e448cc82e52c410 X-CR-MTA-TID: 64aa7808 Received: from 5e16066b06af.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CC34333F-2A95-4811-A500-CEE5634477E6.1; Wed, 08 Jun 2022 14:49:27 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5e16066b06af.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jun 2022 14:49:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fs7X2UugrhYt3br/UnXCkPAdOf5JhxVsSmcpHjn+yLNkIm1Idfn6JhZ5hO+txAB6VKSgmJq5zXMlVXRPQfMuoA7USiZr5B0iLtv4BeeADR5jrqnDspW6Zdf3Ag7NHE89pON1FvzailVLsWysi9VkYlxvl043Y/TsG01IoVPTaV1WPNkICTV+ZrVWtO9ZqS0n2I5c7qfBOzjrf2LFofGXr75QFQoTzDIwHmTVk42WcipyNYuTvhz9kwhnA8gvhrAX7Er+TtSjFcP+dYcII+muh6COarP7iYmUoTmE6nV2zRN6OOoMrwxG+mZALwUyRafDBwpKP7xQFRvkrcXapISAng== 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=mVU9Y8FVEWLqdSl1X88sYXWEI227BPrEZCIy+VzMPlU=; b=gjQQ37OkTjBC1yWW8EzXFmEpCbcV8N5rFgCpfddTQ8/SFe0G59YQVKrmZv/loATIgmtIu4LLA1mbJ/P03qhIRXzJRreMPPIQEdJPgM5RBn5JoQHLy4sSAhGqIGUTh8wOyMxYmS6zWvmlMFh/d3CAturMHCstKS7/5Ude3S+uqn0+HcT6bVwJv2cfgnx540fdD1Wyeiij5qbk5pCRnmlZ2aI5b0mUSxzJOFv68qENU6nzeSWa0bnaNLZdS4/qAzz+bZ5urzIwfXHXMqWjt3iO9IDd12azqhRoO8AMXiypvKYYRgrZtxu1TFJ1GWZl5IPH8CgTdBUX1fXAaQvnoY4QpA== 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 Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) by AM8PR08MB5585.eurprd08.prod.outlook.com (2603:10a6:20b:1c5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Wed, 8 Jun 2022 14:49:26 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::54e5:594b:e5fd:a9b4]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::54e5:594b:e5fd:a9b4%7]) with mapi id 15.20.5314.019; Wed, 8 Jun 2022 14:49:26 +0000 Date: Wed, 8 Jun 2022 15:49:23 +0100 To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/2]AArch64 Fix 128-bit sequential consistency atomic operations. Message-ID: <patch-15782-tamar@arm.com> Content-Type: multipart/mixed; boundary="wm/hVt81OvTjM6jl" Content-Disposition: inline X-ClientProxiedBy: LO4P265CA0160.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c7::19) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: df212b90-569d-48aa-6a6a-08da495e1d5b X-MS-TrafficTypeDiagnostic: AM8PR08MB5585:EE_|VE1EUR03FT033:EE_|HE1PR0802MB2425:EE_ X-Microsoft-Antispam-PRVS: <HE1PR0802MB24253364A0E8F02F85F5BAE0FFA49@HE1PR0802MB2425.eurprd08.prod.outlook.com> 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: szu65EN6DyESdyeZqdqPFknuUkADRBeOEF3mdYXyPhB8HQWwzwibx7WLXY3k65HWdFllL29s1D70k1u9RyvS9tEF8MYyWahTMhpTfQ1H+WzKYcAS477bKnTiWqyTEVMdTUR14JWjaCmYUz7Et2VA4+v6u2/aCKhZwS1ubZkCrRS+TfRS385K38d9XAvF+GVWBVlgMl8LEpZTDD0R6p2AIcBywVbNk1RgNXWf+xPRZap0ZXFHr9j2fFuwBwZ33mU4A3hhB4m0ALlH0AmfMUQ/zVxdMos5Akl0C3DBirm7ABQn2PrZYSo9i9f/THMZcKzOhxsq19Mh5awvz0cDHMxWYKmZLhIuxgONR2SNJaUxfP0nEhQdmQZt1BrtIGUJBbS3pLruKcbz3eUiNOBtuU2GjdVnu7YJS2ri74vd6azkcUJ8KVT710TSRF+jHLkm8KizFrn0knvmzKu467aMFKAxMfiuIQglRNL3HBm72vHu5j/wXU82Rl8JTMUuwrTIoTFjJHrEpU/nUmtwpq9abXb88UEImenw1BrIvjHhHIh2RDUXkOBAMEsKMyaLCl0zKuHJLHeEPr84edNReAu04IiRDLgIwMJpNB81twwBMk4BwYMltLje8qcch5bB0EBSUOmASJp0t08iuVPoOjfvbjVaAAxnGhQRpfHIdRzmwwHydLiCQF6m01ZU07hYPutKKpOLIFPUBZphCD0QuGB8r6j2/RA6oa9WgJbh3azWfXZ7c6RWBXPkUEbK0CUfej7cQQtAiextf1IROfRpMMMbFBLnOb0whEOC3eFeF7NeHzi9KnhPj/8GwZoZdmGok+xIeIIjkVz+uSlWJKin2IxDi6c2xg== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB5325.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(235185007)(66946007)(8676002)(6506007)(66476007)(38100700002)(44144004)(33964004)(86362001)(6666004)(4326008)(6486002)(66556008)(5660300002)(186003)(2906002)(44832011)(508600001)(2616005)(83380400001)(6916009)(26005)(316002)(8936002)(4743002)(6512007)(4216001)(2004002)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5585 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: VE1EUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 8df32faa-9ab9-4e22-11f1-08da495e1542 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WCdPNu8RaLVTdCbtWU9cam+EJvPkcdmGC5i5gFHxU8b4sALgK3dP1AuZQtaDonYmqAVsJm3b0sFklZsfujVC8v/T8+c5M/i321bEH0uPL5AqdiYhrePwF+iZ5eSoTWxrb19DVf0w3r7JaIlcoXKvE2HqX2zjwbpCZ7l437uIC5/IFDTiw7bo4FkjhyjXyTHm0CLfXp6sBXBQae+sJjpJKTb6MUK6KCIDmKYyyVNmuUQyvZQ1AbtjlLpkSya0UHIoHXL6jM1DbajZbjQBgvzfqgH1z4HDkPyCSI1KywVUXz3HM+pTuRvaaFQkFUjjV3SjqJlpZp2XGdvoq51aeuaC+HStpfnjo4eLX6DzYFYyPPtHMtSkMGYNgWVQscdrzxp8yL/agqyeDE8cKlAaQ5qWW7T5ise9uT3GzzXzr0ljPfXu9mR2ZHd9MNiO29yG8VBf87wlvl+FzxQhUPy6um11OL0MG6X2/A0mPPTeRW5SD1xsu3YkMT4F98oytC8KD4kcE9yM24zkdQyqGRLlGIvvDKejWZ/GXljqABOHNVTzlPNXvI0CY32K3Pj5snwz70oPk7OAy7uPFI1j/YOYyfL2tDoxIYXieNCUoYAqyUm4Dz89v7RArmJAOOjv75wwprGf1oMzD0wLbWj1rgf+35NnstbZGiWkXvfcBEPxPIEewfggxKzMCJ3CeMlxkt795Tk+QKXQQZYyAFJ2JIwpYn9ef1xiPrZsKIB60VKcabOEcuHNN5R78WMrlE5MNVN1nXCZTSYlRA5aASMA5/ST/qcjtO9fcn6LoZEzjCAYoCe9HyQbHZ/+11uyeZ9AqMJnsFwRSbshK9bJbhQqHvU6hDWDew== 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:(13230001)(4636009)(36840700001)(40470700004)(46966006)(44832011)(36860700001)(5660300002)(36756003)(44144004)(70586007)(81166007)(356005)(40460700003)(2906002)(316002)(4326008)(8676002)(86362001)(8936002)(47076005)(336012)(186003)(2616005)(6916009)(70206006)(82310400005)(83380400001)(6666004)(6486002)(508600001)(26005)(6512007)(6506007)(4743002)(33964004)(235185007)(4216001)(2004002)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2022 14:49:39.3224 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df212b90-569d-48aa-6a6a-08da495e1d5b 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: VE1EUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2425 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Tamar Christina via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Tamar Christina <tamar.christina@arm.com> Cc: Richard.Earnshaw@arm.com, nd@arm.com, richard.sandiford@arm.com, Marcus.Shawcroft@arm.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
[1/2] AArch64 Fix 128-bit sequential consistency atomic operations.
|
|
Commit Message
Tamar Christina
June 8, 2022, 2:49 p.m. UTC
Hi All, The AArch64 implementation of 128-bit atomics is broken. For 128-bit atomics we rely on pthread barriers to correct guard the address in the pointer to get correct memory ordering. However for 128-bit atomics the address under the lock is different from the original pointer. This means that one of the values under the atomic operation is not protected properly and so we fail during when the user has requested sequential consistency as there's no barrier to enforce this requirement. As such users have resorted to adding an #ifdef GCC <emit barrier> #endif around the use of these atomics. This corrects the issue by issuing a barrier only when __ATOMIC_SEQ_CST was requested. To remedy this performance hit I think we should revisit using a similar approach to out-line-atomics for the 128-bit atomics. Note that I believe I need the empty file due to the include_next chain but I am not entirely sure. I have hand verified that the barriers are inserted for atomic seq cst. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for master? and for backporting to GCC 12, 11 and 10? Thanks, Tamar libatomic/ChangeLog: PR target/102218 * config/aarch64/aarch64-config.h: New file. * config/aarch64/host-config.h: New file. --- inline copy of patch -- diff --git a/libatomic/config/aarch64/aarch64-config.h b/libatomic/config/aarch64/aarch64-config.h new file mode 100644 index 0000000000000000000000000000000000000000..d3474fa8ff80cb0c3ddbf8c48acd931d2339d33d -- diff --git a/libatomic/config/aarch64/aarch64-config.h b/libatomic/config/aarch64/aarch64-config.h new file mode 100644 index 0000000000000000000000000000000000000000..d3474fa8ff80cb0c3ddbf8c48acd931d2339d33d --- /dev/null +++ b/libatomic/config/aarch64/aarch64-config.h @@ -0,0 +1,23 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + + This file is part of the GNU Atomic Library (libatomic). + + Libatomic is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + <http://www.gnu.org/licenses/>. */ + diff --git a/libatomic/config/aarch64/host-config.h b/libatomic/config/aarch64/host-config.h new file mode 100644 index 0000000000000000000000000000000000000000..f445a47d25ef5cc51cd2167069500245d07bf1bc --- /dev/null +++ b/libatomic/config/aarch64/host-config.h @@ -0,0 +1,46 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + + This file is part of the GNU Atomic Library (libatomic). + + Libatomic is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + <http://www.gnu.org/licenses/>. */ + +/* Avoiding the DMB (or kernel helper) can be a good thing. */ +#define WANT_SPECIALCASE_RELAXED + +/* Glibc, at least, uses acq_rel in its pthread mutex + implementation. If the user is asking for seq_cst, + this is insufficient. */ + +static inline void __attribute__((always_inline, artificial)) +pre_seq_barrier(int model) +{ + if (model == __ATOMIC_SEQ_CST) + __atomic_thread_fence (__ATOMIC_SEQ_CST); +} + +static inline void __attribute__((always_inline, artificial)) +post_seq_barrier(int model) +{ + pre_seq_barrier(model); +} + +#define pre_post_seq_barrier 1 + +#include_next <host-config.h>
Comments
ping > -----Original Message----- > From: Tamar Christina <tamar.christina@arm.com> > Sent: Wednesday, June 8, 2022 3:49 PM > To: gcc-patches@gcc.gnu.org > Cc: nd <nd@arm.com>; Richard Earnshaw <Richard.Earnshaw@arm.com>; > Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Kyrylo Tkachov > <Kyrylo.Tkachov@arm.com>; Richard Sandiford > <Richard.Sandiford@arm.com> > Subject: [PATCH 1/2]AArch64 Fix 128-bit sequential consistency atomic > operations. > > Hi All, > > The AArch64 implementation of 128-bit atomics is broken. > > For 128-bit atomics we rely on pthread barriers to correct guard the address > in the pointer to get correct memory ordering. However for 128-bit atomics > the address under the lock is different from the original pointer. > > This means that one of the values under the atomic operation is not > protected properly and so we fail during when the user has requested > sequential consistency as there's no barrier to enforce this requirement. > > As such users have resorted to adding an > > #ifdef GCC > <emit barrier> > #endif > > around the use of these atomics. > > This corrects the issue by issuing a barrier only when __ATOMIC_SEQ_CST > was requested. To remedy this performance hit I think we should revisit > using a similar approach to out-line-atomics for the 128-bit atomics. > > Note that I believe I need the empty file due to the include_next chain but I > am not entirely sure. I have hand verified that the barriers are inserted for > atomic seq cst. > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > Ok for master? and for backporting to GCC 12, 11 and 10? > > Thanks, > Tamar > > libatomic/ChangeLog: > > PR target/102218 > * config/aarch64/aarch64-config.h: New file. > * config/aarch64/host-config.h: New file. > > --- inline copy of patch -- > diff --git a/libatomic/config/aarch64/aarch64-config.h > b/libatomic/config/aarch64/aarch64-config.h > new file mode 100644 > index > 0000000000000000000000000000000000000000..d3474fa8ff80cb0c3ddbf8c48ac > d931d2339d33d > --- /dev/null > +++ b/libatomic/config/aarch64/aarch64-config.h > @@ -0,0 +1,23 @@ > +/* Copyright (C) 2022 Free Software Foundation, Inc. > + > + This file is part of the GNU Atomic Library (libatomic). > + > + Libatomic is free software; you can redistribute it and/or modify it > + under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + Libatomic is distributed in the hope that it will be useful, but WITHOUT > ANY > + WARRANTY; without even the implied warranty of MERCHANTABILITY or > FITNESS > + FOR A PARTICULAR PURPOSE. See the GNU General Public License for > + more details. > + > + Under Section 7 of GPL version 3, you are granted additional > + permissions described in the GCC Runtime Library Exception, version > + 3.1, as published by the Free Software Foundation. > + > + You should have received a copy of the GNU General Public License and > + a copy of the GCC Runtime Library Exception along with this program; > + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > + <http://www.gnu.org/licenses/>. */ > + > diff --git a/libatomic/config/aarch64/host-config.h > b/libatomic/config/aarch64/host-config.h > new file mode 100644 > index > 0000000000000000000000000000000000000000..f445a47d25ef5cc51cd2167069 > 500245d07bf1bc > --- /dev/null > +++ b/libatomic/config/aarch64/host-config.h > @@ -0,0 +1,46 @@ > +/* Copyright (C) 2022 Free Software Foundation, Inc. > + > + This file is part of the GNU Atomic Library (libatomic). > + > + Libatomic is free software; you can redistribute it and/or modify it > + under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + Libatomic is distributed in the hope that it will be useful, but WITHOUT > ANY > + WARRANTY; without even the implied warranty of MERCHANTABILITY or > FITNESS > + FOR A PARTICULAR PURPOSE. See the GNU General Public License for > + more details. > + > + Under Section 7 of GPL version 3, you are granted additional > + permissions described in the GCC Runtime Library Exception, version > + 3.1, as published by the Free Software Foundation. > + > + You should have received a copy of the GNU General Public License and > + a copy of the GCC Runtime Library Exception along with this program; > + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > + <http://www.gnu.org/licenses/>. */ > + > +/* Avoiding the DMB (or kernel helper) can be a good thing. */ #define > +WANT_SPECIALCASE_RELAXED > + > +/* Glibc, at least, uses acq_rel in its pthread mutex > + implementation. If the user is asking for seq_cst, > + this is insufficient. */ > + > +static inline void __attribute__((always_inline, artificial)) > +pre_seq_barrier(int model) { > + if (model == __ATOMIC_SEQ_CST) > + __atomic_thread_fence (__ATOMIC_SEQ_CST); } > + > +static inline void __attribute__((always_inline, artificial)) > +post_seq_barrier(int model) { > + pre_seq_barrier(model); > +} > + > +#define pre_post_seq_barrier 1 > + > +#include_next <host-config.h> > > > > > --
Hi Tamar, Let me be the latest to offer my apologies for the slow review. > -----Original Message----- > From: Tamar Christina <Tamar.Christina@arm.com> > Sent: Wednesday, June 8, 2022 3:49 PM > To: gcc-patches@gcc.gnu.org > Cc: nd <nd@arm.com>; Richard Earnshaw <Richard.Earnshaw@arm.com>; > Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Kyrylo Tkachov > <Kyrylo.Tkachov@arm.com>; Richard Sandiford > <Richard.Sandiford@arm.com> > Subject: [PATCH 1/2]AArch64 Fix 128-bit sequential consistency atomic > operations. > > Hi All, > > The AArch64 implementation of 128-bit atomics is broken. > > For 128-bit atomics we rely on pthread barriers to correct guard the address > in the pointer to get correct memory ordering. However for 128-bit atomics > the > address under the lock is different from the original pointer. > > This means that one of the values under the atomic operation is not > protected > properly and so we fail during when the user has requested sequential > consistency as there's no barrier to enforce this requirement. > > As such users have resorted to adding an > > #ifdef GCC > <emit barrier> > #endif > > around the use of these atomics. > > This corrects the issue by issuing a barrier only when __ATOMIC_SEQ_CST > was > requested. To remedy this performance hit I think we should revisit using a > similar approach to out-line-atomics for the 128-bit atomics. > > Note that I believe I need the empty file due to the include_next chain but > I am not entirely sure. I have hand verified that the barriers are inserted > for atomic seq cst. > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > Ok for master? and for backporting to GCC 12, 11 and 10? I'll admit I'm not too familiar with the mechanics of libatomic but... > > Thanks, > Tamar > > libatomic/ChangeLog: > > PR target/102218 > * config/aarch64/aarch64-config.h: New file. > * config/aarch64/host-config.h: New file. > > --- inline copy of patch -- > diff --git a/libatomic/config/aarch64/aarch64-config.h > b/libatomic/config/aarch64/aarch64-config.h > new file mode 100644 > index > 0000000000000000000000000000000000000000..d3474fa8ff80cb0c3ddbf8c4 > 8acd931d2339d33d > --- /dev/null > +++ b/libatomic/config/aarch64/aarch64-config.h > @@ -0,0 +1,23 @@ > +/* Copyright (C) 2022 Free Software Foundation, Inc. > + > + This file is part of the GNU Atomic Library (libatomic). > + > + Libatomic is free software; you can redistribute it and/or modify it > + under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + Libatomic is distributed in the hope that it will be useful, but WITHOUT > ANY > + WARRANTY; without even the implied warranty of MERCHANTABILITY or > FITNESS > + FOR A PARTICULAR PURPOSE. See the GNU General Public License for > + more details. > + > + Under Section 7 of GPL version 3, you are granted additional > + permissions described in the GCC Runtime Library Exception, version > + 3.1, as published by the Free Software Foundation. > + > + You should have received a copy of the GNU General Public License and > + a copy of the GCC Runtime Library Exception along with this program; > + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > + <http://www.gnu.org/licenses/>. */ > + > diff --git a/libatomic/config/aarch64/host-config.h > b/libatomic/config/aarch64/host-config.h > new file mode 100644 > index > 0000000000000000000000000000000000000000..f445a47d25ef5cc51cd21670 > 69500245d07bf1bc > --- /dev/null > +++ b/libatomic/config/aarch64/host-config.h > @@ -0,0 +1,46 @@ > +/* Copyright (C) 2022 Free Software Foundation, Inc. > + > + This file is part of the GNU Atomic Library (libatomic). > + > + Libatomic is free software; you can redistribute it and/or modify it > + under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + Libatomic is distributed in the hope that it will be useful, but WITHOUT > ANY > + WARRANTY; without even the implied warranty of MERCHANTABILITY or > FITNESS > + FOR A PARTICULAR PURPOSE. See the GNU General Public License for > + more details. > + > + Under Section 7 of GPL version 3, you are granted additional > + permissions described in the GCC Runtime Library Exception, version > + 3.1, as published by the Free Software Foundation. > + > + You should have received a copy of the GNU General Public License and > + a copy of the GCC Runtime Library Exception along with this program; > + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > + <http://www.gnu.org/licenses/>. */ > + > +/* Avoiding the DMB (or kernel helper) can be a good thing. */ > +#define WANT_SPECIALCASE_RELAXED > + > +/* Glibc, at least, uses acq_rel in its pthread mutex > + implementation. If the user is asking for seq_cst, > + this is insufficient. */ > + > +static inline void __attribute__((always_inline, artificial)) > +pre_seq_barrier(int model) > +{ > + if (model == __ATOMIC_SEQ_CST) > + __atomic_thread_fence (__ATOMIC_SEQ_CST); > +} > + > +static inline void __attribute__((always_inline, artificial)) > +post_seq_barrier(int model) > +{ > + pre_seq_barrier(model); > +} > + > +#define pre_post_seq_barrier 1 > + > +#include_next <host-config.h> ... This does looks sensible and similar to what's done on powerpc, which is similar to the aarch64 target in this regard. However, there is already a host-config.h in config/linux/aarch64/host-config.h . Does this file end up including the one in config/linux? If so, does this mean that this works correctly (i.e. was tested) for aarch64-none-elf as well as Linux? Thanks, Kyrill > > > > > --
> -----Original Message----- > From: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com> > Sent: Tuesday, July 12, 2022 2:46 PM > To: Tamar Christina <Tamar.Christina@arm.com>; gcc-patches@gcc.gnu.org > Cc: nd <nd@arm.com>; Richard Earnshaw <Richard.Earnshaw@arm.com>; > Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Richard Sandiford > <Richard.Sandiford@arm.com> > Subject: RE: [PATCH 1/2]AArch64 Fix 128-bit sequential consistency atomic > operations. > > Hi Tamar, > > Let me be the latest to offer my apologies for the slow review. > > > -----Original Message----- > > From: Tamar Christina <Tamar.Christina@arm.com> > > Sent: Wednesday, June 8, 2022 3:49 PM > > To: gcc-patches@gcc.gnu.org > > Cc: nd <nd@arm.com>; Richard Earnshaw <Richard.Earnshaw@arm.com>; > > Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Kyrylo Tkachov > > <Kyrylo.Tkachov@arm.com>; Richard Sandiford > > <Richard.Sandiford@arm.com> > > Subject: [PATCH 1/2]AArch64 Fix 128-bit sequential consistency atomic > > operations. > > > > Hi All, > > > > The AArch64 implementation of 128-bit atomics is broken. > > > > For 128-bit atomics we rely on pthread barriers to correct guard the > > address in the pointer to get correct memory ordering. However for > > 128-bit atomics the address under the lock is different from the > > original pointer. > > > > This means that one of the values under the atomic operation is not > > protected properly and so we fail during when the user has requested > > sequential consistency as there's no barrier to enforce this > > requirement. > > > > As such users have resorted to adding an > > > > #ifdef GCC > > <emit barrier> > > #endif > > > > around the use of these atomics. > > > > This corrects the issue by issuing a barrier only when > > __ATOMIC_SEQ_CST was requested. To remedy this performance hit I > > think we should revisit using a similar approach to out-line-atomics > > for the 128-bit atomics. > > > > Note that I believe I need the empty file due to the include_next > > chain but I am not entirely sure. I have hand verified that the > > barriers are inserted for atomic seq cst. > > > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > > > Ok for master? and for backporting to GCC 12, 11 and 10? > > I'll admit I'm not too familiar with the mechanics of libatomic but... > > > > > Thanks, > > Tamar > > > > libatomic/ChangeLog: > > > > PR target/102218 > > * config/aarch64/aarch64-config.h: New file. > > * config/aarch64/host-config.h: New file. > > > > --- inline copy of patch -- > > diff --git a/libatomic/config/aarch64/aarch64-config.h > > b/libatomic/config/aarch64/aarch64-config.h > > new file mode 100644 > > index > > 0000000000000000000000000000000000000000..d3474fa8ff80cb0c3ddbf8c4 > > 8acd931d2339d33d > > --- /dev/null > > +++ b/libatomic/config/aarch64/aarch64-config.h > > @@ -0,0 +1,23 @@ > > +/* Copyright (C) 2022 Free Software Foundation, Inc. > > + > > + This file is part of the GNU Atomic Library (libatomic). > > + > > + Libatomic is free software; you can redistribute it and/or modify it > > + under the terms of the GNU General Public License as published by > > + the Free Software Foundation; either version 3 of the License, or > > + (at your option) any later version. > > + > > + Libatomic is distributed in the hope that it will be useful, but > > + WITHOUT > > ANY > > + WARRANTY; without even the implied warranty of MERCHANTABILITY or > > FITNESS > > + FOR A PARTICULAR PURPOSE. See the GNU General Public License for > > + more details. > > + > > + Under Section 7 of GPL version 3, you are granted additional > > + permissions described in the GCC Runtime Library Exception, version > > + 3.1, as published by the Free Software Foundation. > > + > > + You should have received a copy of the GNU General Public License and > > + a copy of the GCC Runtime Library Exception along with this program; > > + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > > + <http://www.gnu.org/licenses/>. */ > > + > > diff --git a/libatomic/config/aarch64/host-config.h > > b/libatomic/config/aarch64/host-config.h > > new file mode 100644 > > index > > 0000000000000000000000000000000000000000..f445a47d25ef5cc51cd21670 > > 69500245d07bf1bc > > --- /dev/null > > +++ b/libatomic/config/aarch64/host-config.h > > @@ -0,0 +1,46 @@ > > +/* Copyright (C) 2022 Free Software Foundation, Inc. > > + > > + This file is part of the GNU Atomic Library (libatomic). > > + > > + Libatomic is free software; you can redistribute it and/or modify it > > + under the terms of the GNU General Public License as published by > > + the Free Software Foundation; either version 3 of the License, or > > + (at your option) any later version. > > + > > + Libatomic is distributed in the hope that it will be useful, but > > + WITHOUT > > ANY > > + WARRANTY; without even the implied warranty of MERCHANTABILITY or > > FITNESS > > + FOR A PARTICULAR PURPOSE. See the GNU General Public License for > > + more details. > > + > > + Under Section 7 of GPL version 3, you are granted additional > > + permissions described in the GCC Runtime Library Exception, version > > + 3.1, as published by the Free Software Foundation. > > + > > + You should have received a copy of the GNU General Public License and > > + a copy of the GCC Runtime Library Exception along with this program; > > + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > > + <http://www.gnu.org/licenses/>. */ > > + > > +/* Avoiding the DMB (or kernel helper) can be a good thing. */ > > +#define WANT_SPECIALCASE_RELAXED > > + > > +/* Glibc, at least, uses acq_rel in its pthread mutex > > + implementation. If the user is asking for seq_cst, > > + this is insufficient. */ > > + > > +static inline void __attribute__((always_inline, artificial)) > > +pre_seq_barrier(int model) { > > + if (model == __ATOMIC_SEQ_CST) > > + __atomic_thread_fence (__ATOMIC_SEQ_CST); } > > + > > +static inline void __attribute__((always_inline, artificial)) > > +post_seq_barrier(int model) { > > + pre_seq_barrier(model); > > +} > > + > > +#define pre_post_seq_barrier 1 > > + > > +#include_next <host-config.h> > > ... This does looks sensible and similar to what's done on powerpc, which is > similar to the aarch64 target in this regard. > However, there is already a host-config.h in config/linux/aarch64/host- > config.h . Does this file end up including the one in config/linux? > If so, does this mean that this works correctly (i.e. was tested) for aarch64- > none-elf as well as Linux? > Hi, We don't build libatomic on any elf platforms. It has a default unsupported flag which we don't override. Indeed we don't produce libatomic.a for elf and a simple example fails to link as well.. Regards, Tamar > Thanks, > Kyrill > > > > > > > > > > > --
> -----Original Message----- > From: Tamar Christina <Tamar.Christina@arm.com> > Sent: Monday, August 8, 2022 10:28 AM > To: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>; gcc-patches@gcc.gnu.org > Cc: nd <nd@arm.com>; Richard Earnshaw <Richard.Earnshaw@arm.com>; > Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Richard Sandiford > <Richard.Sandiford@arm.com> > Subject: RE: [PATCH 1/2]AArch64 Fix 128-bit sequential consistency atomic > operations. > > > > -----Original Message----- > > From: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com> > > Sent: Tuesday, July 12, 2022 2:46 PM > > To: Tamar Christina <Tamar.Christina@arm.com>; gcc- > patches@gcc.gnu.org > > Cc: nd <nd@arm.com>; Richard Earnshaw <Richard.Earnshaw@arm.com>; > > Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Richard Sandiford > > <Richard.Sandiford@arm.com> > > Subject: RE: [PATCH 1/2]AArch64 Fix 128-bit sequential consistency atomic > > operations. > > > > Hi Tamar, > > > > Let me be the latest to offer my apologies for the slow review. > > > > > -----Original Message----- > > > From: Tamar Christina <Tamar.Christina@arm.com> > > > Sent: Wednesday, June 8, 2022 3:49 PM > > > To: gcc-patches@gcc.gnu.org > > > Cc: nd <nd@arm.com>; Richard Earnshaw > <Richard.Earnshaw@arm.com>; > > > Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Kyrylo Tkachov > > > <Kyrylo.Tkachov@arm.com>; Richard Sandiford > > > <Richard.Sandiford@arm.com> > > > Subject: [PATCH 1/2]AArch64 Fix 128-bit sequential consistency atomic > > > operations. > > > > > > Hi All, > > > > > > The AArch64 implementation of 128-bit atomics is broken. > > > > > > For 128-bit atomics we rely on pthread barriers to correct guard the > > > address in the pointer to get correct memory ordering. However for > > > 128-bit atomics the address under the lock is different from the > > > original pointer. > > > > > > This means that one of the values under the atomic operation is not > > > protected properly and so we fail during when the user has requested > > > sequential consistency as there's no barrier to enforce this > > > requirement. > > > > > > As such users have resorted to adding an > > > > > > #ifdef GCC > > > <emit barrier> > > > #endif > > > > > > around the use of these atomics. > > > > > > This corrects the issue by issuing a barrier only when > > > __ATOMIC_SEQ_CST was requested. To remedy this performance hit I > > > think we should revisit using a similar approach to out-line-atomics > > > for the 128-bit atomics. > > > > > > Note that I believe I need the empty file due to the include_next > > > chain but I am not entirely sure. I have hand verified that the > > > barriers are inserted for atomic seq cst. > > > > > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > > > > > Ok for master? and for backporting to GCC 12, 11 and 10? > > > > I'll admit I'm not too familiar with the mechanics of libatomic but... > > > > > > > > Thanks, > > > Tamar > > > > > > libatomic/ChangeLog: > > > > > > PR target/102218 > > > * config/aarch64/aarch64-config.h: New file. > > > * config/aarch64/host-config.h: New file. > > > > > > --- inline copy of patch -- > > > diff --git a/libatomic/config/aarch64/aarch64-config.h > > > b/libatomic/config/aarch64/aarch64-config.h > > > new file mode 100644 > > > index > > > > 0000000000000000000000000000000000000000..d3474fa8ff80cb0c3ddbf8c4 > > > 8acd931d2339d33d > > > --- /dev/null > > > +++ b/libatomic/config/aarch64/aarch64-config.h > > > @@ -0,0 +1,23 @@ > > > +/* Copyright (C) 2022 Free Software Foundation, Inc. > > > + > > > + This file is part of the GNU Atomic Library (libatomic). > > > + > > > + Libatomic is free software; you can redistribute it and/or modify it > > > + under the terms of the GNU General Public License as published by > > > + the Free Software Foundation; either version 3 of the License, or > > > + (at your option) any later version. > > > + > > > + Libatomic is distributed in the hope that it will be useful, but > > > + WITHOUT > > > ANY > > > + WARRANTY; without even the implied warranty of MERCHANTABILITY > or > > > FITNESS > > > + FOR A PARTICULAR PURPOSE. See the GNU General Public License for > > > + more details. > > > + > > > + Under Section 7 of GPL version 3, you are granted additional > > > + permissions described in the GCC Runtime Library Exception, version > > > + 3.1, as published by the Free Software Foundation. > > > + > > > + You should have received a copy of the GNU General Public License > and > > > + a copy of the GCC Runtime Library Exception along with this program; > > > + see the files COPYING3 and COPYING.RUNTIME respectively. If not, > see > > > + <http://www.gnu.org/licenses/>. */ > > > + > > > diff --git a/libatomic/config/aarch64/host-config.h > > > b/libatomic/config/aarch64/host-config.h > > > new file mode 100644 > > > index > > > > 0000000000000000000000000000000000000000..f445a47d25ef5cc51cd21670 > > > 69500245d07bf1bc > > > --- /dev/null > > > +++ b/libatomic/config/aarch64/host-config.h > > > @@ -0,0 +1,46 @@ > > > +/* Copyright (C) 2022 Free Software Foundation, Inc. > > > + > > > + This file is part of the GNU Atomic Library (libatomic). > > > + > > > + Libatomic is free software; you can redistribute it and/or modify it > > > + under the terms of the GNU General Public License as published by > > > + the Free Software Foundation; either version 3 of the License, or > > > + (at your option) any later version. > > > + > > > + Libatomic is distributed in the hope that it will be useful, but > > > + WITHOUT > > > ANY > > > + WARRANTY; without even the implied warranty of MERCHANTABILITY > or > > > FITNESS > > > + FOR A PARTICULAR PURPOSE. See the GNU General Public License for > > > + more details. > > > + > > > + Under Section 7 of GPL version 3, you are granted additional > > > + permissions described in the GCC Runtime Library Exception, version > > > + 3.1, as published by the Free Software Foundation. > > > + > > > + You should have received a copy of the GNU General Public License > and > > > + a copy of the GCC Runtime Library Exception along with this program; > > > + see the files COPYING3 and COPYING.RUNTIME respectively. If not, > see > > > + <http://www.gnu.org/licenses/>. */ > > > + > > > +/* Avoiding the DMB (or kernel helper) can be a good thing. */ > > > +#define WANT_SPECIALCASE_RELAXED > > > + > > > +/* Glibc, at least, uses acq_rel in its pthread mutex > > > + implementation. If the user is asking for seq_cst, > > > + this is insufficient. */ > > > + > > > +static inline void __attribute__((always_inline, artificial)) > > > +pre_seq_barrier(int model) { > > > + if (model == __ATOMIC_SEQ_CST) > > > + __atomic_thread_fence (__ATOMIC_SEQ_CST); } > > > + > > > +static inline void __attribute__((always_inline, artificial)) > > > +post_seq_barrier(int model) { > > > + pre_seq_barrier(model); > > > +} > > > + > > > +#define pre_post_seq_barrier 1 > > > + > > > +#include_next <host-config.h> > > > > ... This does looks sensible and similar to what's done on powerpc, which is > > similar to the aarch64 target in this regard. > > However, there is already a host-config.h in config/linux/aarch64/host- > > config.h . Does this file end up including the one in config/linux? > > If so, does this mean that this works correctly (i.e. was tested) for aarch64- > > none-elf as well as Linux? > > > > Hi, > > We don't build libatomic on any elf platforms. It has a default unsupported > flag which we don't override. Indeed we don't produce libatomic.a for elf > and a simple example fails to link as well.. Ok, then I think this patch is a step in the right direction. Ok for trunk. Thanks, Kyrill > > Regards, > Tamar > > > Thanks, > > Kyrill > > > > > > > > > > > > > > > > > --
--- /dev/null +++ b/libatomic/config/aarch64/aarch64-config.h @@ -0,0 +1,23 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + + This file is part of the GNU Atomic Library (libatomic). + + Libatomic is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + <http://www.gnu.org/licenses/>. */ + diff --git a/libatomic/config/aarch64/host-config.h b/libatomic/config/aarch64/host-config.h new file mode 100644 index 0000000000000000000000000000000000000000..f445a47d25ef5cc51cd2167069500245d07bf1bc --- /dev/null +++ b/libatomic/config/aarch64/host-config.h @@ -0,0 +1,46 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + + This file is part of the GNU Atomic Library (libatomic). + + Libatomic is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + <http://www.gnu.org/licenses/>. */ + +/* Avoiding the DMB (or kernel helper) can be a good thing. */ +#define WANT_SPECIALCASE_RELAXED + +/* Glibc, at least, uses acq_rel in its pthread mutex + implementation. If the user is asking for seq_cst, + this is insufficient. */ + +static inline void __attribute__((always_inline, artificial)) +pre_seq_barrier(int model) +{ + if (model == __ATOMIC_SEQ_CST) + __atomic_thread_fence (__ATOMIC_SEQ_CST); +} + +static inline void __attribute__((always_inline, artificial)) +post_seq_barrier(int model) +{ + pre_seq_barrier(model); +} + +#define pre_post_seq_barrier 1 + +#include_next <host-config.h>