From patchwork Mon Sep 5 16:35:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 1674371 Return-Path: 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=) 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=sGm2EZWz; 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 4MLvKV1Gc6z1yhd for ; Tue, 6 Sep 2022 02:36:14 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A73803856952 for ; Mon, 5 Sep 2022 16:36:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A73803856952 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1662395770; bh=FbSYPpY4E8acvqFVWJBDpv4AQt5bnPutxxN01Qatjwo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=sGm2EZWzvdeQD2kUuamP0phH7gU5E47vyrACmH3ZeytliZw9sq5wNxYH2O4+0BwFm toiKOv/HwKLBZoulGwDQhnuyfN11Tc8Y61QHEwY3Gz5h/ZHWpYxRTG1pb47cFhV6TE OhgKpvVXeuTrXU6wRDRsuvX9X5ZE0QPMKmUro4cQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10071.outbound.protection.outlook.com [40.107.1.71]) by sourceware.org (Postfix) with ESMTPS id 9B3AC3856DC0 for ; Mon, 5 Sep 2022 16:35:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9B3AC3856DC0 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=L2mJSHUe1DW8kMrjAUxNeJ8s2O6bo344GgtWIGHwtCPcZ2xuNtxbZB3J+TwYj88tbS2aFoNmMfcS2CqhRJq8OVSPQpTzyU/dvVBwejDsyMK85AkY50nYeEn4SnCnc96T0AHxe0Cy5QWj+quLl0funuzmVWovLonW/8uA2CgXKVWaYCLLOe1gdwPmxVEH2nEFCE+XhN1bm+lPX0bFunHvcl9I1+01egzutz7zrvlytGicGn+7hT+1Ri1Y0SZ06C11fpIAn5COUqWXUKDJ0/rslcV8nOB1P2XkKPhAa32KJRXzpkF+T1BNhi5WiH1tKAoCitz0Owa5TorxsbqQCDwn7Q== 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=FbSYPpY4E8acvqFVWJBDpv4AQt5bnPutxxN01Qatjwo=; b=YE7dPPr0C9Q+Mp1wFVry+1pNpW7tJzggj7kMSkKDf38zYpoXJMrDs/Vnr6uok3FfOmN62qogdbm+3C5E1KS2JjTqMoLf6DB2zriBtIsA7VkxqpNxW1wJURlgpheyAaJS1mMN0ymeIseC66DgMTV4FVIzni01khvXrOw8U969iVjUaGIwjDaMnobQNsVZ7z4giW28R0G/l2jZKOUsVwR81clcDHpulmdFRx+8R/sKGM53CGJ2lqT2F6qYBxdX2HIh2Z8dJdzxquYFGnRqxjNth8CXQ6C20+UkvssU+uxEsHpvobVu0FUQ7r96zwiFMhK4LwZi+8SJ7iZiag8xAdcqzw== 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 DUZPR01CA0043.eurprd01.prod.exchangelabs.com (2603:10a6:10:468::6) by VI1PR08MB5517.eurprd08.prod.outlook.com (2603:10a6:803:139::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.12; Mon, 5 Sep 2022 16:35:49 +0000 Received: from DBAEUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:468:cafe::4) by DUZPR01CA0043.outlook.office365.com (2603:10a6:10:468::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.14 via Frontend Transport; Mon, 5 Sep 2022 16:35:49 +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 DBAEUR03FT012.mail.protection.outlook.com (100.127.142.126) 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:35:49 +0000 Received: ("Tessian outbound fccf984e7173:v123"); Mon, 05 Sep 2022 16:35:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 466546c8b9038f55 X-CR-MTA-TID: 64aa7808 Received: from 0723a59b135f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4AEA9740-31BB-4CC4-92AF-88C3E4CA925C.1; Mon, 05 Sep 2022 16:35:42 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0723a59b135f.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 05 Sep 2022 16:35:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J5d8X6t+uh6AK7Q/LYen96BdH9iB0MoZo51i3hBBdDEipXyMJdmYYP5pQrIFhC8zHIwuaBjwjjyWeetR9mrDG5SRzGL2lrZ0EhEHV7pQyg5r4DhVNDWQ7GWKUuMddqQ4UH33N361v7Amw1kGZwFi/PBGmtHQ0TdXPzOJOpEVrqynJmPgA616KVd3flolCvdXgZxramhoaReBfoBgq2ZClIyzRiJuOalYRuCPX7kveaUSr4F4AfZ4SdgyP7Xas2SU63H+qXBcgXRL6gQJlSLLBlX1WQYiZFWaBJzTbfPahXT649oz43mTeoj47Phe5PtUR4/rO6LbUjDHzGfq1ZnCzA== 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=FbSYPpY4E8acvqFVWJBDpv4AQt5bnPutxxN01Qatjwo=; b=oE9UgmYpi2WLil7Nw1OPVO1SmavaMqmp9QdnNbDYl8yy5KudL4zJXI4XtjAdeKCGJbdckw/EzeGsa3e3OUoicbopcqGVandeHgsIGMsxb7ZQxc4abB6VmkFKdHe3sg2Ad5ox37F2MXPa0FXf/nrmds1wqspUf7TCqINUVNmaRgnxptI4y/IhfDfrErUyPTI1esrls/Cj1A/H98iWKaJJ7NQ/I3g3J7kSCt0Dd+l6iCmqywMtsusBgouUL07chsLsoAbNctUtaS3TV+ArYTv2OpOeKsdwG2hM6SEU9Vo1rQdvcm7UdEW7KV3VrWMEhxfLg0lMKqiKmKh7dHPz+HC1Vg== 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 AS2PR08MB9414.eurprd08.prod.outlook.com (2603:10a6:20b:596::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Mon, 5 Sep 2022 16:35:41 +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:35:40 +0000 To: 'GNU C Library' Subject: [PATCH] Use C11 atomics instead of atomic_bit_set/bit_test_set Thread-Topic: [PATCH] Use C11 atomics instead of atomic_bit_set/bit_test_set Thread-Index: AQHYwUVpNZ5UYNp6Mk2+9/hh6vxlAw== Date: Mon, 5 Sep 2022 16:35:40 +0000 Message-ID: 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: 17d5b4eb-5638-4a4e-6379-08da8f5cb0d3 x-ms-traffictypediagnostic: AS2PR08MB9414:EE_|DBAEUR03FT012:EE_|VI1PR08MB5517: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: F2jZyMt251G0OR/So2fmYZ+LAZvnkp/g+5ra7cWZuQIHlZLJPFw1sAdcBSst3Sg1zzPGAcioOFxv2oS7VYDT7ajgeUZcxB0XNxlcixECSv4xViCl8TBJwCxvYZauVA/lrGap79rFyj1z+WWf6Y624QGvElW97PN+4IdC0AwyPNI5GJ8mRWCGERJxxz5wqCQ+CDqIvBq14yngby29lfz0nF9X7eINElC2qDVnDJE4LuFb7pBio8KaaXIQ5YLE3ctS5degFUiLrxa4Elbl/90NNuFX5cEmsj5tlgSPTrpCRrqKLFCLwcyQohqHEYjSaUOgqyNeo6Zi2AjFXa3P36AzfYBHpnoruRp+HJyv8QbLWJgpN4T6fHnXcrp64a2TD/mzyeXp3vm0SErhjt9/AzkfmEPYpPQguxOyZzCmNwy44GpzlHYEEOPhYzTIBrJ03HYLOqYcK9fKcIc2osEx/OyvSj7kAaKbAz2otCkDd4NtEuHRgwLHOXQC5891zvDZT7yF+7a/9i4sNvYj+tbjenwha1QQmgAbUj54Br2hp4qMzkEauuuVnqeP2iAeuhWIRjN7Jj8pLcImRxQLB7iICbm9J4akrt8RoHmSrktuRuTsBmC/us5Dq71xmQzRBl36I7I+0M2+alvfLxETmFMLWOU9O0MkRpkEQMLubxpIqvQoltAl/d/KLK+nP6eGBSRzDEcsJaa2z285y4FtyUHq9TgiREwiFvVW9gScblTtSJnjCXK2Dvs1eMA1PlOMdprYvCpuhCjoDDhxbJ2fqwtbgN6iAA== 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)(39860400002)(366004)(376002)(136003)(396003)(346002)(91956017)(8676002)(76116006)(66946007)(4326008)(66476007)(66446008)(316002)(64756008)(66556008)(6916009)(86362001)(26005)(9686003)(33656002)(186003)(52536014)(38070700005)(2906002)(55016003)(5660300002)(8936002)(7696005)(6506007)(38100700002)(41300700001)(71200400001)(478600001)(122000001); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9414 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: DBAEUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 0fc208bc-c60d-4886-60d4-08da8f5cabc1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YlfexIYWzqWenga+HlzbSGJFTPeSfv5AnnYWWZD3Gzb3EO2ZUyTP8PlVq9VhNhwty04LaFmQNBlB98LLeba6575xe4xnk8k3+AdW8STRH7zrbtysjMWPxNvX4pZkDE9uo44KG5dy6WU00epSIqCntadMI8YY+DTrwaD+Ndn8HNPSwcKDdlrsLYp3qDSTmvb498SZ0y2PRMoEWvyf3HhaLgGo31Bz1hDnZAMNTrnI1dIz31Oly86ZUPZPZymfyOouV/js1OlYafAiuYSScUzPc/W7b2bcyrWoRVTnl0i8IOrejTX/HlgX9xwlyrsgfISBcstYHYXzB3yyPiAv46cZAvEUtGLZ0r1oqojwug2g7h2hYL0T9nAvHG0kJNzaQMIFI6IJsJX9HJnSsSQJUyxDflAyQw/WFhx/ct4iRbo3UJ/PRlU2BemCitPvd7Ygu+Q34ranEMOza/sF1ga5YN/SAdNFM5HsZtxDEjWNz4R5MOL10rSaW8v5dYASocyCynRq0t1VSuO4eC/QbA7NLOFhmx1qgwNqZ/tiLEoOHgf03e0hyo4qCgLn2OTP99eL6YWHBK551WNEimfALfRIt9FuQWVAeGqAdji0rksK3uuANxfTp4kclDSIsGzkhTDtICvpqBw8Z2DJeBV9PpmRRVGNeT5CYjKvr4N6x88uQOidXFHrs3DToPPhJxcCKLh3Fn5AfwUYvP9tT6PIFp5z9nRRkxwBHyFPLFWZwjSDhSU7N3o84AVVuX8sfddSf7f0hGR7gvBHsu8VJ387zk5oauth/Q== 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)(39860400002)(376002)(396003)(136003)(346002)(40470700004)(36840700001)(46966006)(4326008)(8676002)(33656002)(70206006)(336012)(47076005)(70586007)(8936002)(36860700001)(5660300002)(52536014)(107886003)(6506007)(26005)(7696005)(478600001)(41300700001)(186003)(40460700003)(6916009)(316002)(86362001)(40480700001)(9686003)(55016003)(356005)(81166007)(2906002)(82740400003)(82310400005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2022 16:35:49.2597 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17d5b4eb-5638-4a4e-6379-08da8f5cb0d3 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: DBAEUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5517 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, 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: 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: , X-Patchwork-Original-From: Wilco Dijkstra via Libc-alpha From: Wilco Dijkstra Reply-To: Wilco Dijkstra Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Replace the 3 uses of atomic_bit_set and atomic_bit_test_set with atomic_fetch_or_acquire. Passes regress on AArch64. Reviewed-by: Florian Weimer diff --git a/nptl/nptl_free_tcb.c b/nptl/nptl_free_tcb.c index 0d31143ac849de6398e06c399b94813ae57dcff3..0ba291e0d87435b7f551ab8d64f73fb5abec92fc 100644 --- a/nptl/nptl_free_tcb.c +++ b/nptl/nptl_free_tcb.c @@ -24,7 +24,8 @@ void __nptl_free_tcb (struct pthread *pd) { /* The thread is exiting now. */ - if (atomic_bit_test_set (&pd->cancelhandling, TERMINATED_BIT) == 0) + if ((atomic_fetch_or_acquire (&pd->cancelhandling, TERMINATED_BITMASK) + & TERMINATED_BITMASK) == 0) { /* Free TPP data. */ if (pd->tpp != NULL) diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 870a8fcb34eb43b58c2260fee6a4624f0fbbd469..d206ed7bf4c2305c0d65bc2a47baefe02969e3d2 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -487,7 +487,7 @@ start_thread (void *arg) /* The thread is exiting now. Don't set this bit until after we've hit the event-reporting breakpoint, so that td_thr_get_info on us while at the breakpoint reports TD_THR_RUN state rather than TD_THR_ZOMBIE. */ - atomic_bit_set (&pd->cancelhandling, EXITING_BIT); + atomic_fetch_or_acquire (&pd->cancelhandling, EXITING_BITMASK); if (__glibc_unlikely (atomic_decrement_and_test (&__nptl_nthreads))) /* This was the last thread. */ diff --git a/sysdeps/nptl/pthreadP.h b/sysdeps/nptl/pthreadP.h index 39af275c254ef3e737736bd5c38099bada8746d6..7db1b71f1d5b6b6925a5405090a83697545b6798 100644 --- a/sysdeps/nptl/pthreadP.h +++ b/sysdeps/nptl/pthreadP.h @@ -43,12 +43,6 @@ atomic_compare_and_exchange_val_acq (&(descr)->member, new, old) #endif -#ifndef THREAD_ATOMIC_BIT_SET -# define THREAD_ATOMIC_BIT_SET(descr, member, bit) \ - atomic_bit_set (&(descr)->member, bit) -#endif - - static inline short max_adaptive_count (void) { #if HAVE_TUNABLES @@ -276,7 +270,7 @@ __do_cancel (void) struct pthread *self = THREAD_SELF; /* Make sure we get no more cancellations. */ - atomic_bit_set (&self->cancelhandling, EXITING_BIT); + atomic_fetch_or_acquire (&self->cancelhandling, EXITING_BITMASK); __pthread_unwind ((__pthread_unwind_buf_t *) THREAD_GETMEM (self, cleanup_jmp_buf));