Re: [PATCH 2/2] iommu/ioasid: Remove custom IOASID allocator

From: Jason Gunthorpe
Date: Mon Feb 13 2023 - 18:45:55 EST


On Mon, Feb 13, 2023 at 03:43:45PM -0800, Jacob Pan wrote:
> Hi Jason,
>
> On Mon, 13 Feb 2023 19:18:51 -0400, Jason Gunthorpe <jgg@xxxxxxxxxx> wrote:
>
> > On Mon, Feb 13, 2023 at 01:44:02PM -0800, Jacob Pan wrote:
> > > > Your DMA API PASID thing will simply need one new API to alloc/free a
> > > > PASID from the iommu_global_pasid_ida
> > > It should satisfy what we need right now.
> > > Just wondering if we were to do resource management of global PASIDs,
> > > say with the new misc cgroup controller, do we plan to expand in iommu
> > > sva code? If yes, do we keep DMA API PASID in a separate range/set?
> >
> > I would say all shared PASIDs held by userspace should be captured by
> > by a resource limit, it doesn't matter if they are global PASIDs or
> > device local shared PASIDs.
> agreed, I was just thinking in-kernel DMA PASID is not held by userspace,
> might be good to keep them in separate pool, thus keeping ioasid_set.

Then you just don't charge a cgroup when you get these, you won't have
a cgroup anyhow in that context.

The "ioasid_set" is really the xarray, and you don't have an option to
use two xarrays with the same RID, so we definately wouldn't have two
pools.

> > So if a cgroup comes it is just a matter of putting charges in the
> > right place which is auditable by looking at calls to attach pasid
> > functions.
> shouldn't we charge cg during allocation? Or it might be too early for
> iommufd so we have to wait until attach?

We need to sort this all out. I would expect that iommufd will have an
allocation API.

Jason