On 4/24/25 18:26, John Levon wrote:
On Thu, Apr 24, 2025 at 06:08:21PM +0200, Cédric Le Goater wrote:
On 4/9/25 15:48, John Levon wrote:
Instead of requesting region information on demand with
VFIO_DEVICE_GET_REGION_INFO, maintain a cache: this will become
necessary for performance for vfio-user, where this call becomes a
message over the control socket, so is of higher overhead than the
traditional path.
We will also need it to generalize region accesses, as that means we
can't use ->config_offset for configuration space accesses, but must
look up the region offset (if relevant) each time.
This change is an optimization for vfio-user. I would prefer to keep it
for after enabling vfio-user.
It's not vfio-user specific. Just to clarify, you want this code:
static int vfio_io_region_write(VFIODevice *vbasedev, uint8_t index, off_t
off,
uint32_t size, void *data, bool post)
{
struct vfio_region_info *info = vbasedev->regions[index];
int ret;
ret = pwrite(vbasedev->fd, data, size, info->offset + off);
return ret < 0 ? -errno : ret;
}
to become:
static int vfio_io_region_write(VFIODevice *vbasedev, uint8_t index, off_t
off,
uint32_t size, void *data, bool post)
{
struct vfio_region_info info;
ioctl(vbasedev->fd, VFIO_DEVICE_GET_IRQ_INFO, &info);
> struct vfio_region_info *info = vbasedev->regions[index];
int ret;
ret = pwrite(vbasedev->fd, data, size, info->offset + off);
return ret < 0 ? -errno : ret;
}
i.e. every region read/write needs to look up info each time?
Oh I didn't this. So the introduction VFIODeviceIOOps is not seamless.
If not, what are you suggesting?
vfio_device_io_region_read and vfio_device_io_region_write should come
separately in patch 13.
Let me comment more this patch.
Thanks,
C.