public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Arjan van de Ven <arjan@linux.intel.com>
To: Oleh Derevenko <oleh.derevenko@gmail.com>
Cc: "H.J. Lu" <hjl.tools@gmail.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH] x86: Optimize atomic_compare_and_exchange_[val|bool]_acq [BZ #28537]
Date: Wed, 3 Nov 2021 10:30:16 -0700	[thread overview]
Message-ID: <5b16e035-d523-21c9-226c-3c8b8d9aa759@linux.intel.com> (raw)
In-Reply-To: <CAC1wWD3Q8BVEZ4ZBOqULT7LbfZ_3MegsQZ=t=g3OWaeEvNAfLA@mail.gmail.com>

On 11/3/2021 10:26 AM, Oleh Derevenko wrote:
> Arjan
> 
>> What the patch does is check non-atomic first if the actual atomic operation has
> a chance of working. if it has a chance, the actual normal atomic
> operation is done as
> before. But if non-atomic read already tells you the cmpxchg has no
> chance to succeed, it errors
> out early.
> 
> The idea of atomic function is that they are intended to work fairly
> with any type of memory. In your case, the speculative reads for a
> cached device memory may result in cache access only and will prevent
> fetching memory updates from the device, thus making the reading
> thread "see" the change later than it could.


eh I am not sure I understand what you say since cmpxchg uses the exact same
cache protocol/etc to do its read...  it won't go to device memory either if
the cache line is anywhere in the cache hierarchy (including core-to-core transfers
in case another core has it in their caches)


(and cmpxchg on MMIO space has very very interesting and unexpected behavior. If folks remember
the "linux torches your e1000 eeprom" bug from some years ago, it came from that)

  reply	other threads:[~2021-11-03 17:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 15:04 H.J. Lu
2021-11-03 15:14 ` Andreas Schwab
2021-11-03 15:50 ` Oleh Derevenko
2021-11-03 16:59   ` Arjan van de Ven
2021-11-03 17:17     ` Andreas Schwab
2021-11-03 19:21       ` Arjan van de Ven
2021-11-03 19:48         ` H.J. Lu
2021-11-03 20:38       ` Oleh Derevenko
2021-11-03 22:12         ` H.J. Lu
2021-11-04  8:58           ` Oleh Derevenko
2021-11-04  9:44             ` Oleh Derevenko
2021-11-03 17:26     ` Oleh Derevenko
2021-11-03 17:30       ` Arjan van de Ven [this message]
2021-11-03 17:55         ` Oleh Derevenko
2021-11-03 19:22           ` Arjan van de Ven
2021-11-04 11:42     ` Oleh Derevenko
2021-11-04 14:15       ` Arjan van de Ven
2021-11-03 16:35 ` Florian Weimer
2021-11-03 19:13   ` H.J. Lu
2021-11-04 10:15     ` Florian Weimer
2021-11-04 14:31       ` H.J. Lu
2021-11-04 14:59         ` H.J. Lu
2021-11-03 17:25 ` Noah Goldstein

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=5b16e035-d523-21c9-226c-3c8b8d9aa759@linux.intel.com \
    --to=arjan@linux.intel.com \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=oleh.derevenko@gmail.com \
    /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).