From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UbrGa-000758-4b for qemu-devel@nongnu.org; Mon, 13 May 2013 07:50:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UbrGV-0001rq-9Y for qemu-devel@nongnu.org; Mon, 13 May 2013 07:50:08 -0400 Received: from ozlabs.org ([203.10.76.45]:57369) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UbrGU-0001ns-U6 for qemu-devel@nongnu.org; Mon, 13 May 2013 07:50:03 -0400 Date: Mon, 13 May 2013 21:48:17 +1000 From: David Gibson Message-ID: <20130513114817.GB14944@truffula.fritz.box> References: <1368442465-14363-1-git-send-email-david@gibson.dropbear.id.au> <1368442465-14363-7-git-send-email-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IrhDeMKUP4DT/M7F" Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH 6/8] memory: Sanity check that no listeners remain on a destroyed AddressSpace List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: mst@redhat.com, aik@ozlabs.ru, qemu-devel@nongnu.org, agraf@suse.de, alex.williamson@redhat.com, pbonzini@redhat.com --IrhDeMKUP4DT/M7F Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, May 13, 2013 at 12:10:10PM +0100, Peter Maydell wrote: > On 13 May 2013 11:54, David Gibson wrote: > > At the moment, most AddressSpace objects last as long as the guest syst= em > > in practice, but that could well change in future. In addition, for VF= IO > > we will be introducing some private per-AdressSpace information, which = must > > 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. >=20 > Hmm, is this the ideal semantics? Typically the owner of the > MemoryListener isn't the owner of the AddressSpace so it isn't > necessarily in a position to guarantee that it can unregister > the listener before the address space is destroyed. In fact > as the listener API is currently documented, the filter > argument is just an optimisation to save the callbacks having > to filter out irrelevant information themselves. If so, then it's broken by design. There's no guarantee that after an AddressSpace is destroyed another one won't be created at the same address (in fact, depending on your malloc() implementation, it could be very likely). So references by pointer to an object *must* be removed before the object itself is freed. > Perhaps an "address space being destroyed" callback for > listeners would be better? Then VFIO could just do the > necessary disposal operations automatically when the AS > goes away. I was originally going to do that instead, but none of the things I have planned immediately need it, since I think other lifetime constraints will sort things out (chiefly that PCI devices must be removed before their host bridge can, which will control the AddressSpace lifetime). This patch is so that if I'm wrong about that, it will show up clearly, at which point we can implement such a callback. --=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 --IrhDeMKUP4DT/M7F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlGQ0wEACgkQaILKxv3ab8ZovwCffYqowPWR47kYjJxvmncpCIjx rOkAn39BBQMw0nsWLMEusKathCKWun27 =4Got -----END PGP SIGNATURE----- --IrhDeMKUP4DT/M7F--