From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQbfI-0005Ka-Nx for qemu-devel@nongnu.org; Thu, 20 Mar 2014 08:01:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQbfE-0006DK-OR for qemu-devel@nongnu.org; Thu, 20 Mar 2014 08:01:40 -0400 Date: Thu, 20 Mar 2014 22:45:29 +1100 From: David Gibson Message-ID: <20140320114529.GA1335@voom.fritz.box> References: <1394603550-11556-1-git-send-email-aik@ozlabs.ru> <1394603550-11556-2-git-send-email-aik@ozlabs.ru> <532AC0D9.1050304@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="UlVJffcvxoiEqYs2" Content-Disposition: inline In-Reply-To: <532AC0D9.1050304@redhat.com> Subject: Re: [Qemu-devel] [PATCH v5 01/11] memory: Sanity check that no listeners remain on a destroyed AddressSpace List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Alexey Kardashevskiy , Alex Williamson , qemu-ppc@nongnu.org, Alexander Graf , qemu-devel@nongnu.org --UlVJffcvxoiEqYs2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Mar 20, 2014 at 11:20:09AM +0100, Paolo Bonzini wrote: > Il 12/03/2014 06:52, Alexey Kardashevskiy ha scritto: > >From: David Gibson > > > >At the moment, most AddressSpace objects last as long as the guest system > >in practice, but that could well change in future. In addition, for VFIO > >we will be introducing some private per-AdressSpace information, which m= ust > >be disposed of before the AddressSpace itself is destroyed. > > > >To reduce the chances of subtle bugs in this area, this patch adds > >asssertions to ensure that when an AddressSpace is destroyed, there are = no > >remaining MemoryListeners using that AS as a filter. > > > >Signed-off-by: David Gibson > >Signed-off-by: Alexey Kardashevskiy > >--- > > memory.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > >diff --git a/memory.c b/memory.c > >index 3f1df23..678661e 100644 > >--- a/memory.c > >+++ b/memory.c > >@@ -1722,12 +1722,19 @@ void address_space_init(AddressSpace *as, Memory= Region *root, const char *name) > > > > void address_space_destroy(AddressSpace *as) > > { > >+ MemoryListener *listener; > >+ > > /* Flush out anything from MemoryListeners listening in on this */ > > memory_region_transaction_begin(); > > as->root =3D NULL; > > memory_region_transaction_commit(); > > QTAILQ_REMOVE(&address_spaces, as, address_spaces_link); > > address_space_destroy_dispatch(as); > >+ > >+ QTAILQ_FOREACH(listener, &memory_listeners, link) { > >+ assert(listener->address_space_filter !=3D as); > >+ } > >+ > > flatview_unref(as->current_map); > > g_free(as->name); > > g_free(as->ioeventfds); > > >=20 > Reviewed-by: Paolo Bonzini >=20 > An alternative is to add a count of listeners to the address space > and assert that it is 0. Address space destruction should be pretty rare, so I don't think it's worth the bother of adding a count, which just adds the possibility of bugs updating it. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --UlVJffcvxoiEqYs2 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJTKtTZAAoJEGw4ysog2bOS6IMP/iTuSgyqXz6Paki8OlUGfbRT jYXLhZJ7Tcvfk+OV4ZSRXAUyfwrD/SxgcnQd3lCkt9ugdMOI9V+cyvzgY2zxjtEw hCyGCzmLBYKTM2VjJeY4QNoSEf+YGNCF+qYnGoJdraa9+99+ubBARuRnvpMcubTS OxpLeJTgCaSOLQBpGAdcf9URc5gMLh23VnSbD3yEBdU7MgjmoCwazq5qPXP8dO9Y sZ0nqC9sUrS+ZOmY7GzI1jo3TYdkN2uFxhWXTFkKBRTH4odLi1f39IJRNmrdczXh tNugnmgfr8GM2C1Pquplu8nmo15JjclC8FJ0zv4GlczHCpgod24TGgWBIyKm6lUZ MYaF5qU9wP50vNy8rHEx/55GwDTM5nhxlMWNmTDOTrFUYLHvZu3ZrJUOmOVF9Rhb p7hv2a8jW8OtIGrlqmsyypPN+z0iAMWgDelxkQNWDvJ+vH5C+Pr3eyySblIOJ2wd TCJJ9vrzWmQoT2tcBLdYO9R7FV2c1AGDpBwWJ1kiS2x6hcf5P5GFU1fKgPfaf56M OPBG2AWSRUY1juV9a8y6SISGYEi8MJT6iVIdJrU60IJoBgCuk9VHOzYtXBNL7Ngy uqAed28bMgEY5zzk7AsU5b2W/s3KbMZf7uMmWl0oCX//7WorVrYVpSEFRGaKXOzW LRPzia80JEnO1FLXuUSF =zRR9 -----END PGP SIGNATURE----- --UlVJffcvxoiEqYs2--