Re: [PATCH 04/10] vfio: Use a struct of function pointers instead of a many symbol_get()'s

Jason Gunthorpe
2022-04-15T12:13:19Z

On Fri, Apr 15, 2022 at 06:45:34AM +0200, Christoph Hellwig wrote:
> On Thu, Apr 14, 2022 at 03:46:03PM -0300, Jason Gunthorpe wrote:
> > kvm and VFIO need to be coupled together however neither is willing to
> > tolerate a direct module dependency. Instead when kvm is given a VFIO FD
> > it uses many symbol_get()'s to access VFIO.
> >
> > Provide a single VFIO function vfio_file_get_ops() which validates the
> > given struct file * is a VFIO file and then returns a struct of ops.
> >
> > Following patches will redo each of the symbol_get() calls into an
> > indirection through this ops struct.
>
> So I got anoyed at this as well a while ago and I still think this
> is the wrong way around.

What I plan to do in future is to have differnt ops returned depending
on if the file is a struct vfio_group or a struct vfio_device, so it
is not entirely pointless like this.

> I'd much rather EXPORT_SYMBOL_GPL kvm_register_device_ops and
> just let kvm_vfio_ops live in a module than all the symbol_get
> crazyness. We'll need to be careful to deal with unload races
> or just not allow unloading, though.

This is certainly more complicated - especially considering module
unload - than a single symbol_get(). How do you see the benefit?

Jason