[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 22/33] vfio/migration: Convert bytes_transferred counter to at
From: |
Maciej S. Szmigiero |
Subject: |
[PATCH v4 22/33] vfio/migration: Convert bytes_transferred counter to atomic |
Date: |
Thu, 30 Jan 2025 11:08:43 +0100 |
From: "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>
So it can be safety accessed from multiple threads.
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
---
hw/vfio/migration.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index f5df5ef17080..cbb1e0b6f852 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -416,7 +416,7 @@ static ssize_t vfio_save_block(QEMUFile *f, VFIOMigration
*migration)
qemu_put_be64(f, VFIO_MIG_FLAG_DEV_DATA_STATE);
qemu_put_be64(f, data_size);
qemu_put_buffer(f, migration->data_buffer, data_size);
- bytes_transferred += data_size;
+ qatomic_add(&bytes_transferred, data_size);
trace_vfio_save_block(migration->vbasedev->name, data_size);
@@ -1038,12 +1038,12 @@ static int vfio_block_migration(VFIODevice *vbasedev,
Error *err, Error **errp)
int64_t vfio_mig_bytes_transferred(void)
{
- return bytes_transferred;
+ return qatomic_read(&bytes_transferred);
}
void vfio_reset_bytes_transferred(void)
{
- bytes_transferred = 0;
+ qatomic_set(&bytes_transferred, 0);
}
/*
- [PATCH v4 12/33] migration/multifd: Split packet into header and RAM data, (continued)
- [PATCH v4 12/33] migration/multifd: Split packet into header and RAM data, Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 13/33] migration/multifd: Device state transfer support - receive side, Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 14/33] migration/multifd: Make multifd_send() thread safe, Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 15/33] migration/multifd: Add an explicit MultiFDSendData destructor, Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 16/33] migration/multifd: Device state transfer support - send side, Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 17/33] migration/multifd: Make MultiFDSendData a struct, Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 18/33] migration/multifd: Add multifd_device_state_supported(), Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 19/33] migration: Add save_live_complete_precopy_thread handler, Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 20/33] vfio/migration: Add x-migration-load-config-after-iter VFIO property, Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 21/33] vfio/migration: Add load_device_config_state_start trace event, Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 22/33] vfio/migration: Convert bytes_transferred counter to atomic,
Maciej S. Szmigiero <=
- [PATCH v4 23/33] vfio/migration: Multifd device state transfer support - basic types, Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 24/33] vfio/migration: Multifd device state transfer support - VFIOStateBuffer(s), Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 25/33] vfio/migration: Multifd device state transfer - add support checking function, Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 26/33] vfio/migration: Multifd device state transfer support - receive init/cleanup, Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 27/33] vfio/migration: Multifd device state transfer support - received buffers queuing, Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 28/33] vfio/migration: Multifd device state transfer support - load thread, Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 29/33] vfio/migration: Multifd device state transfer support - config loading support, Maciej S. Szmigiero, 2025/01/30
- [PATCH v4 30/33] migration/qemu-file: Define g_autoptr() cleanup function for QEMUFile, Maciej S. Szmigiero, 2025/01/30