From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by sourceware.org (Postfix) with ESMTPS id 527383858C50 for ; Tue, 12 Jul 2022 18:09:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 527383858C50 Received: by mail-pj1-x1036.google.com with SMTP id 89-20020a17090a09e200b001ef7638e536so12494398pjo.3 for ; Tue, 12 Jul 2022 11:09:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SkwRUpk7ydwJbBBR9WMTbJPMUK0bnz6vb1+Mb+Qs8GQ=; b=eO1vJUxemJDykB0UrJhL6N9zPp4bcuaryHBPBV+I63HUtSJcdViqGQzNKLuphUr+0F OQ8QZ3Xxw9o42oINWK9J/RJiYYu4hdU3SxlHuCfwU2JFCAI7BfuSX4Og6JaVy9+zWX7d YNaNV7LVuHi7lfVJM6s6NIXDNgDrDVJtxddp/ovGAfSLIopf/V3UkliZYJzubOgwEkrG JHiylvEf9RSC8WbGaLi8MfCICacizzAecuJPl/L2k8Z7VmFb7D8OKMCPIVSKVIovCb88 8UnXiMaFE/wN5cU5Z9qv1kvJEktO+vqNVPHWlOglr25wUpxWxh5PDaCWY2hHuBaR4Eg1 iwng== X-Gm-Message-State: AJIora8Pvixj6O8hW6BvxX4OjrdS7b7Sj/H3yQMn4LQ7HCFmAaxYnL2r 3KhOVZfaQoqazyFABleKHAiZYSlFQTOhdr2hutE= X-Google-Smtp-Source: AGRyM1ublQz3HoHhRbu5F1rvuUKfWfLYLuplceP6e+DATM+N5rNXIYIKd3QDokfKHcwm54gTirXfQdXU2HkYfT9wmnY= X-Received: by 2002:a17:902:b215:b0:168:da4b:c925 with SMTP id t21-20020a170902b21500b00168da4bc925mr24219225plr.155.1657649397355; Tue, 12 Jul 2022 11:09:57 -0700 (PDT) MIME-Version: 1.0 References: <0f40a803-eb51-e803-edd3-e6cf05a97b74@linaro.org> In-Reply-To: <0f40a803-eb51-e803-edd3-e6cf05a97b74@linaro.org> From: "H.J. Lu" Date: Tue, 12 Jul 2022 11:09:21 -0700 Message-ID: Subject: Re: [PATCH 3/7] Remove atomic_bit_set/bit_test_set To: Adhemerval Zanella Netto Cc: Noah Goldstein , GNU C Library , Wilco Dijkstra Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3018.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Tue, 12 Jul 2022 18:09:59 -0000 On Tue, Jul 12, 2022 at 10:47 AM Adhemerval Zanella Netto wrote: > > > > On 06/07/22 17:56, H.J. Lu via Libc-alpha wrote: > > On Wed, Jul 6, 2022 at 1:31 PM Noah Goldstein via Libc-alpha > > wrote: > >> > >> On Wed, Jul 6, 2022 at 1:14 PM Wilco Dijkstra wrote: > >>> > >>> Hi Noah, > >>> > >>> The goal here is to move to the standard atomics, not to invent our own set for > >>> convenience or just for fun to be different etc. There were 2 uses of atomic_bit_set > >>> in all of GLIBC, and I cannot believe that atomic_fetch_or (&x, 1 << bit) could cause > >>> any confusion given that it is very similar to x |= 1 << bit. We don't wrap such > >>> expressions in macros like bitset (x, bit) either - it just doesn't make sense. > >>> > >>> As I mentioned, I'll use EXITING_BITMASK rather than 1 << EXITING_BIT. > >> > >> Alright. > > > > Before GCC 12, > > > > (__atomic_fetch_or (&x, MASK, __ATOMIC_ACQUIRE) & MASK) != 0; > > > > will be optimized to "lock btsl" only if x is unsigned. But cancelhandling in > > > > if (atomic_bit_test_set (&pd->cancelhandling, TERMINATED_BIT) == 0) > > > > is signed which leads to the much worse code when GCC 11 or older are > > used. > > > > I think it should be safe to change cancelhandling to be unsigned, > although this is really a micro-optimization that we should handle > in the compiler instead roll-out our own atomics. We should help older compilers in this case. Can we change cancelhandling to unsigned? Thanks. -- H.J.