From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1UsaKk-0004fA-AL for mharc-qemu-trivial@gnu.org; Fri, 28 Jun 2013 11:11:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsaKh-0004dK-1s for qemu-trivial@nongnu.org; Fri, 28 Jun 2013 11:11:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UsaKf-0004kM-Mz for qemu-trivial@nongnu.org; Fri, 28 Jun 2013 11:11:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35625) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsaKf-0004kH-EL; Fri, 28 Jun 2013 11:11:29 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5SFBQs5018882 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 28 Jun 2013 11:11:26 -0400 Received: from yakj.usersys.redhat.com (ovpn-112-50.ams2.redhat.com [10.36.112.50]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r5SFBMZV014878; Fri, 28 Jun 2013 11:11:23 -0400 Message-ID: <51CDA797.9000803@redhat.com> Date: Fri, 28 Jun 2013 17:11:19 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6 MIME-Version: 1.0 To: Peter Maydell 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: X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-trivial@nongnu.org, Michael Tokarev , qemu-devel Subject: Re: [Qemu-trivial] [PATCH] tls.h: Enable TLS on FreeBSD X-BeenThere: qemu-trivial@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jun 2013 15:11:32 -0000 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 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