> From: Jean-Philippe Brucker <jean-philippe@xxxxxxxxxx> > Sent: Friday, April 3, 2020 8:40 PM > Subject: Re: [PATCH v1 1/8] vfio: Add VFIO_IOMMU_PASID_REQUEST(alloc/free) > > On Fri, Apr 03, 2020 at 11:56:09AM +0000, Liu, Yi L wrote: > > > > /** > > > > + * VFIO_MM objects - create, release, get, put, search > > > > + * Caller of the function should have held vfio.vfio_mm_lock. > > > > + */ > > > > +static struct vfio_mm *vfio_create_mm(struct mm_struct *mm) { > > > > + struct vfio_mm *vmm; > > > > + struct vfio_mm_token *token; > > > > + int ret = 0; > > > > + > > > > + vmm = kzalloc(sizeof(*vmm), GFP_KERNEL); > > > > + if (!vmm) > > > > + return ERR_PTR(-ENOMEM); > > > > + > > > > + /* Per mm IOASID set used for quota control and group operations */ > > > > + ret = ioasid_alloc_set((struct ioasid_set *) mm, > > > > > > Hmm, either we need to change the token of ioasid_alloc_set() to > > > "void *", or pass an actual ioasid_set struct, but this cast doesn't > > > look good :) > > > > > > As I commented on the IOASID series, I think we could embed a struct > > > ioasid_set into vfio_mm, pass that struct to all other ioasid_* > > > functions, and get rid of ioasid_sid. > > > > I think change to "void *" is better as we needs the token to ensure > > all threads within a single VM share the same ioasid_set. > > Don't they share the same vfio_mm? that's right. then both works well for me. Regards, Yi Liu