public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Andrew Pinski <pinskia@gmail.com>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: swapcontext happening on different threads
Date: Tue, 12 Mar 2024 14:47:42 +0100	[thread overview]
Message-ID: <87a5n3v9xd.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <CA+=Sn1mq6CmyQj-bw5=-uNQfzjO+8Qc2LREUFusx0yRcyj-ruQ@mail.gmail.com> (Andrew Pinski's message of "Tue, 12 Mar 2024 00:24:21 -0700")

* Andrew Pinski:

> Reference https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65712 .
>
> I am not 100% sure if this is a valid thing to do.
> But take the code in the referenced GCC bug report. Currently since
> pthread_self is marked as const, if you swap to a different context
> and then have that context be swapped on a different thread, you
> might/will get the old value of pthread_self in some cases.
>
> Is this well defined or is this a corner case that was not expected. I
> don't see anywhere in the older versions of POSIX that explain what
> would happen if you do that. And glibc's documentation does not talk
> about this case either.
>
> It would be useful if the documentation talked about this either way.

There have been passed discussions about this on the gcc list, for other
stackful coroutine implementations.  QEMU in particular needs a way to
implement a barrier for thread-local variable optimizations.  This is
not just about const functions like pthread_self or __errno_location, it
impacts GCC code generation for TLS variable access as well.

  Disabling TLS address caching to help QEMU on GNU/Linux
  <https://inbox.sourceware.org/gcc/87im15qbp3.fsf@oldenburg.str.redhat.com/>

I'm sure the QEMU developers would still appreciate explict TLS address
barriers in GCC.  As part of this, maybe we can get a replacement
function attribute to replace const for those functions.

Thanks,
Florian


      parent reply	other threads:[~2024-03-12 13:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12  7:24 Andrew Pinski
2024-03-12 12:48 ` Szabolcs Nagy
2024-03-12 13:47 ` Florian Weimer [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=87a5n3v9xd.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=pinskia@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).