From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 54D513858C50 for ; Tue, 12 Jul 2022 17:47:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 54D513858C50 Received: by mail-oi1-x232.google.com with SMTP id u68so1641107oie.0 for ; Tue, 12 Jul 2022 10:47:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=If+963Ve4R7II+RmQPQOf6y8cEl0J/cjlrm6aaCyNE4=; b=EaSvrxQa1z/gqjq09HgiXFi8BWm1kHu5mOg26r5RVtxuxNsbJEbmBbVM7AuEUKpY8w uWiIY+HR5k76K/MPfdkQ5wzJg71nsqgxTn/u2bFI1L4iGu7k0I33ZlWi3nEdvnELepXu OFMGoA/EZG5u1kYLEpuTAFTZqJUadyRAGqqkz0ydjW0aSFxqZ5B/uR+O7z0D8/XLm50F TyrBlYRzVH8XtPRCgcYTDdVPNQLc8eEPYFPLw0V/NNNjbTGaXmGlFvkR4HUkYv1yioaE Y/rwqyErVIRTqXZMW6ZXR93jdO3eeSvbewWINXgwBEWvfZv9nbeQmRaSbriclQe5f2Ne C8GQ== X-Gm-Message-State: AJIora834YkA2BcRUMUTqTOWCR9LMaMFA+ZhFm7ZBCKTrb5aqlag1uOl xfZtNXhqSw31kmUdlW49+vtOjuLpjlhBPg== X-Google-Smtp-Source: AGRyM1vR3qHuDlDxhPaqYnOjOyeUYBm++QHx3oB6NMZHBpEsLRGXn8R3NUHvftd3rOgZcLQgJigzIw== X-Received: by 2002:a05:6808:189c:b0:339:f6ca:c36c with SMTP id bi28-20020a056808189c00b00339f6cac36cmr2477037oib.64.1657648055218; Tue, 12 Jul 2022 10:47:35 -0700 (PDT) Received: from [12.18.8.156] ([201.46.27.6]) by smtp.gmail.com with ESMTPSA id t32-20020a056870602000b00101cdb417f1sm4936112oaa.22.2022.07.12.10.47.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Jul 2022 10:47:34 -0700 (PDT) Message-ID: <0f40a803-eb51-e803-edd3-e6cf05a97b74@linaro.org> Date: Tue, 12 Jul 2022 14:47:31 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.0.2 Subject: Re: [PATCH 3/7] Remove atomic_bit_set/bit_test_set Content-Language: en-US To: "H.J. Lu" , Noah Goldstein Cc: GNU C Library , Wilco Dijkstra References: From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, 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 17:47:38 -0000 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.