aboutsummaryrefslogtreecommitdiff
path: root/migration/ram.h
diff options
context:
space:
mode:
authorPeter Xu <peterx@redhat.com>2022-10-11 17:55:51 -0400
committerJuan Quintela <quintela@redhat.com>2022-12-15 10:30:37 +0100
commit23b7576d7879cdc93e3328e1a9228e8843780012 (patch)
treeef2bd156267ac39a812f728e54d7a17fcd4337bf /migration/ram.h
parentf3321554ef7e3adc3be6f697185d3bd50d60e30e (diff)
migration: Use atomic ops properly for page accountings
To prepare for thread-safety on page accountings, at least below counters need to be accessed only atomically, they are: ram_counters.transferred ram_counters.duplicate ram_counters.normal ram_counters.postcopy_bytes There are a lot of other counters but they won't be accessed outside migration thread, then they're still safe to be accessed without atomic ops. Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'migration/ram.h')
-rw-r--r--migration/ram.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/migration/ram.h b/migration/ram.h
index 038d52f49f..81cbb0947c 100644
--- a/migration/ram.h
+++ b/migration/ram.h
@@ -32,7 +32,27 @@
#include "qapi/qapi-types-migration.h"
#include "exec/cpu-common.h"
#include "io/channel.h"
+#include "qemu/stats64.h"
+/*
+ * These are the migration statistic counters that need to be updated using
+ * atomic ops (can be accessed by more than one thread). Here since we
+ * cannot modify MigrationStats directly to use Stat64 as it was defined in
+ * the QAPI scheme, we define an internal structure to hold them, and we
+ * propagate the real values when QMP queries happen.
+ *
+ * IOW, the corresponding fields within ram_counters on these specific
+ * fields will be always zero and not being used at all; they're just
+ * placeholders to make it QAPI-compatible.
+ */
+typedef struct {
+ Stat64 transferred;
+ Stat64 duplicate;
+ Stat64 normal;
+ Stat64 postcopy_bytes;
+} MigrationAtomicStats;
+
+extern MigrationAtomicStats ram_atomic_counters;
extern MigrationStats ram_counters;
extern XBZRLECacheStats xbzrle_counters;
extern CompressionStats compression_counters;