qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Make cpu_single_env thread local (Linux only fo


From: Jan Kiszka
Subject: Re: [Qemu-devel] [PATCH] Make cpu_single_env thread local (Linux only for now)
Date: Wed, 26 Oct 2011 17:02:56 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

On 2011-10-26 16:54, Peter Maydell wrote:
> On 26 October 2011 15:39, Paolo Bonzini <address@hidden> wrote:
>> On 10/26/2011 04:03 PM, Peter Maydell wrote:
>>>
>>> For the record (since I think we only talked about this on IRC):
>>>  * the POSIX TLS fallback code doesn't work on Linux hosts for
>>>    linux-user emulation (the constructor is never called to set up
>>>    the TLS for the main thread, probably something to do with our
>>>    custom linker script, since it does work OK for system emulation)
>>>  * if I recall correctly from IRC it doesn't compile on OpenBSD
>>>
>>> so for 1.0 perhaps we need to fall back to a simpler set of patches
>>> that just avoid the regression in thread support for linux-user ?
>>
>> I agree.
> 
> I was thinking something like a trivial qemu-tls.h which does
> 
> #ifdef __linux__
> #define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x)
> #define DEFINE_TLS(type, x)  __thread __typeof__(type) tls__##x
> #define get_tls(x)           tls__##x
> #else
> /* Dummy implementations -- we can get away with this because system
>  * mode is effectively single-threaded for our current limited use of
>  * TLS, and the only -user mode which supports multiple threads is
>  * linux-user.

We will use it in system mode as well, e.g. when I'll push away the
global lock from KVM entry/exits. So let's state that it is only
interesting on Linux hosts for now.

Otherwise, this looks good.

Jan

>  * TODO: proper implementations via Win32 .tls sections and
>  * POSIX pthread_getspecific.
>  */
> #define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x)
> #define DEFINE_TLS(type, x)  __typeof__(type) tls__##x
> #define get_tls(x)           tls__##x
> #endif
> 
> and then we can just use your "Make cpu_single_env thread-local"
> patch as-is:
> 
> http://git.linaro.org/gitweb?p=people/pmaydell/qemu-arm.git;a=commitdiff;h=b674559fc8a67ae7d30fe3ab3062d5855ac77d2d
> 
> (for that matter we could apply the "Prepare Windows port for
> thread-local cpu_single_env" patch too, but that's not a requirement.)
> 
> -- PMM

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux



reply via email to

[Prev in Thread] Current Thread [Next in Thread]