Received: from eggs.gnu.org ([2001:4830:134:3::10]:39726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhaUz-0003eV-Rx for qemu-devel@nongnu.org; Wed, 07 Sep 2016 06:54:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhaUv-0001UO-Nd for qemu-devel@nongnu.org; Wed, 07 Sep 2016 06:54:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53062) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhaUv-0001UI-IH for qemu-devel@nongnu.org; Wed, 07 Sep 2016 06:54:29 -0400 References: <1473226344-28520-1-git-send-email-peterx@redhat.com> <1473226344-28520-3-git-send-email-peterx@redhat.com> <20160907060550.GQ2780@voom.fritz.box> From: Paolo Bonzini Message-ID: Date: Wed, 7 Sep 2016 12:54:23 +0200 MIME-Version: 1.0 In-Reply-To: <20160907060550.GQ2780@voom.fritz.box> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 2/3] memory: generalize iommu_ops.notify_started to notifier_add List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson , Peter Xu Cc: qemu-devel@nongnu.org, mst@redhat.com, jasowang@redhat.com, vkaplans@redhat.com, alex.williamson@redhat.com, wexu@redhat.com, cornelia.huck@de.ibm.com, dgibson@redhat.com On 07/09/2016 08:05, David Gibson wrote: > On Wed, Sep 07, 2016 at 01:32:23PM +0800, Peter Xu wrote: >> Considering that we may have multiple IOMMU notifier consumers in the >> future, converting iommu_ops.notify_{started|stopped} into some more >> general form. Now we can trap all notifier registerations and >> deregistrations, rather than only the first ones. >> >> Power was leveraging the notifier_{started|stopped}, adding iommu_user >> field for counting on Power guests to achieve the same goal. >=20 > Requiring each vIOMMU frontend to reference count or whatever seems > like a pain. The semantics of notify_started() were designed to avoid > that. >=20 > Instead I'd suggest a callback which gets tripped any time the logical > OR of the requested notifications for all current notifiers changes. I like the suggestion. Alternatively you could call notify_stopped if old & ~new is nonzero (and you pass old & ~new), and notify_started if new & ~old is nonzero (and you pass new & ~old). Paolo