[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 03/27] vfio/common: return early if space isn't empty
|
From: |
Zhenzhong Duan |
|
Subject: |
[PATCH v7 03/27] vfio/common: return early if space isn't empty |
|
Date: |
Tue, 21 Nov 2023 16:44:02 +0800 |
This is a trivial optimization. If there is active container in space,
vfio_reset_handler will never be unregistered. So revert the check of
space->containers and return early.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
---
hw/vfio/common.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 572ae7c934..934f4f5446 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1462,10 +1462,13 @@ VFIOAddressSpace *vfio_get_address_space(AddressSpace
*as)
void vfio_put_address_space(VFIOAddressSpace *space)
{
- if (QLIST_EMPTY(&space->containers)) {
- QLIST_REMOVE(space, list);
- g_free(space);
+ if (!QLIST_EMPTY(&space->containers)) {
+ return;
}
+
+ QLIST_REMOVE(space, list);
+ g_free(space);
+
if (QLIST_EMPTY(&vfio_address_spaces)) {
qemu_unregister_reset(vfio_reset_handler, NULL);
}
--
2.34.1
- [PATCH v7 00/27] vfio: Adopt iommufd, Zhenzhong Duan, 2023/11/21
- [PATCH v7 01/27] backends/iommufd: Introduce the iommufd object, Zhenzhong Duan, 2023/11/21
- [PATCH v7 02/27] util/char_dev: Add open_cdev(), Zhenzhong Duan, 2023/11/21
- [PATCH v7 03/27] vfio/common: return early if space isn't empty,
Zhenzhong Duan <=
- [PATCH v7 04/27] vfio/iommufd: Implement the iommufd backend, Zhenzhong Duan, 2023/11/21
- [PATCH v7 05/27] vfio/iommufd: Relax assert check for iommufd backend, Zhenzhong Duan, 2023/11/21
- [PATCH v7 06/27] vfio/iommufd: Add support for iova_ranges and pgsizes, Zhenzhong Duan, 2023/11/21
- [PATCH v7 07/27] vfio/pci: Extract out a helper vfio_pci_get_pci_hot_reset_info, Zhenzhong Duan, 2023/11/21
- [PATCH v7 08/27] vfio/pci: Introduce a vfio pci hot reset interface, Zhenzhong Duan, 2023/11/21
- [PATCH v7 09/27] vfio/iommufd: Enable pci hot reset through iommufd cdev interface, Zhenzhong Duan, 2023/11/21
- [PATCH v7 10/27] vfio/pci: Allow the selection of a given iommu backend, Zhenzhong Duan, 2023/11/21
- [PATCH v7 11/27] vfio/pci: Make vfio cdev pre-openable by passing a file handle, Zhenzhong Duan, 2023/11/21