]> git.proxmox.com Git - mirror_qemu.git/blame - migration/dirtyrate.h
memory: Explicitly tag doc comments for structs
[mirror_qemu.git] / migration / dirtyrate.h
CommitLineData
4240dcee
CZ
1/*
2 * Dirtyrate common functions
3 *
4 * Copyright (c) 2020 HUAWEI TECHNOLOGIES CO., LTD.
5 *
6 * Authors:
7 * Chuan Zheng <zhengchuan@huawei.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_DIRTYRATE_H
14#define QEMU_MIGRATION_DIRTYRATE_H
15
16/*
17 * Sample 512 pages per GB as default.
18 * TODO: Make it configurable.
19 */
20#define DIRTYRATE_DEFAULT_SAMPLE_PAGES 512
21
a2635f0a
CZ
22/*
23 * Record ramblock idstr
24 */
25#define RAMBLOCK_INFO_MAX_LEN 256
26
f82583cd
CZ
27/*
28 * Minimum RAMBlock size to sample, in megabytes.
29 */
30#define MIN_RAMBLOCK_SIZE 128
31
eca58224
CZ
32/*
33 * Take 1s as minimum time for calculation duration
34 */
35#define MIN_FETCH_DIRTYRATE_TIME_SEC 1
36#define MAX_FETCH_DIRTYRATE_TIME_SEC 60
37
4240dcee
CZ
38struct DirtyRateConfig {
39 uint64_t sample_pages_per_gigabytes; /* sample pages per GB */
40 int64_t sample_period_seconds; /* time duration between two sampling */
41};
42
a2635f0a
CZ
43/*
44 * Store dirtypage info for each ramblock.
45 */
46struct RamblockDirtyInfo {
47 char idstr[RAMBLOCK_INFO_MAX_LEN]; /* idstr for each ramblock */
48 uint8_t *ramblock_addr; /* base address of ramblock we measure */
49 uint64_t ramblock_pages; /* ramblock size in TARGET_PAGE_SIZE */
50 uint64_t *sample_page_vfn; /* relative offset address for sampled page */
51 uint64_t sample_pages_count; /* count of sampled pages */
52 uint64_t sample_dirty_count; /* count of dirty pages we measure */
53 uint32_t *hash_result; /* array of hash result for sampled pages */
54};
55
c9a58d71
CZ
56/*
57 * Store calculation statistics for each measure.
58 */
59struct DirtyRateStat {
60 uint64_t total_dirty_samples; /* total dirty sampled page */
61 uint64_t total_sample_count; /* total sampled pages */
62 uint64_t total_block_mem_MB; /* size of total sampled pages in MB */
63 int64_t dirty_rate; /* dirty rate in MB/s */
64 int64_t start_time; /* calculation start time in units of second */
65 int64_t calc_time; /* time duration of two sampling in units of second */
66};
67
4240dcee
CZ
68void *get_dirtyrate_thread(void *arg);
69#endif