From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER,SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 994041F55B for ; Fri, 22 May 2020 10:55:16 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 010923851C0C; Fri, 22 May 2020 10:55:13 +0000 (GMT) Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90071.outbound.protection.outlook.com [40.107.9.71]) by sourceware.org (Postfix) with ESMTPS id CF0B7385E830 for ; Fri, 22 May 2020 10:55:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CF0B7385E830 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@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=SEntE1ybEVcnHRQr6s9qa54sR3qbXTFhODWMDcKwrzA=; b=1IBTiwk7XxvzMQTxUYckBz3kd/j96ONVjBQqVGdRICT4z7WPBl3dyO5c1O0FIvlUwNNpPAmBvFgdAKoJZ1pjXyIr8Ksc8vKPt/pdY4bnt7JZLBGNIkXj/w8Wzr80EUivSJtccCe93Qx45sh182kMOxGvRcJDJXMMKsEziFhhXck= Received: from AM7PR02CA0020.eurprd02.prod.outlook.com (2603:10a6:20b:100::30) by PR2PR08MB5227.eurprd08.prod.outlook.com (2603:10a6:101:1f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.27; Fri, 22 May 2020 10:55:07 +0000 Received: from AM5EUR03FT044.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:100:cafe::c0) by AM7PR02CA0020.outlook.office365.com (2603:10a6:20b:100::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.26 via Frontend Transport; Fri, 22 May 2020 10:55:07 +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 AM5EUR03FT044.mail.protection.outlook.com (10.152.17.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Fri, 22 May 2020 10:55:07 +0000 Received: ("Tessian outbound 952576a3272a:v57"); Fri, 22 May 2020 10:55:07 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 09f089a3f7c2e501 X-CR-MTA-TID: 64aa7808 Received: from 26702cc34423.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 07D2FF4E-AB59-402C-9410-3A3769770A43.1; Fri, 22 May 2020 10:55:01 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 26702cc34423.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 22 May 2020 10:55:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Az/1H1xopTmJIGyv/vXKTL+8T46E/rBGa5ZKKIF7ZokrG6VA0czjJsJ5aMg7jfhoJkDX6QVsuH7lsXDxq0VFebc84sNbDe+lS8pnVWWKS6nKxeGxZ2ffM6NZc9ffRADv+8j2z+/ER1grEiLNa4YNA2BuvRFpWVMVQirBaDqV6qRKHmdKxDEaO7rTGLs05aW00ecBKq5PlQlD4FKQDJuWvuMPq0NayDS2vpa2LWuoZB3NKjS9rS2Vjoe6DMG746UW82BGHs2SQJL9gltfX2lstYmBDUaNE31BSjKRJch5mTABS1KtqK45l+HCTk+hi1Mccin91x+b+xtv8/DZqu+DRw== 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=SEntE1ybEVcnHRQr6s9qa54sR3qbXTFhODWMDcKwrzA=; b=j2qXg9B/UhJCVxs7H9k5MUnnjJIO6ZRAeO2vHh35lTFEdpnFz2U+dmz9qejcH/3NDk3YDGfj5a8dT+o5m1yqk2FyL80iFaHgZO1enjRTYAOg97LoEMm3YdjhFdMmruEZMLI1ju8h9BpGX6EOtULVBuyZv7333RZQY0IiGTKwsn4gFemEsLGyOcVgLxDwurWbxI4pXwSCrJE2vcZf3vhj0J/qcwTKyQ6Nwgkf/UmRKONkP/GiNMY5gqklD/20NzAY7hwYpTMFp+1NA+uoY/fzz+g8trrB3yhwdmDtJfFhP6IpQIno90v6RI8lgC6MUUTNgPPBZTutcCH+w8uBolaHRg== 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=SEntE1ybEVcnHRQr6s9qa54sR3qbXTFhODWMDcKwrzA=; b=1IBTiwk7XxvzMQTxUYckBz3kd/j96ONVjBQqVGdRICT4z7WPBl3dyO5c1O0FIvlUwNNpPAmBvFgdAKoJZ1pjXyIr8Ksc8vKPt/pdY4bnt7JZLBGNIkXj/w8Wzr80EUivSJtccCe93Qx45sh182kMOxGvRcJDJXMMKsEziFhhXck= Authentication-Results-Original: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB3800.eurprd08.prod.outlook.com (2603:10a6:20b:87::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.26; Fri, 22 May 2020 10:55:00 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::49fd:6ded:4da7:8862]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::49fd:6ded:4da7:8862%7]) with mapi id 15.20.3021.020; Fri, 22 May 2020 10:55:00 +0000 Date: Fri, 22 May 2020 11:54:58 +0100 From: Szabolcs Nagy To: Florian Weimer Subject: Re: [PATCH 2/2] manual: Document __libc_single_threaded Message-ID: <20200522105458.GB29518@arm.com> References: <2c218c9ed9586ed5491f6fa08045d1e883b126c3.1589998207.git.fweimer@redhat.com> <724ecd59-d6e4-9f52-f425-8a4ff795114f@linaro.org> <20200521130927.GF14130@arm.com> <39687760-f8b1-4209-8798-ed8a16b87b57@linaro.org> <20200521133046.GH14130@arm.com> <87k115768f.fsf@oldenburg2.str.redhat.com> <20200522100146.GA29518@arm.com> <877dx45low.fsf@oldenburg2.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <877dx45low.fsf@oldenburg2.str.redhat.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-ClientProxiedBy: LO2P265CA0118.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::34) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from arm.com (217.140.106.55) by LO2P265CA0118.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.24 via Frontend Transport; Fri, 22 May 2020 10:55:00 +0000 X-Originating-IP: [217.140.106.55] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: cf8acd92-812d-47a6-62f9-08d7fe3e9720 X-MS-TrafficTypeDiagnostic: AM6PR08MB3800:|PR2PR08MB5227: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-Forefront-PRVS: 04111BAC64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: VcGXEnTnAvSw7Usup08yLw6QGiAesPb3Pj8fD1q9jnU2ro0N+ZPLKS34mR648J7l4V3gre3c9y0hBXQfxgTGtJKr6TsZA9bnkjFxYPDwjO9hDAnbN3h/9MjtrQBrvZ1/Uy8DSLfVtLsJfmzbUxhqgGRvcjPpnL7dwhCb8DBgkFUpzWUpOlak2LJHENU+Lo7MgoYORZkojY69PAZqLNdgNK2/AjRqhLSI6YzmHmfhtC7J1HUtfms5zSKJpeQjwm4YMuaBoFn0MZVQQXXnM73EsVw9q/mojm36BfEL1o82y/4ZqsMViAFx7Lc0aM04dA7qSZfxUwAQS03NT641Wepq8QJj0fvlq25JolTC8dcBETxVKwEdxkF1fdI+5m9tyffgx9/r26klg3HuTx/tRr6oPU4m6i/o+2gIWM3ynQFjiAM8yJIOMInwS24pgc3sYaQj X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(376002)(346002)(366004)(396003)(136003)(86362001)(7696005)(66556008)(6916009)(316002)(8676002)(8886007)(2616005)(66476007)(956004)(36756003)(478600001)(8936002)(44832011)(66946007)(2906002)(1076003)(5660300002)(52116002)(26005)(186003)(16526019)(55016002)(4326008)(33656002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Ma4mtTmWP4e5SwCTmKRtLkQaICa1wfqpGrHrrSuz+wha5zBtA2Vadm/lwH/ssiTqw8ND+k9w3OxDfF95cyCAx4uTdYTzXRuFU1wTqi9dMUDn1sjh3+IJqDdCxtDd+8skudNrcF3RvvaKuQcIh7i+oZHd2mV1b6BggtG8TtW/sOQfU3jrfnkdSXv5edazpZgVINsxTxd+2qreESXM3eNOHlYT0PGe0fz5Y6/6NJesB11fuXZTYGygk1+mcSAOS0sARpS+vsaIgUsxRYoQOSZSqxhfa2cb8AeEQEh8suYbF28ZxGZBHQ2vFBMY1atQYm9DhKrqiHTarVohyUdHd32tDq5mCkH92ImKDM9vaRi2GLSi7xWBvpf7yX1FWzH/BdmXIlWE0q95jCKa3e5kUBcplDaqAKJxJCX9GhfU8XNKlx7RbaPSawDvba8k7QZltve/gOimAw5vh0mA+CQ+BzhHdFFkPKB5d9X/Iz36L/ofCrQM/7m9xgzFsdBJs1FFcCIN X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3800 Original-Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT044.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)(346002)(396003)(136003)(376002)(39860400002)(46966005)(2906002)(55016002)(4326008)(36906005)(956004)(47076004)(336012)(186003)(70206006)(26005)(86362001)(16526019)(8886007)(70586007)(2616005)(36756003)(82740400003)(82310400002)(7696005)(81166007)(356005)(6862004)(316002)(44832011)(478600001)(33656002)(5660300002)(8676002)(1076003)(8936002); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: e6f086ed-e574-4c6f-c500-08d7fe3e931a X-Forefront-PRVS: 04111BAC64 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wYkRxXy87v1CPxI3KVOwx2cwrQAcVIAH41PaSAN5QM6m08kKawTsRGV/otNQt+rQazk7HsYn0eSty9utg6MNPRv0LfBkarrdk+t0alEp3UJMK0/TMhMllcNXqu1qO9zIi3SACkwhpU6HGxN8Y3xbiOU9z2ZFoS3GZo9g94qrumlemZ2bJck5rpVapW5lKSivOmTj6+hlzP4Zxg1MbhYUh09RmGQX7VSvDSjEXwTqQmcrGlU40DmQA0yloSwAhZPZA5WRNet9Vtu9WyMUz6xfx0slFlh6+/IM5GeRxmm0Kbnw0zhMcYGhQaMhGYEDcLaW7Bj8EQeoA/1USpf8E1W8qEogWKhFYypkIgTrS7SZTo3WJWqjiyHAvGdOzwKwkE7FEnL3/HxerO6SiC5/aLFgiYCJ5Q4sg26IIhWgKVichfdKJX3/mDYU7AEREdGdJUmXLrm3wTCrKA0GAtWTfnA5nTzeQY22eUlKxArHq1/f4NkYRGmFQRTq6TLlN7I2Hn1/6ZfI2pKD6fvR6YZHnKQp6Q== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2020 10:55:07.2504 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf8acd92-812d-47a6-62f9-08d7fe3e9720 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: PR2PR08MB5227 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: , Cc: libc-alpha@sourceware.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The 05/22/2020 12:05, Florian Weimer wrote: > * Szabolcs Nagy: > > > The 05/21/2020 15:44, Florian Weimer wrote: > >> * Szabolcs Nagy: > >> > what's wrong with pthread_join updating it? > >> > >> It's tricky do it correctly if there are two remaining threads, one of > >> them the one being joined, the other one a detached thread. A > >> straightforward implementation merely looking at __nptl_nthreads before > >> returning from pthread_join would not perform the required > >> synchronization on the detached thread exit. > > > > i'm trying to understand this, but don't see > > what's wrong if the last thread is detached. > > Sorry, I meant three reamining threads in total, i.e., two more threads > in addition to the one thread that keeps going after the other two > exited, and may use __libc_single_threaded in the future. > > Clearer now? hm so a detached thread is concurrently exiting with a pthread_join which sees a decremented __nptl_nthreads but the detached thread has not actually exited yet. i think glibc can issue a memory barrier syscall before decrementing __nptl_nthreads in a detached thread, this means if pthread_join observes __nptl_nthreads==1 then user memory accesses in the detached thread are synchronized with non-atomic memory accesses after pthread_join returns. (i.e. __nptl_nthreads==1 should mean at all times that as far as user code is concerned the process is single threaded even if some detached thread is still hanging around) i think __libc_single_threaded should be possible to update in pthread_join with the above change, in which case we need not document that it stays false forever, so we can change this in the future. (unless somebody finds usecases where a false->true transition would cause problems)