From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: Role of qemu_fair_mutex Date: Mon, 03 Jan 2011 11:03:50 +0100 Message-ID: <4D219F06.7040305@web.de> References: <4D219AF5.2030204@web.de> <4D219E6D.8060902@redhat.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig68BB5C1A8F1F848DA4B75CEC" Cc: qemu-devel , kvm , Marcelo Tosatti To: Avi Kivity Return-path: Received: from fmmailgate03.web.de ([217.72.192.234]:37876 "EHLO fmmailgate03.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751426Ab1ACKDw (ORCPT ); Mon, 3 Jan 2011 05:03:52 -0500 In-Reply-To: <4D219E6D.8060902@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig68BB5C1A8F1F848DA4B75CEC Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Am 03.01.2011 11:01, Avi Kivity wrote: > On 01/03/2011 11:46 AM, Jan Kiszka wrote: >> Hi, >> >> at least in kvm mode, the qemu_fair_mutex seems to have lost its >> function of balancing qemu_global_mutex access between the io-thread a= nd >> vcpus. It's now only taken by the latter, isn't it? >> >> This and the fact that qemu-kvm does not use this kind of lock made me= >> wonder what its role is and if it is still relevant in practice. I'd >> like to unify the execution models of qemu-kvm and qemu, and this lock= >> is the most obvious difference (there are surely more subtle ones as >> well...). >> >=20 > IIRC it was used for tcg, which has a problem that kvm doesn't have: a > tcg vcpu needs to hold qemu_mutex when it runs, which means there will > always be contention on qemu_mutex. In the absence of fairness, the tc= g > thread could dominate qemu_mutex and starve the iothread. >=20 > This doesn't happen with kvm since kvm vcpus drop qemu_mutex when runni= ng. >=20 I see. Then I guess we should do this: diff --git a/cpus.c b/cpus.c index 9bf5224..0de8552 100644 --- a/cpus.c +++ b/cpus.c @@ -734,9 +734,7 @@ static sigset_t block_io_signals(void) void qemu_mutex_lock_iothread(void) { if (kvm_enabled()) { - qemu_mutex_lock(&qemu_fair_mutex); qemu_mutex_lock(&qemu_global_mutex); - qemu_mutex_unlock(&qemu_fair_mutex); } else { qemu_mutex_lock(&qemu_fair_mutex); if (qemu_mutex_trylock(&qemu_global_mutex)) { Jan --------------enig68BB5C1A8F1F848DA4B75CEC 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.15 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iEYEARECAAYFAk0hnwYACgkQitSsb3rl5xShnQCfWBaHsYQbXU+DamanEgnZTRs3 fBwAnAv4aAqog1wj1vc95ShA2AOQWxbJ =lUtm -----END PGP SIGNATURE----- --------------enig68BB5C1A8F1F848DA4B75CEC--