Am 26.10.2021 um 19:10 hat Richard Henderson geschrieben: > On 10/26/21 9:34 AM, Stefan Hajnoczi wrote: > > On Tue, Oct 26, 2021 at 08:10:16AM -0700, Richard Henderson wrote: > > > On 10/26/21 6:22 AM, Stefan Hajnoczi wrote: > > > > If "safe" TLS variables are opt-in then we'll likely have obscure bugs > > > > when code changes to access a TLS variable that was previously never > > > > accessed from a coroutine. There is no compiler error and no way to > > > > detect this. When it happens debugging it is painful. > > > > > > Co-routines are never used in user-only builds. > > > > If developers have the choice of using __thread then bugs can slip > > through. > > Huh? How. No, really. > > > Are you concerned about performance, the awkwardness of calling > > getters/setters, or something else for qemu-user? > > Awkwardness first, performance second. > > I'll also note that coroutines never run on vcpu threads, only io threads. > So I'll resist any use of these interfaces in TCG as well.
This is wrong. Device emulation is called from vcpu threads, and it calls into code using coroutines. Using dedicated iothreads is possible for some devices, but not the default. In fact, this is probably where the most visible case of the bug comes from: A coroutine is created in the vcpu thread (while holding the BQL) and after yielding first, it is subsequently reentered from the main thread. This is exactly the same pattern as you often get with callbacks, where the request is made in the vcpu thread and the callback is run in the main thread. Kevin
