On 4/3/25 18:00, John Levon wrote:
On Thu, Apr 03, 2025 at 05:46:03PM +0200, Cédric Le Goater wrote:

+static void vfio_get_all_regions(VFIODevice *vbasedev)
+{
+    struct vfio_region_info *info;
+    int i;
+
+    for (i = 0; i < vbasedev->num_regions; i++) {
+        vfio_get_region_info(vbasedev, i, &info);
+    }
+}
+
   void vfio_prepare_device(VFIODevice *vbasedev, VFIOContainerBase *bcontainer,
                            VFIOGroup *group, struct vfio_device_info *info)
   {
@@ -1586,6 +1596,8 @@ void vfio_prepare_device(VFIODevice *vbasedev, 
VFIOContainerBase *bcontainer,
       }
       QLIST_INSERT_HEAD(&vfio_device_list, vbasedev, global_next);
+
+    vfio_get_all_regions(vbasedev);
   }

+    /* check cache */
+    if (vbasedev->regions[index] != NULL) {
+        *info = vbasedev->regions[index];
+        return 0;
+    }
+

why not populate vbasedev->regions[index] in vfio_get_all_regions() ?

Good question. I presume it's not possible for us to ever look up a region
that has somehow appeared *after* vfio_prepare_device() ?

We'd end up off the end of the array in that case anyway.


I was confused. I thought we were caching VFIORegions ...

Anyway, this is an optimisation and I fail to understand where
the VFIO_DEVICE_GET_REGION_INFO ioctl is called on a hot path.

Is it for interrupts ? Please explain.

Do you have figures ?


Thanks,

C.





Reply via email to