master
h 141 lines 3.64 KB
Raw
1 /*
2 * Migration stats
3 *
4 * Copyright (c) 2012-2023 Red Hat Inc
5 *
6 * Authors:
7 * Juan Quintela <quintela@redhat.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
11 */
12
13 #ifndef QEMU_MIGRATION_STATS_H
14 #define QEMU_MIGRATION_STATS_H
15
16 /*
17 * Amount of time to allocate to each "chunk" of bandwidth-throttled
18 * data.
19 */
20 #define BUFFER_DELAY 100
21
22 /*
23 * If rate_limit_max is 0, there is special code to remove the rate
24 * limit.
25 */
26 #define RATE_LIMIT_DISABLED 0
27
28 /*
29 * These are the ram migration statistic counters. It is loosely
30 * based on MigrationRAMStats.
31 */
32 typedef struct {
33 /*
34 * Number of bytes that were reported dirty after the latest
35 * system-wise synchronization of dirty information. It is used to do
36 * best-effort estimation on expected downtime.
37 */
38 uint64_t dirty_bytes_last_sync;
39 /*
40 * Number of bytes that were reported dirty now. This is an estimate
41 * value and will be updated every time migration thread queries from
42 * modules in an iteration loop. It is used to provide best-effort
43 * estimation on total remaining data.
44 */
45 uint64_t dirty_bytes_total;
46 /*
47 * Number of pages dirtied per second.
48 */
49 uint64_t dirty_pages_rate;
50 /*
51 * Number of times we have synchronized guest bitmaps. This always
52 * starts from 1 for the 1st iteration.
53 */
54 uint64_t dirty_sync_count;
55 /*
56 * Number of times zero copy failed to send any page using zero
57 * copy.
58 */
59 uint64_t dirty_sync_missed_zero_copy;
60 /*
61 * Number of bytes sent at migration completion stage while the
62 * guest is stopped.
63 */
64 uint64_t downtime_bytes;
65 /*
66 * Number of bytes sent through multifd channels.
67 */
68 uint64_t multifd_bytes;
69 /*
70 * Number of pages transferred that were not full of zeros.
71 */
72 uint64_t normal_pages;
73 /*
74 * Number of bytes sent during postcopy.
75 */
76 uint64_t postcopy_bytes;
77 /*
78 * Number of postcopy page faults that we have handled during
79 * postcopy stage.
80 */
81 uint64_t postcopy_requests;
82 /*
83 * Number of bytes sent during precopy stage.
84 */
85 uint64_t precopy_bytes;
86 /*
87 * Number of bytes transferred with QEMUFile.
88 */
89 uint64_t qemu_file_transferred;
90 /*
91 * Amount of transferred data at the start of current cycle.
92 */
93 uint64_t rate_limit_start;
94 /*
95 * Maximum amount of data we can send in a cycle.
96 */
97 uint64_t rate_limit_max;
98 /*
99 * Number of bytes sent through RDMA.
100 */
101 uint64_t rdma_bytes;
102 /*
103 * Number of pages transferred that were full of zeros.
104 */
105 uint64_t zero_pages;
106 } MigrationAtomicStats;
107
108 extern MigrationAtomicStats mig_stats;
109
110 /**
111 * migration_rate_get: Get the maximum amount that can be transferred.
112 *
113 * Returns the maximum number of bytes that can be transferred in a cycle.
114 */
115 uint64_t migration_rate_get(void);
116
117 /**
118 * migration_rate_reset: Reset the rate limit counter.
119 *
120 * This is called when we know we start a new transfer cycle.
121 */
122 void migration_rate_reset(void);
123
124 /**
125 * migration_rate_set: Set the maximum amount that can be transferred.
126 *
127 * Sets the maximum amount of bytes that can be transferred in one cycle.
128 *
129 * @new_rate: new maximum amount
130 */
131 void migration_rate_set(uint64_t new_rate);
132
133 /**
134 * migration_transferred_bytes: Return number of bytes transferred
135 *
136 * Returns how many bytes have we transferred since the beginning of
137 * the migration. It accounts for bytes sent through any migration
138 * channel, multifd, qemu_file, rdma, ....
139 */
140 uint64_t migration_transferred_bytes(void);
141 #endif