On Thu, Aug 06, 2015 at 01:20:09PM -0600, Alex Williamson wrote: > On Wed, 2015-08-05 at 17:18 +0200, Joerg Roedel wrote: > > static void set_iommu_domain(struct intel_iommu *iommu, u16 did, > > struct dmar_domain *domain) > > { > > - iommu->domains[did] = domain; > > + struct dmar_domain **domains; > > + int idx = did >> 8; > > + > > + if (!iommu->domains[idx]) { > > + size_t size = 256 * sizeof(struct dmar_domain *); > > + iommu->domains[idx] = kzalloc(size, GFP_ATOMIC); > > + } > > + > > + domains = iommu->domains[idx]; > > + if (WARN_ON(!domains)) > > + return; > > + else > > + domains[did & 0xff] = domain; > > } > > I'm tempted to suggest using pages here since we're dealing with 2k > second level arrays, but maybe caring about pointers per page just makes > that ugly.
The benefit would be that we avoid the slab-overhead while allocating. But since the VT-d driver is needed on platforms with different page-sizes, the handling would be indeed more complicated because we have to split the index at a different point then depending on the architecture. Joerg _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu