From: Florian Weimer via Libc-alpha <libc-alpha@sourceware.org>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH 2/2] manual: Document __libc_single_threaded
Date: Wed, 03 Jun 2020 17:48:35 +0200 [thread overview]
Message-ID: <87r1uwtajw.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <af6b629b-bc68-193a-fad8-f9c575cf9540@linaro.org> (Adhemerval Zanella's message of "Thu, 21 May 2020 11:32:02 -0300")
* Adhemerval Zanella:
>> I'm going to add this to the manual as an implementation note, after the
>> first example:
>>
>> @c Note: No memory order on __libc_single_threaded. The
>> @c implementation must ensure that exit of the critical
>> @c (second-to-last) thread happens-before setting
>> @c __libc_single_threaded to true. Otherwise, acquire MO might be
>> @c needed for reading the variable in some scenarios, and that would
>> @c completely defeat its purpose.
>
> The comments is sound, but I still think we should properly document
> that this initial version does not attempt to update
> __libc_single_threaded on pthread_join or detach exit and maybe also
> the brief explanation you added on why this semantic was chose (to
> avoid the requirement of more strict MO).
I'm concerned that if we make the implementation too transparent,
programmers will read the explanation and say, “gosh, I better assign
true to __libc_single_threaded after I joined the last thread”. That's
not something we want to encourage.
>> For detached thread exits, this kind of synchronization may not be
>> easily obtainable in all cases. I don't think we can do it on the
>> on-thread exit path because the kernel will perform certain actions
>> afterwards (like robust mutex updates), no matter how late we do it. I
>> guess we could perhaps piggy-back on the stack reclamation mechanism.
>
> It seems that robust mutexes updates are indeed a problem, but I am not
> sure if CLONE_CHILD_CLEARTID clear helps here. It signals the thread
> is done with the memory synchronization, but the stack cache is not
> really updated. Maybe an extra clone3 flag ?
I thought we might piggy-back on the work that free_stacks does. But
the code is sufficiently convoluted that I'm no longer sure.
Thanks,
Florian
next prev parent reply other threads:[~2020-06-03 15:48 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-20 18:12 [PATCH 0/2] Add __libc_single_threaded Florian Weimer via Libc-alpha
2020-05-20 18:12 ` [PATCH 1/2] Add the __libc_single_threaded variable Florian Weimer via Libc-alpha
2020-05-21 13:07 ` Szabolcs Nagy
2020-05-21 13:16 ` Florian Weimer via Libc-alpha
2020-05-21 13:26 ` Szabolcs Nagy
2020-05-20 18:12 ` [PATCH 2/2] manual: Document __libc_single_threaded Florian Weimer via Libc-alpha
2020-05-21 7:52 ` Michael Kerrisk (man-pages) via Libc-alpha
2020-05-21 12:17 ` Florian Weimer via Libc-alpha
2020-05-21 11:18 ` Szabolcs Nagy
2020-05-21 12:16 ` Florian Weimer via Libc-alpha
2020-05-21 12:50 ` Adhemerval Zanella via Libc-alpha
2020-05-21 13:09 ` Szabolcs Nagy
2020-05-21 13:15 ` Adhemerval Zanella via Libc-alpha
2020-05-21 13:30 ` Szabolcs Nagy
2020-05-21 13:44 ` Florian Weimer via Libc-alpha
2020-05-21 13:58 ` Adhemerval Zanella via Libc-alpha
2020-05-21 14:03 ` Florian Weimer via Libc-alpha
2020-05-22 10:01 ` Szabolcs Nagy
2020-05-22 10:05 ` Florian Weimer via Libc-alpha
2020-05-22 10:54 ` Szabolcs Nagy
2020-05-22 11:08 ` Florian Weimer via Libc-alpha
2020-05-22 15:07 ` Rich Felker
2020-05-22 16:14 ` Rich Felker
2020-05-22 16:36 ` Adhemerval Zanella via Libc-alpha
2020-05-22 17:02 ` Florian Weimer via Libc-alpha
2020-05-22 17:18 ` Florian Weimer via Libc-alpha
2020-05-22 17:28 ` Rich Felker
2020-05-22 17:40 ` Florian Weimer via Libc-alpha
2020-05-22 17:49 ` Rich Felker
2020-05-22 19:22 ` Szabolcs Nagy
2020-05-22 19:53 ` Rich Felker
2020-05-23 6:49 ` Szabolcs Nagy
2020-05-23 16:02 ` Rich Felker
2020-05-25 8:08 ` Florian Weimer via Libc-alpha
2020-05-25 8:08 ` Florian Weimer via Libc-alpha
2020-05-25 17:21 ` Rich Felker
2020-05-27 11:54 ` Florian Weimer via Libc-alpha
2020-05-27 15:36 ` Rich Felker
2020-06-03 15:00 ` Florian Weimer via Libc-alpha
2020-06-03 17:11 ` Rich Felker
2020-05-21 13:56 ` Adhemerval Zanella via Libc-alpha
2020-05-21 13:14 ` Florian Weimer via Libc-alpha
2020-05-21 14:32 ` Adhemerval Zanella via Libc-alpha
2020-06-03 15:48 ` Florian Weimer via Libc-alpha [this message]
2020-06-03 17:52 ` Adhemerval Zanella via Libc-alpha
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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r1uwtajw.fsf@oldenburg2.str.redhat.com \
--to=libc-alpha@sourceware.org \
--cc=adhemerval.zanella@linaro.org \
--cc=fweimer@redhat.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).