blob: 6f2cfdbd4bd8b942ecc27a724b3345ffcf2bd5d9 (
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
/* $Id: STAMInternal.h $ */
/** @file
* STAM Internal Header.
*/
/*
* Copyright (C) 2006-2023 Oracle and/or its affiliates.
*
* This file is part of VirtualBox base platform packages, as
* available from https://www.virtualbox.org.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, in version 3 of the
* License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <https://www.gnu.org/licenses>.
*
* SPDX-License-Identifier: GPL-3.0-only
*/
#ifndef VMM_INCLUDED_SRC_include_STAMInternal_h
#define VMM_INCLUDED_SRC_include_STAMInternal_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif
#include <VBox/cdefs.h>
#include <VBox/types.h>
#include <VBox/vmm/stam.h>
#include <VBox/vmm/gvmm.h>
#include <VBox/vmm/gmm.h>
#include <iprt/list.h>
#include <iprt/semaphore.h>
RT_C_DECLS_BEGIN
/** @defgroup grp_stam_int Internals
* @ingroup grp_stam
* @internal
* @{
*/
/** Pointer to sample descriptor. */
typedef struct STAMDESC *PSTAMDESC;
/** Pointer to a sample lookup node. */
typedef struct STAMLOOKUP *PSTAMLOOKUP;
/**
* Sample lookup node.
*/
typedef struct STAMLOOKUP
{
/** The parent lookup record. This is NULL for the root node. */
PSTAMLOOKUP pParent;
/** Array of children (using array for binary searching). */
PSTAMLOOKUP *papChildren;
/** Pointer to the description node, if any. */
PSTAMDESC pDesc;
/** Number of decentants with descriptors. (Use for freeing up sub-trees.) */
uint32_t cDescsInTree;
/** The number of children. */
uint16_t cChildren;
/** The index in the parent paChildren array. UINT16_MAX for the root node. */
uint16_t iParent;
/** The path offset. */
uint16_t off;
/** The size of the path component. */
uint16_t cch;
/** The name (variable size). */
char szName[1];
} STAMLOOKUP;
/**
* Sample descriptor.
*/
typedef struct STAMDESC
{
/** Our entry in the big linear list. */
RTLISTNODE ListEntry;
/** Pointer to our lookup node. */
PSTAMLOOKUP pLookup;
/** Sample name. */
const char *pszName;
/** Sample type. */
STAMTYPE enmType;
/** Visibility type. */
STAMVISIBILITY enmVisibility;
/** Pointer to the sample data. */
union STAMDESCSAMPLEDATA
{
/** Counter. */
PSTAMCOUNTER pCounter;
/** Profile. */
PSTAMPROFILE pProfile;
/** Advanced profile. */
PSTAMPROFILEADV pProfileAdv;
/** Ratio, unsigned 32-bit. */
PSTAMRATIOU32 pRatioU32;
/** unsigned 8-bit. */
uint8_t *pu8;
/** unsigned 16-bit. */
uint16_t *pu16;
/** unsigned 32-bit. */
uint32_t *pu32;
/** unsigned 64-bit. */
uint64_t *pu64;
/** Simple void pointer. */
void *pv;
/** Boolean. */
bool *pf;
/** */
struct STAMDESCSAMPLEDATACALLBACKS
{
/** The same pointer. */
void *pvSample;
/** Pointer to the reset callback. */
PFNSTAMR3CALLBACKRESET pfnReset;
/** Pointer to the print callback. */
PFNSTAMR3CALLBACKPRINT pfnPrint;
} Callback;
} u;
/** Unit. */
STAMUNIT enmUnit;
/** The refresh group number (STAM_REFRESH_GRP_XXX). */
uint8_t iRefreshGroup;
/** Description. */
const char *pszDesc;
} STAMDESC;
/**
* STAM data kept in the UVM.
*/
typedef struct STAMUSERPERVM
{
/** List of samples. */
RTLISTANCHOR List;
/** Root of the lookup tree. */
PSTAMLOOKUP pRoot;
/** RW Lock for the list and tree. */
RTSEMRW RWSem;
/** The copy of the GVMM statistics. */
GVMMSTATS GVMMStats;
/** The number of registered host CPU leaves. */
uint32_t cRegisteredHostCpus;
/** Explicit alignment padding. */
uint32_t uAlignment;
/** The copy of the GMM statistics. */
GMMSTATS GMMStats;
} STAMUSERPERVM;
#ifdef IN_RING3
AssertCompileMemberAlignment(STAMUSERPERVM, GMMStats, 8);
#endif
/** Pointer to the STAM data kept in the UVM. */
typedef STAMUSERPERVM *PSTAMUSERPERVM;
/** Locks the sample descriptors for reading. */
#define STAM_LOCK_RD(pUVM) do { int rcSem = RTSemRWRequestRead(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
/** Locks the sample descriptors for writing. */
#define STAM_LOCK_WR(pUVM) do { int rcSem = RTSemRWRequestWrite(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
/** UnLocks the sample descriptors after reading. */
#define STAM_UNLOCK_RD(pUVM) do { int rcSem = RTSemRWReleaseRead(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
/** UnLocks the sample descriptors after writing. */
#define STAM_UNLOCK_WR(pUVM) do { int rcSem = RTSemRWReleaseWrite(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
/** Lazy initialization */
#define STAM_LAZY_INIT(pUVM) do { } while (0)
/** @} */
RT_C_DECLS_END
#endif /* !VMM_INCLUDED_SRC_include_STAMInternal_h */
|