All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/2] tls: add macros for coroutine-safe TLS variables
@ 2021-10-25 14:07 Stefan Hajnoczi
  2021-10-25 14:07 ` [RFC 1/2] " Stefan Hajnoczi
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: Stefan Hajnoczi @ 2021-10-25 14:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: fweimer, Kevin Wolf, thuth, qemu-block, Stefan Hajnoczi,
	Fam Zheng, sguelton

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.

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

Stefan Hajnoczi (2):
  tls: add macros for coroutine-safe TLS variables
  util/async: replace __thread with QEMU TLS macros

 MAINTAINERS        |   1 +
 include/qemu/tls.h | 142 +++++++++++++++++++++++++++++++++++++++++++++
 util/async.c       |  12 ++--
 3 files changed, 150 insertions(+), 5 deletions(-)
 create mode 100644 include/qemu/tls.h

-- 
2.31.1




^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2021-10-27 12:37 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25 14:07 [RFC 0/2] tls: add macros for coroutine-safe TLS variables Stefan Hajnoczi
2021-10-25 14:07 ` [RFC 1/2] " Stefan Hajnoczi
2021-10-25 14:14   ` Daniel P. Berrangé
2021-10-26 13:36     ` Stefan Hajnoczi
2021-10-26 13:41     ` Stefan Hajnoczi
2021-10-26 14:10       ` Kevin Wolf
2021-10-26 16:26         ` Stefan Hajnoczi
2021-10-25 17:19   ` Richard Henderson
2021-10-26 13:30     ` Stefan Hajnoczi
2021-10-26 15:32       ` Richard Henderson
2021-10-26 16:27         ` Stefan Hajnoczi
2021-10-25 14:07 ` [RFC 2/2] util/async: replace __thread with QEMU TLS macros Stefan Hajnoczi
2021-10-25 14:20 ` [RFC 0/2] tls: add macros for coroutine-safe TLS variables Philippe Mathieu-Daudé
2021-10-25 16:16 ` Richard Henderson
2021-10-25 23:27   ` Warner Losh
2021-10-26 13:22     ` Stefan Hajnoczi
2021-10-26 15:10       ` Richard Henderson
2021-10-26 16:34         ` Stefan Hajnoczi
2021-10-26 17:10           ` Richard Henderson
2021-10-26 17:26             ` Thomas Huth
2021-10-26 18:03               ` Richard Henderson
2021-10-27 10:38             ` Kevin Wolf
2021-10-27 12:34             ` Stefan Hajnoczi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.