From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBoAU-0007XI-Cb for qemu-devel@nongnu.org; Tue, 29 Nov 2016 14:34:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBoAT-0002Bq-E0 for qemu-devel@nongnu.org; Tue, 29 Nov 2016 14:34:18 -0500 References: <20161129114707.2975-1-pbonzini@redhat.com> <20161129114707.2975-3-pbonzini@redhat.com> From: Eric Blake Message-ID: <3990851f-bfd7-d310-225f-1b474ffbcfb4@redhat.com> Date: Tue, 29 Nov 2016 13:34:07 -0600 MIME-Version: 1.0 In-Reply-To: <20161129114707.2975-3-pbonzini@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jR43LSIqFAF2LehrrloRJaHiULqGaEkhb" Subject: Re: [Qemu-devel] [PATCH 02/10] qemu-thread: introduce QemuLockCnt List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: qemu-block@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jR43LSIqFAF2LehrrloRJaHiULqGaEkhb From: Eric Blake To: Paolo Bonzini , qemu-devel@nongnu.org Cc: qemu-block@nongnu.org Message-ID: <3990851f-bfd7-d310-225f-1b474ffbcfb4@redhat.com> Subject: Re: [Qemu-devel] [PATCH 02/10] qemu-thread: introduce QemuLockCnt References: <20161129114707.2975-1-pbonzini@redhat.com> <20161129114707.2975-3-pbonzini@redhat.com> In-Reply-To: <20161129114707.2975-3-pbonzini@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/29/2016 05:46 AM, Paolo Bonzini wrote: > A QemuLockCnt comprises a counter and a mutex, with primitives > to increment and decrement the counter, and to take and release the > mutex. It can be used to do lock-free visits to a data structure > whenever mutexes would be too heavy-weight and the critical section > is too long for RCU. >=20 > This could be implemented simply by protecting the counter with the > mutex, but QemuLockCnt is harder to misuse and more efficient. >=20 > Signed-off-by: Paolo Bonzini > --- > + int qemu_lockcnt_count(QemuLockCnt *lockcnt); > + > + Return the lockcnt's count. The count can change at any time > + any time; still, while the lockcnt is locked, one can usefully= duplicate 'any time' > +++ b/util/lockcnt.c > @@ -0,0 +1,113 @@ > +/* > + * QemuLockCnt implementation > + * > + * Copyright Red Hat, Inc. 2015 You've been sitting on this a while :) Want to add 2016? The documentation is a huge help to understanding the code; overall it looks pretty clean. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --jR43LSIqFAF2LehrrloRJaHiULqGaEkhb 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJYPdgvAAoJEKeha0olJ0NqBgkIAKUKc01waLU4Gm4BuSnO6fMv vkHyoBKGqG1gKMWlOMGy0DpJmvtcOdpXCN3BvwDKbNMFyvTkJnQhlvE2egoGfPAk GTGYp4vlSXyEen3VxDPYtFWInded0n+jeSklQzNf6HTcUpavqCRCE2Hp7rsqgFq/ /T3iOMtURGfVvbwVjcBhssL3M/UrI3+o3Us53chUPp9QxQOUsiOP9CyZIKINOyAj tWxXaditat3PTJACQLnx2Dw+i1ls6mfieXfOa/eOvFg2gdgkttqwsb6RrIx3UTpT y+4DHpZJ7rSTNf6SV3TsHMI7mGBIldelmtEgWcwx2h6lGQglPSNP0ddjM+kys1Q= =8KB2 -----END PGP SIGNATURE----- --jR43LSIqFAF2LehrrloRJaHiULqGaEkhb--