public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@redhat.com>
To: Florian Weimer <fweimer@redhat.com>,
	Arjun Shankar <arjun.is@lostca.se>,
	libc-alpha@sourceware.org
Subject: Re: [PATCH v2] Fix double-checked locking in __gconv_get_path and __gconv_read_conf [BZ #22062]
Date: Tue, 10 Oct 2017 19:08:00 -0000	[thread overview]
Message-ID: <e0924e79-36d4-f966-b3dd-efd39e9e0f8a@redhat.com> (raw)
In-Reply-To: <1b058316-b54d-165d-5876-af1327d0cfde@redhat.com>

On 10/05/2017 11:38 PM, Florian Weimer wrote:
> On 10/06/2017 01:05 AM, Carlos O'Donell wrote:
>> Is there any reason we need this atomic load?
>> 
>>> +      gconv_path_elem_local = atomic_load_relaxed
>>> (&__gconv_path_elem);
>> ^^^^^^^^^^^^^^^^^^^
> 
> Oh, this follows just the general rule that if atomics are used, all
> accesses should employ atomics.  This follows from the general
> principle of C11 compatibility, where an atomic type would default to
> seq-cst access (which we don't want here).  I see this was not
> mentioned in the Concurrency wiki page.  I've fixed that.

Ah! Yes, that makes perfect sense. The assumption is we would switch
the type of the variable to an atomic type, and then the unadorned
accesses have to be seq-cst, which we don't need here.

Thanks for updating the wiki. I'd forgotten entirely about this.

> I did not notice that there was a __libc_once guard.  So it would be
> better to remove the locking from __gconv_get_path and document that
> (including that this serializes initialization of the gconv cache via
> __gconv_load_cache).

Yes, that's right.

Arjun,

I suggest you rework the patch like this:

- Remove locking from __gconv_get_path, and add comments to that function
  access is serialized by __libc_once in the caller.
- Add comment to __gconv_read_conf that it must be serialized by the
  __libc_once in the caller.

-- 
Cheers,
Carlos.

      reply	other threads:[~2017-10-10 19:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-02 14:31 Arjun Shankar
2017-10-05 15:18 ` Florian Weimer
2017-10-05 20:23 ` Carlos O'Donell
2017-10-05 22:20   ` Florian Weimer
2017-10-05 23:05     ` Carlos O'Donell
2017-10-06  6:38       ` Florian Weimer
2017-10-10 19:08         ` Carlos O'Donell [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=e0924e79-36d4-f966-b3dd-efd39e9e0f8a@redhat.com \
    --to=carlos@redhat.com \
    --cc=arjun.is@lostca.se \
    --cc=fweimer@redhat.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).