Skip to contentSkip to conversation

migration: Drop/unexport migration_is_device() and migration_is_active()

PATCH Applied Avihai Horon 4 participants 17 messages Dec 18, 2024 – Dec 24, 2024

lore
Share & tools
lore
#0 lore raw

v2 cover migration: Drop/unexport migration_is_device() and migration_is_active()

Hello,

This follows up on Peter's series [1] to simplify migration status API to a single migration_is_running() function.

Peter's series tried to drop migration_is_device() and migration_is_active(), however VFIO used them to check if dirty page tracking has been started in order to avoid errors in log sync, so they couldn't simply be dropped without some preliminary cleanups.

This series handles these preliminary cleanups and eventually drops migration_is_device() and unexports migration_is_active().

The series has been migration tested with the following:
- VFIO device dirty tracking.
- Legacy VFIO iommu dirty tracking.
- vIOMMU + Legacy VFIO iommu dirty tracking (migration with vIOMMU is currently blocked, so I used a patched QEMU to allow it).

I also tested calc-dirty-rate as now VFIO dirty pages should be included in its report, and indeed they are.

I didn't test it with iommu DPT as I don't have access to such HW. It would be great if someone with the proper HW could test it.

Patch structure:
1-4: Refactor and clean up VFIO dirty page tracking helpers. 5: Refactor dirty limit code.
6-7: Drop/unexport migration_is_device() and migration_is_running().

Changes from v1 [2]:
* Bail out early in vfio_container_set_dirty_page_tracking() if dirty tracking has already been started/stopped. (Joao)
* Untied the dirty tracking helpers from migration (i.e., removed migration_is_running() check) so VFIO dirty pages will be included in calc-dirty-rate. (Joao)
* Added comment to VFIODevice->dirty_tracking that states it's protected by BQL.
* Added R-b/A-b tags.

Thanks.

[1]
https://lore.kernel.org/qemu-devel/[email protected]/

[2]
https://lore.kernel.org/qemu-devel/[email protected]/

Avihai Horon (7):
vfio/container: Add dirty tracking started flag vfio/migration: Refactor vfio_devices_all_dirty_tracking() logic vfio/migration: Refactor vfio_devices_all_running_and_mig_active()
logic
vfio/migration: Rename vfio_devices_all_dirty_tracking() system/dirtylimit: Don't use migration_is_active()
migration: Drop migration_is_device()
migration: Unexport migration_is_active()

 include/hw/vfio/vfio-common.h         |  6 +--
 include/hw/vfio/vfio-container-base.h |  1 +
 include/migration/misc.h              |  2 -
 hw/vfio/common.c                      | 57 +++++++++++----------------
 hw/vfio/container-base.c              | 12 +++++-
 hw/vfio/container.c                   |  2 +-
 migration/migration.c                 | 23 ++++-------
 system/dirtylimit.c                   |  3 +-
 8 files changed, 49 insertions(+), 57 deletions(-)
Signature · 1 line
2.40.1
#1 lore raw

PATCH v2 1/7 vfio/container: Add dirty tracking started flag

Add a flag to VFIOContainerBase that indicates whether dirty tracking has been started for the container or not.

This will be used in the following patches to allow dirty page syncs only if dirty tracking has been started.

---
 include/hw/vfio/vfio-container-base.h |  1 +
 hw/vfio/container-base.c              | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)
include/hw/vfio/vfio-container-base.h +1 -0
index 62a8b60d87..4cff9943ab 100644
@@ -44,6 +44,7 @@ typedef struct VFIOContainerBase {
     unsigned long pgsizes;
     unsigned int dma_max_mappings;
     bool dirty_pages_supported;
+    bool dirty_pages_started; /* Protected by BQL */
     QLIST_HEAD(, VFIOGuestIOMMU) giommu_list;
     QLIST_HEAD(, VFIORamDiscardListener) vrdl_list;
     QLIST_ENTRY(VFIOContainerBase) next;
hw/vfio/container-base.c +11 -1
index 6f86c37d97..749a3fd29d 100644
@@ -64,13 +64,23 @@ int vfio_container_set_dirty_page_tracking(VFIOContainerBase *bcontainer,
                                            bool start, Error **errp)
 {
     VFIOIOMMUClass *vioc = VFIO_IOMMU_GET_CLASS(bcontainer);
+    int ret;
 
     if (!bcontainer->dirty_pages_supported) {
         return 0;
     }
 
     g_assert(vioc->set_dirty_page_tracking);
-    return vioc->set_dirty_page_tracking(bcontainer, start, errp);
+    if (bcontainer->dirty_pages_started == start) {
+        return 0;
+    }
+
+    ret = vioc->set_dirty_page_tracking(bcontainer, start, errp);
+    if (!ret) {
+        bcontainer->dirty_pages_started = start;
+    }
+
+    return ret;
 }
 
 int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer,
Signature · 1 line
2.40.1
#2 lore raw

PATCH v2 2/7 vfio/migration: Refactor vfio_devices_all_dirty_tracking() logic

In reply to Avihai Horon

During dirty page log sync, vfio_devices_all_dirty_tracking() is used to check if dirty tracking has been started in order to avoid errors. The current logic checks if migration is in ACTIVE or DEVICE states to ensure dirty tracking has been started.

However, recently there has been an effort to simplify the migration status API and reduce it to a single migration_is_running() function.

To accommodate this, refactor vfio_devices_all_dirty_tracking() logic so it won't use migration_is_active() and migration_is_device(). Instead, use internal VFIO dirty tracking flags.

As a side effect, now that migration status is no longer used to detect dirty tracking status, VFIO log syncs are untied from migration. This will make calc-dirty-rate more accurate as now it will also include VFIO dirty pages.

While at it, as VFIODevice->dirty_tracking is now used to detect dirty tracking status, add a comment that states how it's protected.

---
 include/hw/vfio/vfio-common.h |  2 +-
 hw/vfio/common.c              | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
include/hw/vfio/vfio-common.h +1 -1
index e0ce6ec3a9..6c999be398 100644
@@ -143,7 +143,7 @@ typedef struct VFIODevice {
     OnOffAuto pre_copy_dirty_page_tracking;
     OnOffAuto device_dirty_page_tracking;
     bool dirty_pages_supported;
-    bool dirty_tracking;
+    bool dirty_tracking; /* Protected by BQL */
     bool iommu_dirty_tracking;
     HostIOMMUDevice *hiod;
     int devid;
hw/vfio/common.c +16 -1
index dcef44fe55..e032ce1b6f 100644
@@ -170,11 +170,26 @@ bool vfio_device_state_is_precopy(VFIODevice *vbasedev)
            migration->device_state == VFIO_DEVICE_STATE_PRE_COPY_P2P;
 }
 
+static bool vfio_devices_all_device_dirty_tracking_started(
+    const VFIOContainerBase *bcontainer)
+{
+    VFIODevice *vbasedev;
+
+    QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) {
+        if (!vbasedev->dirty_tracking) {
+            return false;
+        }
+    }
+
+    return true;
+}
+
 static bool vfio_devices_all_dirty_tracking(VFIOContainerBase *bcontainer)
 {
     VFIODevice *vbasedev;
 
-    if (!migration_is_active() && !migration_is_device()) {
+    if (!(vfio_devices_all_device_dirty_tracking_started(bcontainer) ||
+          bcontainer->dirty_pages_started)) {
         return false;
     }
 
Signature · 1 line
2.40.1
Reviewed-by on v2 2/7
#3 lore raw

Re: [PATCH v2 2/7] vfio/migration: Refactor vfio_devices_all_dirty_tracking() logic

Quoted 17 lines · Avihai Horon

During dirty page log sync, vfio_devices_all_dirty_tracking() is used to check if dirty tracking has been started in order to avoid errors. The current logic checks if migration is in ACTIVE or DEVICE states to ensure dirty tracking has been started.

However, recently there has been an effort to simplify the migration status API and reduce it to a single migration_is_running() function.

To accommodate this, refactor vfio_devices_all_dirty_tracking() logic so it won't use migration_is_active() and migration_is_device(). Instead, use internal VFIO dirty tracking flags.

As a side effect, now that migration status is no longer used to detect dirty tracking status, VFIO log syncs are untied from migration. This will make calc-dirty-rate more accurate as now it will also include VFIO dirty pages.

Quoted 4 lines

While at it, as VFIODevice->dirty_tracking is now used to detect dirty tracking status, add a comment that states how it's protected.

Quoted 50 lines
---
 include/hw/vfio/vfio-common.h |  2 +-
 hw/vfio/common.c              | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
include/hw/vfio/vfio-common.h +1 -1
index e0ce6ec3a9..6c999be398 100644
@@ -143,7 +143,7 @@ typedef struct VFIODevice {
     OnOffAuto pre_copy_dirty_page_tracking;
     OnOffAuto device_dirty_page_tracking;
     bool dirty_pages_supported;
-    bool dirty_tracking;
+    bool dirty_tracking; /* Protected by BQL */
     bool iommu_dirty_tracking;
     HostIOMMUDevice *hiod;
     int devid;
hw/vfio/common.c +16 -1
index dcef44fe55..e032ce1b6f 100644
@@ -170,11 +170,26 @@ bool vfio_device_state_is_precopy(VFIODevice *vbasedev)
            migration->device_state == VFIO_DEVICE_STATE_PRE_COPY_P2P;
 }
 
+static bool vfio_devices_all_device_dirty_tracking_started(
+    const VFIOContainerBase *bcontainer)
+{
+    VFIODevice *vbasedev;
+
+    QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) {
+        if (!vbasedev->dirty_tracking) {
+            return false;
+        }
+    }
+
+    return true;
+}
+
 static bool vfio_devices_all_dirty_tracking(VFIOContainerBase *bcontainer)
 {
     VFIODevice *vbasedev;
 
-    if (!migration_is_active() && !migration_is_device()) {
+    if (!(vfio_devices_all_device_dirty_tracking_started(bcontainer) ||
+          bcontainer->dirty_pages_started)) {
         return false;
     }
 
#4 lore raw

PATCH v2 3/7 vfio/migration: Refactor vfio_devices_all_running_and_mig_active() logic

In reply to Avihai Horon

During DMA unmap with vIOMMU, vfio_devices_all_running_and_mig_active() is used to check whether a dirty page log sync of the unmapped pages is required. Such log sync is needed during migration pre-copy phase, and the current logic detects it by checking if migration is active and if the VFIO devices are running.

However, recently there has been an effort to simplify the migration status API and reduce it to a single migration_is_running() function.

To accommodate this, refactor vfio_devices_all_running_and_mig_active() logic so it won't use migration_is_active(). Do it by simply checking if dirty tracking has been started using internal VFIO flags.

This should be equivalent to the previous logic as during migration dirty tracking is active and when the guest is stopped there shouldn't be DMA unmaps coming from it.

As a side effect, now that migration status is no longer used, DMA unmap log syncs are untied from migration. This will make calc-dirty-rate more accurate as now it will also include VFIO dirty pages that were DMA unmapped.

Also rename the function to properly reflect its new logic and extract common code from vfio_devices_all_dirty_tracking().

---
 include/hw/vfio/vfio-common.h |  4 ++--
 hw/vfio/common.c              | 40 +++++++----------------------------
 hw/vfio/container.c           |  2 +-
 3 files changed, 11 insertions(+), 35 deletions(-)
include/hw/vfio/vfio-common.h +2 -2
index 6c999be398..d5f542beab 100644
@@ -296,8 +296,8 @@ bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp);
 void vfio_migration_exit(VFIODevice *vbasedev);
 
 int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size);
-bool
-vfio_devices_all_running_and_mig_active(const VFIOContainerBase *bcontainer);
+bool vfio_devices_all_dirty_tracking_started(
+    const VFIOContainerBase *bcontainer);
 bool
 vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer);
 int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer,
hw/vfio/common.c +8 -32
index e032ce1b6f..2831f674ff 100644
@@ -184,12 +184,18 @@ static bool vfio_devices_all_device_dirty_tracking_started(
     return true;
 }
 
+bool vfio_devices_all_dirty_tracking_started(
+    const VFIOContainerBase *bcontainer)
+{
+    return vfio_devices_all_device_dirty_tracking_started(bcontainer) ||
+           bcontainer->dirty_pages_started;
+}
+
 static bool vfio_devices_all_dirty_tracking(VFIOContainerBase *bcontainer)
 {
     VFIODevice *vbasedev;
 
-    if (!(vfio_devices_all_device_dirty_tracking_started(bcontainer) ||
-          bcontainer->dirty_pages_started)) {
+    if (!vfio_devices_all_dirty_tracking_started(bcontainer)) {
         return false;
     }
 
@@ -225,36 +231,6 @@ bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer)
     return true;
 }
 
-/*
- * Check if all VFIO devices are running and migration is active, which is
- * essentially equivalent to the migration being in pre-copy phase.
- */
-bool
-vfio_devices_all_running_and_mig_active(const VFIOContainerBase *bcontainer)
-{
-    VFIODevice *vbasedev;
-
-    if (!migration_is_active()) {
-        return false;
-    }
-
-    QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) {
-        VFIOMigration *migration = vbasedev->migration;
-
-        if (!migration) {
-            return false;
-        }
-
-        if (vfio_device_state_is_running(vbasedev) ||
-            vfio_device_state_is_precopy(vbasedev)) {
-            continue;
-        } else {
-            return false;
-        }
-    }
-    return true;
-}
-
 static bool vfio_listener_skipped_section(MemoryRegionSection *section)
 {
     return (!memory_region_is_ram(section->mr) &&
hw/vfio/container.c +1 -1
index 9ccdb639ac..15deffe3e4 100644
@@ -131,7 +131,7 @@ static int vfio_legacy_dma_unmap(const VFIOContainerBase *bcontainer,
     int ret;
     Error *local_err = NULL;
 
-    if (iotlb && vfio_devices_all_running_and_mig_active(bcontainer)) {
+    if (iotlb && vfio_devices_all_dirty_tracking_started(bcontainer)) {
         if (!vfio_devices_all_device_dirty_tracking(bcontainer) &&
             bcontainer->dirty_pages_supported) {
             return vfio_dma_unmap_bitmap(container, iova, size, iotlb);
Signature · 1 line
2.40.1
Reviewed-by on v2 3/7
#5 lore raw

Re: [PATCH v2 3/7] vfio/migration: Refactor vfio_devices_all_running_and_mig_active() logic

Quoted 22 lines · Avihai Horon

During DMA unmap with vIOMMU, vfio_devices_all_running_and_mig_active() is used to check whether a dirty page log sync of the unmapped pages is required. Such log sync is needed during migration pre-copy phase, and the current logic detects it by checking if migration is active and if the VFIO devices are running.

However, recently there has been an effort to simplify the migration status API and reduce it to a single migration_is_running() function.

To accommodate this, refactor vfio_devices_all_running_and_mig_active() logic so it won't use migration_is_active(). Do it by simply checking if dirty tracking has been started using internal VFIO flags.

This should be equivalent to the previous logic as during migration dirty tracking is active and when the guest is stopped there shouldn't be DMA unmaps coming from it.

As a side effect, now that migration status is no longer used, DMA unmap log syncs are untied from migration. This will make calc-dirty-rate more accurate as now it will also include VFIO dirty pages that were DMA unmapped.

Quoted 4 lines

Also rename the function to properly reflect its new logic and extract common code from vfio_devices_all_dirty_tracking().

Quoted 96 lines
---
 include/hw/vfio/vfio-common.h |  4 ++--
 hw/vfio/common.c              | 40 +++++++----------------------------
 hw/vfio/container.c           |  2 +-
 3 files changed, 11 insertions(+), 35 deletions(-)
include/hw/vfio/vfio-common.h +2 -2
index 6c999be398..d5f542beab 100644
@@ -296,8 +296,8 @@ bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp);
 void vfio_migration_exit(VFIODevice *vbasedev);
 
 int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size);
-bool
-vfio_devices_all_running_and_mig_active(const VFIOContainerBase *bcontainer);
+bool vfio_devices_all_dirty_tracking_started(
+    const VFIOContainerBase *bcontainer);
 bool
 vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer);
 int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer,
hw/vfio/common.c +8 -32
index e032ce1b6f..2831f674ff 100644
@@ -184,12 +184,18 @@ static bool vfio_devices_all_device_dirty_tracking_started(
     return true;
 }
 
+bool vfio_devices_all_dirty_tracking_started(
+    const VFIOContainerBase *bcontainer)
+{
+    return vfio_devices_all_device_dirty_tracking_started(bcontainer) ||
+           bcontainer->dirty_pages_started;
+}
+
 static bool vfio_devices_all_dirty_tracking(VFIOContainerBase *bcontainer)
 {
     VFIODevice *vbasedev;
 
-    if (!(vfio_devices_all_device_dirty_tracking_started(bcontainer) ||
-          bcontainer->dirty_pages_started)) {
+    if (!vfio_devices_all_dirty_tracking_started(bcontainer)) {
         return false;
     }
 
@@ -225,36 +231,6 @@ bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer)
     return true;
 }
 
-/*
- * Check if all VFIO devices are running and migration is active, which is
- * essentially equivalent to the migration being in pre-copy phase.
- */
-bool
-vfio_devices_all_running_and_mig_active(const VFIOContainerBase *bcontainer)
-{
-    VFIODevice *vbasedev;
-
-    if (!migration_is_active()) {
-        return false;
-    }
-
-    QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) {
-        VFIOMigration *migration = vbasedev->migration;
-
-        if (!migration) {
-            return false;
-        }
-
-        if (vfio_device_state_is_running(vbasedev) ||
-            vfio_device_state_is_precopy(vbasedev)) {
-            continue;
-        } else {
-            return false;
-        }
-    }
-    return true;
-}
-
 static bool vfio_listener_skipped_section(MemoryRegionSection *section)
 {
     return (!memory_region_is_ram(section->mr) &&
hw/vfio/container.c +1 -1
index 9ccdb639ac..15deffe3e4 100644
@@ -131,7 +131,7 @@ static int vfio_legacy_dma_unmap(const VFIOContainerBase *bcontainer,
     int ret;
     Error *local_err = NULL;
 
-    if (iotlb && vfio_devices_all_running_and_mig_active(bcontainer)) {
+    if (iotlb && vfio_devices_all_dirty_tracking_started(bcontainer)) {
         if (!vfio_devices_all_device_dirty_tracking(bcontainer) &&
             bcontainer->dirty_pages_supported) {
             return vfio_dma_unmap_bitmap(container, iova, size, iotlb);
#6 lore raw

PATCH v2 4/7 vfio/migration: Rename vfio_devices_all_dirty_tracking()

In reply to Avihai Horon

vfio_devices_all_dirty_tracking() is used to check if dirty page log sync is needed. However, besides checking the dirty page tracking status, it also checks the pre_copy_dirty_page_tracking flag.

Rename it to vfio_devices_log_sync_needed() which reflects its purpose more accurately and makes the code clearer as there are already several helpers with similar names.

---
 hw/vfio/common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/vfio/common.c +2 -2
index 2831f674ff..d113d8f4f5 100644
@@ -191,7 +191,7 @@ bool vfio_devices_all_dirty_tracking_started(
            bcontainer->dirty_pages_started;
 }
 
-static bool vfio_devices_all_dirty_tracking(VFIOContainerBase *bcontainer)
+static bool vfio_log_sync_needed(const VFIOContainerBase *bcontainer)
 {
     VFIODevice *vbasedev;
 
@@ -1364,7 +1364,7 @@ static void vfio_listener_log_sync(MemoryListener *listener,
         return;
     }
 
-    if (vfio_devices_all_dirty_tracking(bcontainer)) {
+    if (vfio_log_sync_needed(bcontainer)) {
         ret = vfio_sync_dirty_bitmap(bcontainer, section, &local_err);
         if (ret) {
             error_report_err(local_err);
Signature · 1 line
2.40.1
#7 lore raw

PATCH v2 5/7 system/dirtylimit: Don't use migration_is_active()

In reply to Avihai Horon

vcpu_dirty_rate_stat_collect() uses migration_is_active() to detect whether migration is running or not, in order to get the correct dirty rate period value.

However, recently there has been an effort to simplify the migration status API and reduce it to a single migration_is_running() function.

To accommodate this, and since the same functionality can be achieved with migration_is_running(), use it instead of migration_is_active().

---
 system/dirtylimit.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
system/dirtylimit.c +1 -2
index ab20da34bb..d7a855c603 100644
@@ -80,8 +80,7 @@ static void vcpu_dirty_rate_stat_collect(void)
     int i = 0;
     int64_t period = DIRTYLIMIT_CALC_TIME_MS;
 
-    if (migrate_dirty_limit() &&
-        migration_is_active()) {
+    if (migrate_dirty_limit() && migration_is_running()) {
         period = migrate_vcpu_dirty_limit_period();
     }
 
Signature · 1 line
2.40.1
#8 lore raw

PATCH v2 6/7 migration: Drop migration_is_device()

In reply to Avihai Horon

After being removed from VFIO, migration_is_device() no longer has any users. Drop it.

---
 include/migration/misc.h | 1 -
 migration/migration.c    | 7 -------
 2 files changed, 8 deletions(-)
include/migration/misc.h +0 -1
index 804eb23c06..ad1e25826a 100644
@@ -54,7 +54,6 @@ void migration_object_init(void);
 void migration_shutdown(void);
 
 bool migration_is_active(void);
-bool migration_is_device(void);
 bool migration_is_running(void);
 bool migration_thread_is_self(void);
 
migration/migration.c +0 -7
index 8c5bd0a75c..18ca60af4f 100644
@@ -1645,13 +1645,6 @@ bool migration_is_active(void)
             s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE);
 }
 
-bool migration_is_device(void)
-{
-    MigrationState *s = current_migration;
-
-    return s->state == MIGRATION_STATUS_DEVICE;
-}
-
 bool migration_thread_is_self(void)
 {
     MigrationState *s = current_migration;
Signature · 1 line
2.40.1
#9 lore raw

PATCH v2 7/7 migration: Unexport migration_is_active()

In reply to Avihai Horon

After being removed from VFIO and dirty limit, migration_is_active() no longer has any users outside the migration subsystem, and in fact, it's only used in migration.c.

Unexport it and also relocate it so it can be made static.

---
 include/migration/misc.h |  1 -
 migration/migration.c    | 16 ++++++++--------
 2 files changed, 8 insertions(+), 9 deletions(-)
include/migration/misc.h +0 -1
index ad1e25826a..c0e23fdac9 100644
@@ -53,7 +53,6 @@ void dump_vmstate_json_to_file(FILE *out_fp);
 void migration_object_init(void);
 void migration_shutdown(void);
 
-bool migration_is_active(void);
 bool migration_is_running(void);
 bool migration_thread_is_self(void);
 
migration/migration.c +8 -8
index 18ca60af4f..5bb0633e37 100644
@@ -1139,6 +1139,14 @@ bool migration_is_running(void)
     }
 }
 
+static bool migration_is_active(void)
+{
+    MigrationState *s = current_migration;
+
+    return (s->state == MIGRATION_STATUS_ACTIVE ||
+            s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE);
+}
+
 static bool migrate_show_downtime(MigrationState *s)
 {
     return (s->state == MIGRATION_STATUS_COMPLETED) || migration_in_postcopy();
@@ -1637,14 +1645,6 @@ bool migration_in_bg_snapshot(void)
     return migrate_background_snapshot() && migration_is_running();
 }
 
-bool migration_is_active(void)
-{
-    MigrationState *s = current_migration;
-
-    return (s->state == MIGRATION_STATUS_ACTIVE ||
-            s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE);
-}
-
 bool migration_thread_is_self(void)
 {
     MigrationState *s = current_migration;
Signature · 1 line
2.40.1
#10 lore raw
In reply to Avihai Horon
Quoted 19 lines · Avihai Horon

Hello,

This follows up on Peter's series [1] to simplify migration status API to a single migration_is_running() function.

Peter's series tried to drop migration_is_device() and migration_is_active(), however VFIO used them to check if dirty page tracking has been started in order to avoid errors in log sync, so they couldn't simply be dropped without some preliminary cleanups.

This series handles these preliminary cleanups and eventually drops migration_is_device() and unexports migration_is_active().

The series has been migration tested with the following:
- VFIO device dirty tracking.
- Legacy VFIO iommu dirty tracking.
- vIOMMU + Legacy VFIO iommu dirty tracking (migration with vIOMMU is currently blocked, so I used a patched QEMU to allow it).

Quoted 6 lines

I also tested calc-dirty-rate as now VFIO dirty pages should be included in its report, and indeed they are.

I didn't test it with iommu DPT as I don't have access to such HW. It would be great if someone with the proper HW could test it.

FWIW tested iommufd DPT (migration and calc-dirty-rate) on said compatible hardware (Milan hardware). Things look to be working as expected. I deferred vIOMMU IOMMUFD DPT testing to my own follow-up once I am back from vacation.

Thanks for fixing calc-dirty-rate along the way your cleanup!

Joao

#11 lore raw
Quoted 20 lines · Joao Martins
Quoted 19 lines · Avihai Horon

Hello,

This follows up on Peter's series [1] to simplify migration status API to a single migration_is_running() function.

Peter's series tried to drop migration_is_device() and migration_is_active(), however VFIO used them to check if dirty page tracking has been started in order to avoid errors in log sync, so they couldn't simply be dropped without some preliminary cleanups.

This series handles these preliminary cleanups and eventually drops migration_is_device() and unexports migration_is_active().

The series has been migration tested with the following:
- VFIO device dirty tracking.
- Legacy VFIO iommu dirty tracking.
- vIOMMU + Legacy VFIO iommu dirty tracking (migration with vIOMMU is currently blocked, so I used a patched QEMU to allow it).

Quoted 8 lines
Quoted 6 lines

I also tested calc-dirty-rate as now VFIO dirty pages should be included in its report, and indeed they are.

I didn't test it with iommu DPT as I don't have access to such HW. It would be great if someone with the proper HW could test it.

FWIW tested iommufd DPT (migration and calc-dirty-rate) on said compatible hardware (Milan hardware). Things look to be working as expected.

Could we have a Tested-by tag then ?

Quoted 4 lines

I deferred
vIOMMU IOMMUFD DPT testing to my own follow-up once I am back from vacation.

Thanks for fixing calc-dirty-rate along the way your cleanup!

Thanks,

C.

Tested-by
#12 lore raw
Quoted 24 lines · Cédric Le Goater
Quoted 23 lines · Joao Martins
Quoted 22 lines · Avihai Horon

Hello,

This follows up on Peter's series [1] to simplify migration status API to a single migration_is_running() function.

Peter's series tried to drop migration_is_device() and migration_is_active(), however VFIO used them to check if dirty page tracking has been started in order to avoid errors in log sync, so they couldn't simply be dropped without some preliminary cleanups.

This series handles these preliminary cleanups and eventually drops migration_is_device() and unexports migration_is_active().

The series has been migration tested with the following:
- VFIO device dirty tracking.
- Legacy VFIO iommu dirty tracking.
- vIOMMU + Legacy VFIO iommu dirty tracking (migration with vIOMMU is currently blocked, so I used a patched QEMU to allow it).

I also tested calc-dirty-rate as now VFIO dirty pages should be included in its report, and indeed they are.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I didn't test it with iommu DPT as I don't have access to such HW. It would be great if someone with the proper HW could test it.

FWIW tested iommufd DPT (migration and calc-dirty-rate) on said compatible hardware (Milan hardware). Things look to be working as expected.

Could we have a Tested-by tag then ?

Yes:

Quoted 11 lines
Quoted 4 lines

I deferred
vIOMMU IOMMUFD DPT testing to my own follow-up once I am back from vacation.

Thanks for fixing calc-dirty-rate along the way your cleanup!

Thanks,

C.

#13 lore raw
Quoted 31 lines · Joao Martins
Quoted 30 lines · Cédric Le Goater
Quoted 28 lines · Joao Martins
Quoted 19 lines · Avihai Horon

Hello,

This follows up on Peter's series [1] to simplify migration status API to a single migration_is_running() function.

Peter's series tried to drop migration_is_device() and migration_is_active(), however VFIO used them to check if dirty page tracking has been started in order to avoid errors in log sync, so they couldn't simply be dropped without some preliminary cleanups.

This series handles these preliminary cleanups and eventually drops migration_is_device() and unexports migration_is_active().

The series has been migration tested with the following:
- VFIO device dirty tracking.
- Legacy VFIO iommu dirty tracking.
- vIOMMU + Legacy VFIO iommu dirty tracking (migration with vIOMMU is currently blocked, so I used a patched QEMU to allow it).

Quoted 6 lines

I also tested calc-dirty-rate as now VFIO dirty pages should be included in its report, and indeed they are.

I didn't test it with iommu DPT as I don't have access to such HW. It would be great if someone with the proper HW could test it.

FWIW tested iommufd DPT (migration and calc-dirty-rate) on said compatible hardware (Milan hardware). Things look to be working as expected.

Quoted 7 lines
Quoted 2 lines

Could we have a Tested-by tag then ?

Yes:

Applied to vfio-next.

Thanks,

C.

#14 lore raw
In reply to Avihai Horon

Fabiano, Peter,

Quoted 22 lines · Avihai Horon

Hello,

This follows up on Peter's series [1] to simplify migration status API to a single migration_is_running() function.

Peter's series tried to drop migration_is_device() and migration_is_active(), however VFIO used them to check if dirty page tracking has been started in order to avoid errors in log sync, so they couldn't simply be dropped without some preliminary cleanups.

This series handles these preliminary cleanups and eventually drops migration_is_device() and unexports migration_is_active().

The series has been migration tested with the following:
- VFIO device dirty tracking.
- Legacy VFIO iommu dirty tracking.
- vIOMMU + Legacy VFIO iommu dirty tracking (migration with vIOMMU is currently blocked, so I used a patched QEMU to allow it).

I also tested calc-dirty-rate as now VFIO dirty pages should be included in its report, and indeed they are.

Quoted 7 lines

I didn't test it with iommu DPT as I don't have access to such HW. It would be great if someone with the proper HW could test it.

Patch structure:
1-4: Refactor and clean up VFIO dirty page tracking helpers. 5: Refactor dirty limit code.
6-7: Drop/unexport migration_is_device() and migration_is_running().

I can take these migration changes through the VFIO queue. Is that ok for you ?

Thanks,

C.

#15 lore raw
Quoted 28 lines · Cédric Le Goater

Fabiano, Peter,

Quoted 25 lines · Avihai Horon

Hello,

This follows up on Peter's series [1] to simplify migration status API to a single migration_is_running() function.

Peter's series tried to drop migration_is_device() and migration_is_active(), however VFIO used them to check if dirty page tracking has been started in order to avoid errors in log sync, so they couldn't simply be dropped without some preliminary cleanups.

This series handles these preliminary cleanups and eventually drops migration_is_device() and unexports migration_is_active().

The series has been migration tested with the following:
- VFIO device dirty tracking.
- Legacy VFIO iommu dirty tracking.
- vIOMMU + Legacy VFIO iommu dirty tracking (migration with vIOMMU is currently blocked, so I used a patched QEMU to allow it).

I also tested calc-dirty-rate as now VFIO dirty pages should be included in its report, and indeed they are.

I didn't test it with iommu DPT as I don't have access to such HW. It would be great if someone with the proper HW could test it.

Quoted 7 lines
Quoted 4 lines

Patch structure:
1-4: Refactor and clean up VFIO dirty page tracking helpers. 5: Refactor dirty limit code.
6-7: Drop/unexport migration_is_device() and migration_is_running().

I can take these migration changes through the VFIO queue. Is that ok for you ?

Fabiano is collecting things for this cycle, but just in case he's in the middle of a party - yes please, thanks!

Signature · 1 line
Peter Xu
#16 lore raw
Quoted 34 lines · Peter Xu
Quoted 33 lines · Cédric Le Goater

Fabiano, Peter,

Quoted 29 lines · Avihai Horon

Hello,

This follows up on Peter's series [1] to simplify migration status API to a single migration_is_running() function.

Peter's series tried to drop migration_is_device() and migration_is_active(), however VFIO used them to check if dirty page tracking has been started in order to avoid errors in log sync, so they couldn't simply be dropped without some preliminary cleanups.

This series handles these preliminary cleanups and eventually drops migration_is_device() and unexports migration_is_active().

The series has been migration tested with the following:
- VFIO device dirty tracking.
- Legacy VFIO iommu dirty tracking.
- vIOMMU + Legacy VFIO iommu dirty tracking (migration with vIOMMU is currently blocked, so I used a patched QEMU to allow it).

I also tested calc-dirty-rate as now VFIO dirty pages should be included in its report, and indeed they are.

I didn't test it with iommu DPT as I don't have access to such HW. It would be great if someone with the proper HW could test it.

Patch structure:
1-4: Refactor and clean up VFIO dirty page tracking helpers. 5: Refactor dirty limit code.
6-7: Drop/unexport migration_is_device() and migration_is_running().

Quoted 6 lines
Quoted 2 lines

I can take these migration changes through the VFIO queue. Is that ok for you ?

Fabiano is collecting things for this cycle, but just in case he's in the middle of a party - yes please, thanks!

Sending the PR then !

Thanks,

C.