From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKIdi-0005qd-35 for qemu-devel@nongnu.org; Tue, 05 Jul 2016 01:11:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKIdd-0001i2-RP for qemu-devel@nongnu.org; Tue, 05 Jul 2016 01:11:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38028) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKIdd-0001hx-Md for qemu-devel@nongnu.org; Tue, 05 Jul 2016 01:11:13 -0400 Date: Tue, 5 Jul 2016 13:11:04 +0800 From: Peter Xu Message-ID: <20160705051104.GD3198@pxdev.xzpeter.org> References: <1466495274-5011-1-git-send-email-peterx@redhat.com> <1466495274-5011-3-git-send-email-peterx@redhat.com> <20160704181458-mutt-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160704181458-mutt-send-email-mst@redhat.com> Subject: Re: [Qemu-devel] [PATCH v10 02/26] x86-iommu: provide x86_iommu_get_default List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org, imammedo@redhat.com, rth@twiddle.net, ehabkost@redhat.com, jasowang@redhat.com, marcel@redhat.com, pbonzini@redhat.com, jan.kiszka@web.de, rkrcmar@redhat.com, alex.williamson@redhat.com, wexu@redhat.com, davidkiarie4@gmail.com On Mon, Jul 04, 2016 at 06:16:08PM +0300, Michael S. Tsirkin wrote: > On Tue, Jun 21, 2016 at 03:47:30PM +0800, Peter Xu wrote: > > Instead of searching the device tree every time, one static variable is > > declared for the default system x86 IOMMU device. Also, some VT-d > > macros are replaced by x86 ones. > > > > Signed-off-by: Peter Xu > > I think it's cleaner to just use object_resolve_path_type > with the X86 type. Error handling by exit is rather ugly, too: > if we need a singleton type, let's add one and have > generic code detect such errors. I did a quick measurement on the old path resolving method, it's consuming >60us every time just to fetch the default IOMMU object (on my laptop, i7-4810MQ CPU @ 2.80GHz). Do you think it'll be better if we can avoid that? Currently there is no critical path that is using this get_default(), only by IEC notifiers. However that will still take some extra time during boot, or when the notifiers are triggered. I agree that we should better provide a more general interface for singleton semantic. But do you think it's okay I send another patch to do that after this series merged? Since I may need some more time reading the codes and IIUC it'll possibly be a very standalone patch related to QOM, and another patch to just let X86 IOMMU be the first user. Thanks, -- peterx