From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:55949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwCHD-0005QQ-9m for qemu-devel@nongnu.org; Sat, 11 Feb 2012 07:42:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RwCHC-0002hq-3u for qemu-devel@nongnu.org; Sat, 11 Feb 2012 07:42:03 -0500 Received: from fmmailgate03.web.de ([217.72.192.234]:49041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwCHB-0002hl-MO for qemu-devel@nongnu.org; Sat, 11 Feb 2012 07:42:02 -0500 Received: from moweb002.kundenserver.de (moweb002.kundenserver.de [172.19.20.108]) by fmmailgate03.web.de (Postfix) with ESMTP id F387F1B1007D1 for ; Sat, 11 Feb 2012 13:41:51 +0100 (CET) Message-ID: <4F36620C.2030405@web.de> Date: Sat, 11 Feb 2012 13:41:48 +0100 From: Jan Kiszka MIME-Version: 1.0 References: <4F363DB2.3080908@web.de> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig55FDEC849991C32CACA6B84F" Subject: Re: [Qemu-devel] [PATCH v2 1/8] kvm: Set cpu_single_env only once List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: Anthony Liguori , kvm@vger.kernel.org, Gleb Natapov , Marcelo Tosatti , qemu-devel , Avi Kivity This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig55FDEC849991C32CACA6B84F Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 2012-02-11 12:25, Blue Swirl wrote: > On Sat, Feb 11, 2012 at 10:06, Jan Kiszka wrote: >> On 2012-02-11 11:02, Blue Swirl wrote: >>> On Fri, Feb 10, 2012 at 18:31, Jan Kiszka wr= ote: >>>> As we have thread-local cpu_single_env now and KVM uses exactly one >>>> thread per VCPU, we can drop the cpu_single_env updates from the loo= p >>>> and initialize this variable only once during setup. >>> >>> I don't think this is correct. Maybe you missed the part that sets >>> cpu_single_env to NULL, which I think is to annoy broken code that >>> assumes that some CPU state is always globally available. This is not= >>> true for monitor context. >> >> I did check this before changing, and I see no such need. Particularly= >> as this old debugging help prevents valid use case. >=20 > It looks like monitor code is safe now. But in several places there > are checks like this in pc.c: > DeviceState *cpu_get_current_apic(void) > { > if (cpu_single_env) { > return cpu_single_env->apic_state; > } else { > return NULL; > } > } >=20 > In cpu-exec.c, there are these lines: > /* fail safe : never use cpu_single_env outside cpu_exec() */ > cpu_single_env =3D NULL; That's legacy stuff from the pre-io-thread times. Nowadays, cpu_single_env is logically either always valid (KVM) or switching seamlessly between the VCPUs (TCG). >=20 > I think using cpu_single_env is an indication of a problem, like poor > code, layering violation or poor API (vmport). What is your use case? We have a few poor ABIs like the VMware stuff or the KVM VAPIC, so we have to live with it already for that use cases. Moreover, cpus.c use it internally, like for vm_stop, to find out the caller context. Jan --------------enig55FDEC849991C32CACA6B84F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk82Yg0ACgkQitSsb3rl5xT8wQCghbhOM0gT2PYQjGCUFrGpnYBy V80AnRuGpJ1nHaMquw4PZIeYh2WFApA0 =dDrL -----END PGP SIGNATURE----- --------------enig55FDEC849991C32CACA6B84F--