]> xenbits.xensource.com Git - libvirt.git/commitdiff
nodedev: update mdevs from the mdevctl thread
authorJonathon Jongsma <jjongsma@redhat.com>
Thu, 6 Jul 2023 14:16:35 +0000 (09:16 -0500)
committerJonathon Jongsma <jjongsma@redhat.com>
Thu, 13 Jul 2023 14:43:45 +0000 (09:43 -0500)
Rather than directly executing mdevctl from the udev event thread when
we determine that we need to re-query, schedule the mdevctl thread to
run. This also helps to coalesce multiple back-to-back updates into a
single one when there are multiple updates in a row or at startup when a
host has a very large number of mdevs.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
src/node_device/node_device_udev.c

index 7fd51bd0bb1b7329381871273d3e3820bcf59a29..dfdef483cbc4db17eb788ae9e680f0d33f3eb4de 100644 (file)
@@ -1451,6 +1451,9 @@ udevGetDeviceDetails(struct udev_device *device,
 }
 
 
+static void scheduleMdevctlUpdate(udevEventData *data, bool force);
+
+
 static int
 udevRemoveOneDeviceSysPath(const char *path)
 {
@@ -1483,8 +1486,7 @@ udevRemoveOneDeviceSysPath(const char *path)
     virNodeDeviceObjEndAPI(&obj);
 
     /* cannot check for mdev_types since they have already been removed */
-    if (nodeDeviceUpdateMediatedDevices() < 0)
-        VIR_WARN("mdevctl failed to update mediated devices");
+    scheduleMdevctlUpdate(driver->privateData, false);
 
     virObjectEventStateQueue(driver->nodeDeviceEventState, event);
     return 0;
@@ -1612,8 +1614,8 @@ udevAddOneDevice(struct udev_device *device)
     has_mdev_types = virNodeDeviceObjHasCap(obj, VIR_NODE_DEV_CAP_MDEV_TYPES);
     virNodeDeviceObjEndAPI(&obj);
 
-    if (has_mdev_types && nodeDeviceUpdateMediatedDevices() < 0)
-        VIR_WARN("mdevctl failed to update mediated devices");
+    if (has_mdev_types)
+        scheduleMdevctlUpdate(driver->privateData, false);
 
     ret = 0;
 
@@ -1775,8 +1777,7 @@ udevHandleOneDevice(struct udev_device *device)
         if (ret == 0 &&
             udevGetDeviceType(device, &dev_cap_type) == 0 &&
             dev_cap_type == VIR_NODE_DEV_CAP_MDEV)
-            if (nodeDeviceUpdateMediatedDevices() < 0)
-                VIR_WARN("mdevctl failed to update mediated devices");
+            scheduleMdevctlUpdate(driver->privateData, false);
         return ret;
     }