diff mbox series

[1/3] vfio/migration: Report only stop-copy size in vfio_state_pending_exact()

Message ID 20241020130108.27148-2-avihaih@nvidia.com
State New
Headers show
Series vfio/migration: Some bug fixes and cleanups | expand

Commit Message

Avihai Horon Oct. 20, 2024, 1:01 p.m. UTC
vfio_state_pending_exact() is used to update migration core how much
device data is left for the device migration. Currently, the sum of
pre-copy and stop-copy sizes of the VFIO device are reported.

The pre-copy size is obtained via the VFIO_MIG_GET_PRECOPY_INFO ioctl,
which returns the amount of device data available to be transferred
while the device is in the PRE_COPY states.

The stop-copy size is obtained via the VFIO_DEVICE_FEATURE_MIG_DATA_SIZE
ioctl, which returns the total amount of device data left to be
transferred in order to complete the device migration.

According to the above, current implementation is wrong -- it reports
extra overlapping data because pre-copy size is already contained in
stop-copy size. Fix it by reporting only stop-copy size.

Fixes: eda7362af959 ("vfio/migration: Add VFIO migration pre-copy support")
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
---
 hw/vfio/migration.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

Cédric Le Goater Oct. 21, 2024, 6:48 a.m. UTC | #1
+Zhiyi

On 10/20/24 15:01, Avihai Horon wrote:
> vfio_state_pending_exact() is used to update migration core how much
> device data is left for the device migration. Currently, the sum of
> pre-copy and stop-copy sizes of the VFIO device are reported.
> 
> The pre-copy size is obtained via the VFIO_MIG_GET_PRECOPY_INFO ioctl,
> which returns the amount of device data available to be transferred
> while the device is in the PRE_COPY states.
> 
> The stop-copy size is obtained via the VFIO_DEVICE_FEATURE_MIG_DATA_SIZE
> ioctl, which returns the total amount of device data left to be
> transferred in order to complete the device migration.
> 
> According to the above, current implementation is wrong -- it reports
> extra overlapping data because pre-copy size is already contained in
> stop-copy size. Fix it by reporting only stop-copy size.
> 
> Fixes: eda7362af959 ("vfio/migration: Add VFIO migration pre-copy support")
> Signed-off-by: Avihai Horon <avihaih@nvidia.com>
> --->   hw/vfio/migration.c | 3 ---
>   1 file changed, 3 deletions(-)
> 
> diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
> index 17199b73ae..992dc3b102 100644
> --- a/hw/vfio/migration.c
> +++ b/hw/vfio/migration.c
> @@ -576,9 +576,6 @@ static void vfio_state_pending_exact(void *opaque, uint64_t *must_precopy,
>   
>       if (vfio_device_state_is_precopy(vbasedev)) {
>           vfio_query_precopy_size(migration);
> -
> -        *must_precopy +=
> -            migration->precopy_init_size + migration->precopy_dirty_size;
>       }
>   
>       trace_vfio_state_pending_exact(vbasedev->name, *must_precopy, *can_postcopy,
Cédric Le Goater Oct. 23, 2024, 10:06 a.m. UTC | #2
On 10/20/24 15:01, Avihai Horon wrote:
> vfio_state_pending_exact() is used to update migration core how much
> device data is left for the device migration. Currently, the sum of
> pre-copy and stop-copy sizes of the VFIO device are reported.
> 
> The pre-copy size is obtained via the VFIO_MIG_GET_PRECOPY_INFO ioctl,
> which returns the amount of device data available to be transferred
> while the device is in the PRE_COPY states.
> 
> The stop-copy size is obtained via the VFIO_DEVICE_FEATURE_MIG_DATA_SIZE
> ioctl, which returns the total amount of device data left to be
> transferred in order to complete the device migration.
> 
> According to the above, current implementation is wrong -- it reports
> extra overlapping data because pre-copy size is already contained in
> stop-copy size. Fix it by reporting only stop-copy size.
> 
> Fixes: eda7362af959 ("vfio/migration: Add VFIO migration pre-copy support")
> Signed-off-by: Avihai Horon <avihaih@nvidia.com>



Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.


> ---
>   hw/vfio/migration.c | 3 ---
>   1 file changed, 3 deletions(-)
> 
> diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
> index 17199b73ae..992dc3b102 100644
> --- a/hw/vfio/migration.c
> +++ b/hw/vfio/migration.c
> @@ -576,9 +576,6 @@ static void vfio_state_pending_exact(void *opaque, uint64_t *must_precopy,
>   
>       if (vfio_device_state_is_precopy(vbasedev)) {
>           vfio_query_precopy_size(migration);
> -
> -        *must_precopy +=
> -            migration->precopy_init_size + migration->precopy_dirty_size;
>       }
>   
>       trace_vfio_state_pending_exact(vbasedev->name, *must_precopy, *can_postcopy,
Michael Tokarev Oct. 25, 2024, 3:18 p.m. UTC | #3
20.10.2024 16:01, Avihai Horon:
> vfio_state_pending_exact() is used to update migration core how much
> device data is left for the device migration. Currently, the sum of
> pre-copy and stop-copy sizes of the VFIO device are reported.
> 
> The pre-copy size is obtained via the VFIO_MIG_GET_PRECOPY_INFO ioctl,
> which returns the amount of device data available to be transferred
> while the device is in the PRE_COPY states.
> 
> The stop-copy size is obtained via the VFIO_DEVICE_FEATURE_MIG_DATA_SIZE
> ioctl, which returns the total amount of device data left to be
> transferred in order to complete the device migration.
> 
> According to the above, current implementation is wrong -- it reports
> extra overlapping data because pre-copy size is already contained in
> stop-copy size. Fix it by reporting only stop-copy size.
> 
> Fixes: eda7362af959 ("vfio/migration: Add VFIO migration pre-copy support")
> Signed-off-by: Avihai Horon <avihaih@nvidia.com>

This smells like a qemu-stable material (for 8.1+).

Please let me know if it is not.

Thanks,

/mjt
Cédric Le Goater Oct. 25, 2024, 4:09 p.m. UTC | #4
On 10/25/24 17:18, Michael Tokarev wrote:
> 20.10.2024 16:01, Avihai Horon:
>> vfio_state_pending_exact() is used to update migration core how much
>> device data is left for the device migration. Currently, the sum of
>> pre-copy and stop-copy sizes of the VFIO device are reported.
>>
>> The pre-copy size is obtained via the VFIO_MIG_GET_PRECOPY_INFO ioctl,
>> which returns the amount of device data available to be transferred
>> while the device is in the PRE_COPY states.
>>
>> The stop-copy size is obtained via the VFIO_DEVICE_FEATURE_MIG_DATA_SIZE
>> ioctl, which returns the total amount of device data left to be
>> transferred in order to complete the device migration.
>>
>> According to the above, current implementation is wrong -- it reports
>> extra overlapping data because pre-copy size is already contained in
>> stop-copy size. Fix it by reporting only stop-copy size.
>>
>> Fixes: eda7362af959 ("vfio/migration: Add VFIO migration pre-copy support")
>> Signed-off-by: Avihai Horon <avihaih@nvidia.com>
> 
> This smells like a qemu-stable material (for 8.1+).

I am in favor.

Thanks,

C.
diff mbox series

Patch

diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index 17199b73ae..992dc3b102 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -576,9 +576,6 @@  static void vfio_state_pending_exact(void *opaque, uint64_t *must_precopy,
 
     if (vfio_device_state_is_precopy(vbasedev)) {
         vfio_query_precopy_size(migration);
-
-        *must_precopy +=
-            migration->precopy_init_size + migration->precopy_dirty_size;
     }
 
     trace_vfio_state_pending_exact(vbasedev->name, *must_precopy, *can_postcopy,