Re: [PATCH 03/26] iommu/vt-d: Split up iommu->domains array

From: Joerg Roedel
Date: Fri Aug 07 2015 - 07:12:01 EST


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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/