public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Cc: gcc-help@gcc.gnu.org, "Paul E. McKenney" <paulmck@kernel.org>
Subject: Re: Help needed for glibc software transaction memory algorithm
Date: Wed, 05 Jan 2022 10:07:09 -0300	[thread overview]
Message-ID: <875yqy72ma.fsf@linux.ibm.com> (raw)
In-Reply-To: <87v8yzfv3u.fsf@oldenburg.str.redhat.com>

Florian Weimer via Libc-alpha <libc-alpha@sourceware.org> writes:

> To fix this, I think it is sufficient to add a release fence just before
> the second version load in the reader.  However, from a C memory model
> perspective, I don't quite see what this fence would synchronize
> with.

AFAIU, it would synchronize with the previous relaxed load as if it were a
release operation.  Quoting N2731:

    A release fence A synchronizes with an atomic operation B that performs an
    acquire operation on an atomic object M if there exists an atomic operation
    X such that *X is sequenced before A*, X modifies M , and B reads the value
    written by X or a value written by any side effect in the hypothetical
    release sequence X would head if it were a release operation.

Where:

 - X is the read of the STM-protected data;
 - B is the load of the counter for a second time;

Notice that I fixed a typo in the original text that says "A is sequenced before
X".  Which is impossible because we would end up with:

    Fence A
    Operation X
    Operation B

Source: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2731.pdf

> And of course once there is one concurrency bug, there might
> be others as well.  Do I need to change the writer to use
> acquire-release MO for the version updates?

I don't think this is necessary.

-- 
Tulio Magno

      parent reply	other threads:[~2022-01-05 13:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-04 14:12 Florian Weimer
2022-01-04 22:14 ` Szabolcs Nagy
2022-01-05 11:38   ` Florian Weimer
2022-01-05 13:07 ` Tulio Magno Quites Machado Filho [this message]

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=875yqy72ma.fsf@linux.ibm.com \
    --to=tuliom@linux.ibm.com \
    --cc=fweimer@redhat.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=libc-alpha@sourceware.org \
    --cc=paulmck@kernel.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).