From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Williamson Subject: Re: [RFC v2 2/5] vfio/type1: Check reserve region conflict and update iova list Date: Fri, 19 Jan 2018 08:45:34 -0700 Message-ID: <20180119084534.4b0fbee1@w520.home> References: <20180112164531.93712-1-shameerali.kolothum.thodi@huawei.com> <20180112164531.93712-3-shameerali.kolothum.thodi@huawei.com> <20180117170439.34236b47@w520.home> <5FC3163CFD30C246ABAA99954A238FA83863BC04@FRAEML521-MBX.china.huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: "eric.auger@redhat.com" , "pmorel@linux.vnet.ibm.com" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Linuxarm , John Garry , "xuwei (O)" To: Shameerali Kolothum Thodi Return-path: Received: from mx1.redhat.com ([209.132.183.28]:41474 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755654AbeASPpi (ORCPT ); Fri, 19 Jan 2018 10:45:38 -0500 In-Reply-To: <5FC3163CFD30C246ABAA99954A238FA83863BC04@FRAEML521-MBX.china.huawei.com> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, 19 Jan 2018 09:48:22 +0000 Shameerali Kolothum Thodi wrote: > > > +static void vfio_iommu_iova_resv_refresh(struct vfio_iommu *iommu) > > > +{ > > > + struct vfio_domain *d; > > > + struct vfio_group *g; > > > + struct vfio_iova *node, *tmp; > > > + struct iommu_resv_region *resv, *resv_next; > > > + struct list_head resv_regions; > > > + phys_addr_t start, end; > > > + > > > + INIT_LIST_HEAD(&resv_regions); > > > + > > > + list_for_each_entry(d, &iommu->domain_list, next) { > > > + list_for_each_entry(g, &d->group_list, next) > > > + iommu_get_group_resv_regions(g->iommu_group, > > > + &resv_regions); > > > + } > > > + > > > + if (list_empty(&resv_regions)) > > > + return; > > > + > > > + list_sort(NULL, &resv_regions, vfio_resv_cmp); > > > + > > > + node = list_first_entry(&iommu->iova_list, struct vfio_iova, list); > > > + start = node->start; > > > + node = list_last_entry(&iommu->iova_list, struct vfio_iova, list); > > > + end = node->end; > > > > list_sort() only sorts based on ->start, we added reserved regions for > > all our groups to one list, we potentially have multiple entries with > > the same ->start. How can we be sure that the last one in the list > > actually has the largest ->end value? > > Hmm.. the sorting is done on the reserved list. The start and end entries > are of the iova list which is kept updated on _attach(). So I don't think > there is a problem here. Oops, yes you're right. List confusion. Thanks, Alex