Message ID | AS4PR08MB7901DED0DB96725C6312B2D8837F9@AS4PR08MB7901.eurprd08.prod.outlook.com |
---|---|
State | New |
Headers | show
Return-Path: <libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=<UNKNOWN>) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Tsf2/gmR; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MLvXK6Nfjz1ygc for <incoming@patchwork.ozlabs.org>; Tue, 6 Sep 2022 02:45:37 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CD4343852746 for <incoming@patchwork.ozlabs.org>; Mon, 5 Sep 2022 16:45:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD4343852746 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1662396335; bh=EnuitpcHHJzLoD7bn+Q792PHRnKbqZGX8ijwqsFtPUU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Tsf2/gmRlKm6N1buLR8wO8Pr7cHE07THL/ufuu9vB+at5GZn3w/7904g1Pr+pe2uA BqaK3Fk308PyPhr62hruIBBUfOVbt/zNRhX5l5KfflIsI2dFbW5BeL4lMUzn+nz2SN 3HNZiENcz/4f7bU84ti4CS5z/UGaJDpn7kaUO6ow= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2088.outbound.protection.outlook.com [40.107.105.88]) by sourceware.org (Postfix) with ESMTPS id 208A3385E02E for <libc-alpha@sourceware.org>; Mon, 5 Sep 2022 16:45:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 208A3385E02E ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=JKvRgNMw2vYJm1q0ZRobKeCP7e0TcChVjTlAhbA3G6JZfqg3eYN9mMnZu4Drxj72lK/OCsXEjUm1i0gMczjqW0y6PfVjNV76obV54Gmowxxxzlqi+GZt7R/1lbJrRK7K81X1m581HEx69KLEy2YsPHoAADSt5Clz62+weIoU5b174rWXynCZdVV5PQh6EX6HkynTJxrNg6pp88R+CEx0WJkpxLZ/qzbtLkUHGhkg39Y+zgJPo320WkUm0+k8lkYj+7frlHuOzpdJfUk90bJvP+zNbbAnjsyFqsy0GoS/rVKj1S6bsRbs7d2UBEGWWyibhtlCq+mimz32iNunq4T1Sw== 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=EnuitpcHHJzLoD7bn+Q792PHRnKbqZGX8ijwqsFtPUU=; b=VnZFEwNcJT3o/97DUsDH1xIav4W7qlqdvjO0O2Nq6tAY1Dbe2mhdQ02xJqK1gowEZD3wL0TGukjXp3fORJAD0lQKJy3HJq0e8J9ro7GsSbJEyD0GSoM3hjTUQ9hjrwKpypdUT9BkqanDbLmyiWdE0cypdJxD2JTxCCperxUPPpk3JejwIMfxfPWc4WYURhYEva1+57+uqhMuo/d8FO+bxDhuu8b4znlWwJ67dFA4uXt4KmfzPwIEyPgAV9T/6auId5rivQ6/i0/AylBgji4INmiPjsAtF53iQgVmMqI7mXgXrVRmFybx5Eed1L+1KYV3UZgkYrgq4scVod0puzAYew== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.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 DB9PR01CA0006.eurprd01.prod.exchangelabs.com (2603:10a6:10:1d8::11) by PAVPR08MB9307.eurprd08.prod.outlook.com (2603:10a6:102:304::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.16; Mon, 5 Sep 2022 16:45:14 +0000 Received: from DBAEUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1d8:cafe::57) by DB9PR01CA0006.outlook.office365.com (2603:10a6:10:1d8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Mon, 5 Sep 2022 16:45:14 +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 DBAEUR03FT061.mail.protection.outlook.com (100.127.143.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Mon, 5 Sep 2022 16:45:14 +0000 Received: ("Tessian outbound 2af316122c7a:v123"); Mon, 05 Sep 2022 16:45:14 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 95734b847f23d4d1 X-CR-MTA-TID: 64aa7808 Received: from db0c6b1d5238.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6FA6AF68-E09A-4CC1-9B73-4B0809A04CA3.1; Mon, 05 Sep 2022 16:45:07 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id db0c6b1d5238.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 05 Sep 2022 16:45:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FvLNmwrgLQku1UDQ7HASqaqyGNqiT2sL1kyh1jAjFdOBR6Oy0dCmPXTwsrYJ+Cg703V5HyWk1enRPUAsKri8B8jM42qOBCMMRcRGaRMnYfXubaClLN7hqTSAktzVBeSoJThHtKMWJZrn93smcnsaxL53NkGhUt4uQ1vU6OUIunObSkAWWgSRKJjiyXHKmt4x4PFKXb73T1bs1pnT9FHpkPNHHUUV48Sgo07nhcN3lJpsl6GjcZoslu/OJvaweQAf7rh7l3U6Y1ULgFwcMwFrEyBWf627KFtrnmSkmQsCT14dpQ36XffoHSinYFEinBZfJLOUQJ+UMXpGk7PhRpOZpA== 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=EnuitpcHHJzLoD7bn+Q792PHRnKbqZGX8ijwqsFtPUU=; b=d5jc7jgK6593jZ/iOllj4G6l2XacPFTakiHj3VWc6oU5dDoqsKkukfFwOc5EUq5aVMoVvCF2Zml2QHY3zJ2fWMB2VDK6wVF1iVONv75bOjAzg/+TS63y9GUwT5KXrXDbOvNHpv1eOJQhQkcC9/UquCXfzljhpvU/2/8cN+gEEyhTmP3KxRU+hxuDriy46WgOItJy9spq31HW/ZI+8r7FRtXfAeVmmy4GS3u8IA2/ry3eAv9Udey6p/BPgwuq6A0KUW9gImvfx75y+/w++VLw475p9hHSB+w4LDnu760lhalZeDwGKZrBhl32bRdRSpLpPXPbmOQ4gRfvKOsR4GALkA== 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 Received: from AS4PR08MB7901.eurprd08.prod.outlook.com (2603:10a6:20b:51c::16) by DBAPR08MB5720.eurprd08.prod.outlook.com (2603:10a6:10:1a1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.11; Mon, 5 Sep 2022 16:45:05 +0000 Received: from AS4PR08MB7901.eurprd08.prod.outlook.com ([fe80::b58b:c477:7fd2:77bf]) by AS4PR08MB7901.eurprd08.prod.outlook.com ([fe80::b58b:c477:7fd2:77bf%4]) with mapi id 15.20.5588.010; Mon, 5 Sep 2022 16:45:05 +0000 To: 'GNU C Library' <libc-alpha@sourceware.org> Subject: [PATCH] Use C11 atomics instead of atomic_add/add_zero Thread-Topic: [PATCH] Use C11 atomics instead of atomic_add/add_zero Thread-Index: AQHYwUa2LQa4wgRjYUy7PeSoTb9OLg== Date: Mon, 5 Sep 2022 16:45:05 +0000 Message-ID: <AS4PR08MB7901DED0DB96725C6312B2D8837F9@AS4PR08MB7901.eurprd08.prod.outlook.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-Office365-Filtering-Correlation-Id: f5e8f46b-a0c7-46fe-0ccd-08da8f5e01bf x-ms-traffictypediagnostic: DBAPR08MB5720:EE_|DBAEUR03FT061:EE_|PAVPR08MB9307:EE_ 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: IABNrw8s5TsQeR6iEL/l8tO7n7lw9VWs/tqVBxS4dk48gjycEVDOGUGQukcGqMRkX37ccyRWS0WfmXfgrAe023hFKskzWA28wYbLlkSmdM2SVRRqypeFJvuXHWiywtnDC8pVMtNureWAH4noDYrY8HZT3sWStZnzNWr399t3uSDtNgFDraA2PUZxDvMIOAcM7bxNIw3KYVbi4KwDTRqiecXyyVYb0jKgkJJV6hH2yCVn2GUUqirNQ/V5YHoxm74PgFMdtwFkCNEc1nHexD4MGVf1zFbcCJQaVY8CV2vVE1S7kySe3zOJz9UU0amls3aNXVLyiD8+YT27hsjnV/FOU4xX7ZSyU8K1IWNGq2CIaRn5Pvm9f5b4EkmOl2UiAm5Ajg75qbQmxOWS3n+I10QwxGUTtQnO5jzsYVcGrFuLArdkdvJ1x54Gw3lw/Stnxpsp3nH48M644WatUXQjG7aVMkvikHL+gqTb+bZ0B4v/2uEBFoN28tgt30/7Jks1dQRePxuLO4oHb7xjhmemrnD5y9gx+oU0uS2YTihqQjARmqitRlezMdRy3ORcKxMqGDLqJs2WD/W3LmTnFnvhdY6wLjBnqSXBn1R9fjR2s0wi4xjRwB/PAALSV+s2Vbf4sv0bR04cnoCRC67iDxnZQjzwJLUixi7wsWnoeaHwuz+4JmaLWS6bRUiVB50PGwyLgb7L3txicxWsISc8EpsO//j//Eu60w0bI6Xj++k1uD5n+2Hzs2b614zjrrPY8jFFQJe2cDNrjRrBGCJKeaqAe6RARA== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS4PR08MB7901.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(39860400002)(376002)(366004)(346002)(396003)(5660300002)(316002)(83380400001)(33656002)(4326008)(8676002)(66556008)(91956017)(66476007)(8936002)(52536014)(6916009)(66946007)(76116006)(64756008)(66446008)(2906002)(41300700001)(71200400001)(55016003)(478600001)(26005)(9686003)(86362001)(186003)(6506007)(38070700005)(7696005)(122000001)(38100700002); 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: DBAPR08MB5720 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: DBAEUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 2d3f3ed2-233a-476d-f256-08da8f5dfc44 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZPA2NSsqBWnvilEyUo4gNOZ7Fx++yGeWxeEthZYe8gDGpp2TetPI52w058r1bGFN9MpfamPkzt+i394U8vPvUs88HIRCGUhv1hgcVudSp/7V12COKmyuipYrt9ziH0mqkrDDG9nBlIKjKwNKMk1m0RBN6DXO1uWlfNREz+unNC0vOkeo1uF6Xl0eh9kj0jEYgkm+pp6Tt/uhsdNsuJlUIOixb40mXmPT12aw5UOWIXkEfozK16avnLKbElsyzM0V5Natw9pIaE75AMsTvtW8ZDiGx6WOdLjjGlPCosTKJZ4YO0Cd5vz1z5qUdjAmcFSapwM1t0tBVxhJvtNER+mV6ibJ9628xMbevOsCzv4PJwUS/GQ5CPQdIaqAorIu8d6nfdZ806aWmwMdwWZeodKb86mdZ4Q5O3hWwTf8hZTQZ3vpMCxjzHs9LLrF9d3qxy7pI3FcNwVOqRd2q8UgmVjPf5aLniRo3nNVMCt/32tV9ZVLghOk5KWfwuxoVpzPQl6Iwsep2r7O+o8Cy1i1pwNISpV6UyIn0vUGTlWJ4K0mhCGFayS5YWUGUiQd2wtvkEwEQLSzynPYP/WYQz0okLMw9g0Hlvf90yoqaR6TKLstO5S24/RgIxs8O7x8OwQt3M+DQzcossH26AX3O21GvyY1BuFuKyhYc2xG/UUtcNQMznR1vMrft8iXc6miSvBjDb9/2ja/4uH4OPy65A3XSeCSGZTzbm2KEG2VitzNw+9Lx1JsVCzVz/6jreA6vSB5F9cQITY6BtZ5PWP1GWKQ2Vodiw== 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:(13230016)(4636009)(376002)(396003)(346002)(136003)(39860400002)(40470700004)(46966006)(36840700001)(316002)(33656002)(107886003)(7696005)(9686003)(26005)(83380400001)(6916009)(6506007)(40460700003)(478600001)(5660300002)(86362001)(52536014)(2906002)(8936002)(55016003)(82310400005)(4326008)(356005)(8676002)(40480700001)(36860700001)(82740400003)(41300700001)(186003)(70586007)(70206006)(81166007)(336012)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2022 16:45:14.5342 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f5e8f46b-a0c7-46fe-0ccd-08da8f5e01bf 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: DBAEUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB9307 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Wilco Dijkstra via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Wilco Dijkstra <Wilco.Dijkstra@arm.com> Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org> |
Series |
Use C11 atomics instead of atomic_add/add_zero
|
expand
|
diff --git a/malloc/malloc.c b/malloc/malloc.c index 6402cf94ea8ae724d86d2a04fc7d42e3af174564..adafef9d5a7b3c323bd6307c8d15f7f1921f0192 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3034,7 +3034,7 @@ munmap_chunk (mchunkptr p) malloc_printerr ("munmap_chunk(): invalid pointer"); atomic_decrement (&mp_.n_mmaps); - atomic_add (&mp_.mmapped_mem, -total_size); + atomic_fetch_add_relaxed (&mp_.mmapped_mem, -total_size); /* If munmap failed the process virtual memory address space is in a bad shape. Just leave the block hanging around, the process will diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c index fe73fe3ba84db02b1d7188de8f29d55019a69ff3..4d486ca9b5026c7a7950bd7c7155212966df3c44 100644 --- a/sysdeps/unix/sysv/linux/check_pf.c +++ b/sysdeps/unix/sysv/linux/check_pf.c @@ -278,7 +278,7 @@ make_request (int fd, pid_t pid) { free (result); - atomic_add (&noai6ai_cached.usecnt, 2); + atomic_fetch_add_relaxed (&noai6ai_cached.usecnt, 2); noai6ai_cached.seen_ipv4 = seen_ipv4; noai6ai_cached.seen_ipv6 = seen_ipv6; result = &noai6ai_cached; @@ -349,7 +349,7 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6, *in6ai = data->in6ai; if (olddata != NULL && olddata->usecnt > 0 - && atomic_add_zero (&olddata->usecnt, -1)) + && atomic_fetch_add_relaxed (&olddata->usecnt, -1) == 1) free (olddata); return; @@ -377,7 +377,7 @@ __free_in6ai (struct in6addrinfo *ai) (struct cached_data *) ((char *) ai - offsetof (struct cached_data, in6ai)); - if (atomic_add_zero (&data->usecnt, -1)) + if (atomic_fetch_add_relaxed (&data->usecnt, -1) == 1) { __libc_lock_lock (lock);