From: Jonathon Jongsma Date: Thu, 6 Jul 2023 14:16:35 +0000 (-0500) Subject: nodedev: update mdevs from the mdevctl thread X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=14026db9b0e25739ea30685bd643ff23aca30588;p=libvirt.git nodedev: update mdevs from the mdevctl thread 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 Reviewed-by: Boris Fiuczynski --- diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 7fd51bd0bb..dfdef483cb 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -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; }