From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsaKj-0004ef-Vo for qemu-devel@nongnu.org; Fri, 28 Jun 2013 11:11:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UsaKi-0004kg-Fc for qemu-devel@nongnu.org; Fri, 28 Jun 2013 11:11:33 -0400 Message-ID: <51CDA797.9000803@redhat.com> Date: Fri, 28 Jun 2013 17:11:19 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1372101677-46175-1-git-send-email-emaste@freebsd.org> <51CD669A.1010100@msgid.tls.msk.ru> <51CD8985.6020401@redhat.com> <51CDA1E7.9000100@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH] tls.h: Enable TLS on FreeBSD List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-trivial@nongnu.org, Ed Maste , Michael Tokarev , qemu-devel Il 28/06/2013 16:55, Peter Maydell ha scritto: >>> >> I don't understand what you mean by "no need for it". We are >>> >> already multithreaded in system mode, so this is simply >>> >> making FreeBSD do the same thing as Linux. >> > >> > cpu_single_env is protected by the BQL unless you're running on KVM. > That doesn't make it magically not a per-thread variable. If it were possible to say "make cpu_single_env magically not per-thread on Linux/TCG", I'd be all for it! But I _can_ make cpu_single_env not per-thread on FreeBSD/TCG, because no one needs per-thread cpu_single_env on FreeBSD. If we could drop support for platforms that lack __thread (or some other fast TLS mechanism), then it would be another story of course. We would not have to do things like this for qtest: while (1) { cpu_single_env = NULL; qemu_mutex_unlock_iothread(); do { int sig; r = sigwait(&waitset, &sig); } while (r == -1 && (errno == EAGAIN || errno == EINTR)); if (r == -1) { perror("sigwait"); exit(1); } qemu_mutex_lock_iothread(); cpu_single_env = env; qemu_wait_io_event_common(cpu); } or similarly set cpu_single_env in cpu_exec. And of course if bsd-user supported 1:1 mapping between guest and host threads on FreeBSD, cpu_single_env would have to be thread-local. Paolo