From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=51863 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhdV3-0006AD-6M for qemu-devel@nongnu.org; Tue, 25 Jan 2011 02:39:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PhdV2-0005Nr-3r for qemu-devel@nongnu.org; Tue, 25 Jan 2011 02:39:37 -0500 Received: from fmmailgate03.web.de ([217.72.192.234]:44502) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PhdV1-0005NK-OM for qemu-devel@nongnu.org; Tue, 25 Jan 2011 02:39:36 -0500 Message-ID: <4D3E7E15.8070806@web.de> Date: Tue, 25 Jan 2011 08:39:01 +0100 From: Jan Kiszka MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [PATCH 4/7] Get rid of QemuMutex and teach its callers about GStaticMutex References: <1295902845-29807-1-git-send-email-aliguori@us.ibm.com> <1295902845-29807-5-git-send-email-aliguori@us.ibm.com> <4D3DFC28.4000408@web.de> <4D3E130B.3000902@codemonkey.ws> In-Reply-To: <4D3E130B.3000902@codemonkey.ws> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigAF7AD3F6F936FB244EC95B2E" Sender: jan.kiszka@web.de List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Stefan Hajnoczi , Marcelo Tosatti , qemu-devel@nongnu.org, Paul Brook , Paulo Bonzini , Arun Bharadwaj This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigAF7AD3F6F936FB244EC95B2E Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 2011-01-25 01:02, Anthony Liguori wrote: > On 01/24/2011 04:24 PM, Jan Kiszka wrote: >> On 2011-01-24 22:00, Anthony Liguori wrote: >> =20 >>> Signed-off-by: Anthony Liguori >>> >>> diff --git a/cpus.c b/cpus.c >>> index 9cf7e6e..0f8e33b 100644 >>> --- a/cpus.c >>> +++ b/cpus.c >>> @@ -321,8 +321,8 @@ void vm_stop(int reason) >>> >>> #include "qemu-thread.h" >>> >>> -QemuMutex qemu_global_mutex; >>> -static QemuMutex qemu_fair_mutex; >>> +GStaticMutex qemu_global_mutex; >>> +static GStaticMutex qemu_fair_mutex; >>> >>> static QemuThread io_thread; >>> >>> @@ -416,9 +416,9 @@ int qemu_init_main_loop(void) >>> qemu_cond_init(&qemu_system_cond); >>> qemu_cond_init(&qemu_pause_cond); >>> qemu_cond_init(&qemu_work_cond); >>> - qemu_mutex_init(&qemu_fair_mutex); >>> - qemu_mutex_init(&qemu_global_mutex); >>> - qemu_mutex_lock(&qemu_global_mutex); >>> + g_static_mutex_init(&qemu_fair_mutex); >>> + g_static_mutex_init(&qemu_global_mutex); >>> + g_static_mutex_lock(&qemu_global_mutex); >>> >>> =20 >> Just replacing our own abstraction with glib's looks like a step in th= e >> wrong direction. From a first glance at that library and its semantics= >> it has at least two major drawbacks: >> >> - Error handling of things like g_mutex_lock or g_cond_wait is, well= , >> very "simplistic". Once we start to use more sophisticated locking= , >> more bugs will occur here, and we will need more support than glib= is >> able to provide (or can you control error handling elsewhere?). >> >> - GMutex is not powerful enough for optional things like PI mutexes = - >> which is required once we want to schedule parts of qemu with RT >> priorities (I did it, it works surprisingly well). >> =20 >=20 > One of the nice design characteristics of glib/gobject/gtk is that it > cohabitates well with other APIs. >=20 > Nothing stops you from using pthread mutex directly if you really need > to. It makes you less portable, but sometimes it's a price that has to= > be paid for functionality. I'm not talking about adding new PI mutexes, I'm talking about effectively reverting this patch as I need to initializes the existing ones with PI enabled in the attributes. Or replacing g_mutex_* with wrappers again to add real error handling. Really, glib is too primitive here. Jan --------------enigAF7AD3F6F936FB244EC95B2E 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/ iEYEARECAAYFAk0+fhUACgkQitSsb3rl5xRg/gCgw5GjWwzhiR+jhhDoljCzeLIW oFIAn2O+BCpxBmj2Vf2GoGUrlX6/IR0h =6lWq -----END PGP SIGNATURE----- --------------enigAF7AD3F6F936FB244EC95B2E--