[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200403123951.GA1410438@myrica>
Date: Fri, 3 Apr 2020 14:39:51 +0200
From: Jean-Philippe Brucker <jean-philippe@...aro.org>
To: "Liu, Yi L" <yi.l.liu@...el.com>
Cc: "alex.williamson@...hat.com" <alex.williamson@...hat.com>,
"eric.auger@...hat.com" <eric.auger@...hat.com>,
"Tian, Kevin" <kevin.tian@...el.com>,
"jacob.jun.pan@...ux.intel.com" <jacob.jun.pan@...ux.intel.com>,
"joro@...tes.org" <joro@...tes.org>,
"Raj, Ashok" <ashok.raj@...el.com>,
"Tian, Jun J" <jun.j.tian@...el.com>,
"Sun, Yi Y" <yi.y.sun@...el.com>,
"peterx@...hat.com" <peterx@...hat.com>,
"iommu@...ts.linux-foundation.org" <iommu@...ts.linux-foundation.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Wu, Hao" <hao.wu@...el.com>
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?
Thanks,
Jean
>
> > > + VFIO_DEFAULT_PASID_QUOTA, &vmm->ioasid_sid);
> > > + if (ret) {
> > > + kfree(vmm);
> > > + return ERR_PTR(ret);
> > > + }
> > > +
> > > + kref_init(&vmm->kref);
> > > + token = &vmm->token;
> > > + token->val = mm;
> >
> > Why the intermediate token struct? Could we just store the mm_struct
> > pointer within vfio_mm?
>
> Hmm, here we only want to use the pointer as a token, instead of using
> the structure behind the pointer. If store the mm_struct directly, may
> leave a space to further use its content, this is not good.
>
> Regards,
> Yi Liu
>
Powered by blists - more mailing lists