|
From: | Richard Henderson |
Subject: | Re: [RFC 0/2] tls: add macros for coroutine-safe TLS variables |
Date: | Mon, 25 Oct 2021 09:16:07 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 |
On 10/25/21 7:07 AM, Stefan Hajnoczi wrote:
This is a preview of how we can solve the coroutines TLS problem. Coroutines re-entered from another thread sometimes see stale TLS values. This happens because compilers may cache values across yield points, so a value from the previous thread will be used when the coroutine is re-entered in another thread.
I'm not thrilled by this, but I guess it does work.It could be worthwhile to add some inline asm instead for specific hosts -- one instruction instead of an out-of-line call.
Serge Guelton developed this technique, see the first patch for details. I'm submitting it for discussion before I go ahead with a full conversion of the source tree. Todo: - Convert all uses of __thread - Extend checkpatch.pl to reject code that uses __thread
Absolutely not. *Perhaps* one or two tls variables which are accessible by coroutines, but there are plenty that have absolutely no relation. Especially everything related to user-only execution.
r~
[Prev in Thread] | Current Thread | [Next in Thread] |