From: "H.J. Lu" <hjl.tools@gmail.com>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Noah Goldstein <goldstein.w.n@gmail.com>,
GNU C Library <libc-alpha@sourceware.org>,
Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Subject: Re: [PATCH 3/7] Remove atomic_bit_set/bit_test_set
Date: Tue, 12 Jul 2022 11:09:21 -0700 [thread overview]
Message-ID: <CAMe9rOrqJ7jBEuNOhwz=rOo8KKz7Rnx=b6DLNqjXjFw4Bd8ceg@mail.gmail.com> (raw)
In-Reply-To: <0f40a803-eb51-e803-edd3-e6cf05a97b74@linaro.org>
On Tue, Jul 12, 2022 at 10:47 AM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> 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
> > <libc-alpha@sourceware.org> wrote:
> >>
> >> On Wed, Jul 6, 2022 at 1:14 PM Wilco Dijkstra <Wilco.Dijkstra@arm.com> 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.
next prev parent reply other threads:[~2022-07-12 18:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-06 15:14 Wilco Dijkstra
2022-07-06 16:14 ` Noah Goldstein
2022-07-06 18:25 ` Noah Goldstein
2022-07-06 18:59 ` Wilco Dijkstra
2022-07-06 19:14 ` Noah Goldstein
2022-07-06 19:30 ` H.J. Lu
2022-07-06 19:36 ` Wilco Dijkstra
2022-07-06 19:51 ` Noah Goldstein
2022-07-06 19:56 ` Noah Goldstein
2022-07-06 20:14 ` Wilco Dijkstra
2022-07-06 20:30 ` Noah Goldstein
2022-07-06 20:56 ` H.J. Lu
2022-07-12 17:47 ` Adhemerval Zanella Netto
2022-07-12 18:09 ` H.J. Lu [this message]
2022-07-12 18:44 ` Wilco Dijkstra
2022-07-12 19:11 ` H.J. Lu
2022-07-12 19:18 ` Noah Goldstein
2022-07-12 20:39 ` Wilco Dijkstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMe9rOrqJ7jBEuNOhwz=rOo8KKz7Rnx=b6DLNqjXjFw4Bd8ceg@mail.gmail.com' \
--to=hjl.tools@gmail.com \
--cc=Wilco.Dijkstra@arm.com \
--cc=adhemerval.zanella@linaro.org \
--cc=goldstein.w.n@gmail.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).