blob: 7a26b40084dbf8c14560607f3350b89b49fa41bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*
* icount - Instruction Counter API
* CPU timers state API
*
* Copyright 2020 SUSE LLC
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef EXEC_ICOUNT_H
#define EXEC_ICOUNT_H
/**
* ICountMode: icount enablement state:
*
* @ICOUNT_DISABLED: Disabled - Do not count executed instructions.
* @ICOUNT_PRECISE: Enabled - Fixed conversion of insn to ns via "shift" option
* @ICOUNT_ADAPTATIVE: Enabled - Runtime adaptive algorithm to compute shift
*/
typedef enum {
ICOUNT_DISABLED = 0,
ICOUNT_PRECISE,
ICOUNT_ADAPTATIVE,
} ICountMode;
#ifdef CONFIG_TCG
extern ICountMode use_icount;
#define icount_enabled() (use_icount)
#else
#define icount_enabled() ICOUNT_DISABLED
#endif
/* Protect the CONFIG_USER_ONLY test vs poisoning. */
#if defined(COMPILING_PER_TARGET) || defined(COMPILING_SYSTEM_VS_USER)
# ifdef CONFIG_USER_ONLY
# undef icount_enabled
# define icount_enabled() ICOUNT_DISABLED
# endif
#endif
/*
* Update the icount with the executed instructions. Called by
* cpus-tcg vCPU thread so the main-loop can see time has moved forward.
*/
void icount_update(CPUState *cpu);
/* get raw icount value */
int64_t icount_get_raw(void);
/* return the virtual CPU time in ns, based on the instruction counter. */
int64_t icount_get(void);
/*
* convert an instruction counter value to ns, based on the icount shift.
* This shift is set as a fixed value with the icount "shift" option
* (precise mode), or it is constantly approximated and corrected at
* runtime in adaptive mode.
*/
int64_t icount_to_ns(int64_t icount);
/**
* icount_configure: configure the icount options, including "shift"
* @opts: Options to parse
* @errp: pointer to a NULL-initialized error object
*
* Return: true on success, else false setting @errp with error
*/
bool icount_configure(QemuOpts *opts, Error **errp);
/* used by tcg vcpu thread to calc icount budget */
int64_t icount_round(int64_t count);
/* if the CPUs are idle, start accounting real time to virtual clock. */
void icount_start_warp_timer(void);
void icount_account_warp_timer(void);
void icount_notify_exit(void);
#endif /* EXEC_ICOUNT_H */
|