Re: [RFC PATCH] iommu/iova: Add a best-fit algorithm

From: Christoph Hellwig
Date: Mon Feb 17 2020 - 03:03:41 EST


On Fri, Feb 14, 2020 at 03:06:42PM -0800, Isaac J. Manjarres wrote:
> From: Liam Mark <lmark@xxxxxxxxxxxxxx>
>
> Using the best-fit algorithm, instead of the first-fit
> algorithm, may reduce fragmentation when allocating
> IOVAs.

As we like to say in standards groups: may also implies may not.
Please provide numbers showing that this helps, and preferably and
explanation how it doesn't hurt as well.

> + * Should be called prior to using dma-apis.
> + */
> +int iommu_dma_enable_best_fit_algo(struct device *dev)
> +{
> + struct iommu_domain *domain;
> + struct iova_domain *iovad;
> +
> + domain = iommu_get_domain_for_dev(dev);
> + if (!domain || !domain->iova_cookie)
> + return -EINVAL;
>
> + iovad = &((struct iommu_dma_cookie *)domain->iova_cookie)->iovad;
> + iovad->best_fit = true;
> return 0;
> }
> +EXPORT_SYMBOL(iommu_dma_enable_best_fit_algo);

Who is going to call this? Patches adding exports always need a user
that goes along with the export. Also drivers have no business calling
directly into dma-iommu.