VirtualBox

source: vbox/trunk/src/VBox/VMM/include/STAMInternal.h@ 105072

Last change on this file since 105072 was 103393, checked in by vboxsync, 10 months ago

VMM/IEM,STAM: Some more liveness experiments. Adjusted the STAMR3RegisterPctOfSum[V] interface for more flexibility. bugref:10372

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 6.8 KB
Line 
1/* $Id: STAMInternal.h 103393 2024-02-16 00:04:24Z vboxsync $ */
2/** @file
3 * STAM Internal Header.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VMM_INCLUDED_SRC_include_STAMInternal_h
29#define VMM_INCLUDED_SRC_include_STAMInternal_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <VBox/cdefs.h>
35#include <VBox/types.h>
36#include <VBox/vmm/stam.h>
37#include <VBox/vmm/gvmm.h>
38#include <VBox/vmm/gmm.h>
39#include <iprt/list.h>
40#include <iprt/semaphore.h>
41
42
43
44RT_C_DECLS_BEGIN
45
46/** @defgroup grp_stam_int Internals
47 * @ingroup grp_stam
48 * @internal
49 * @{
50 */
51
52/** Pointer to sample descriptor. */
53typedef struct STAMDESC *PSTAMDESC;
54/** Pointer to a sample lookup node. */
55typedef struct STAMLOOKUP *PSTAMLOOKUP;
56
57/**
58 * Sample lookup node.
59 */
60typedef struct STAMLOOKUP
61{
62 /** The parent lookup record. This is NULL for the root node. */
63 PSTAMLOOKUP pParent;
64 /** Array of children (using array for binary searching). */
65 PSTAMLOOKUP *papChildren;
66 /** Pointer to the description node, if any. */
67 PSTAMDESC pDesc;
68 /** Number of decentants with descriptors. (Use for freeing up sub-trees.) */
69 uint32_t cDescsInTree;
70 /** The number of children. */
71 uint16_t cChildren;
72 /** The index in the parent paChildren array. UINT16_MAX for the root node. */
73 uint16_t iParent;
74 /** The path offset. */
75 uint16_t off;
76 /** The size of the path component. */
77 uint16_t cch;
78 /** The name (variable size). */
79 char szName[1];
80} STAMLOOKUP;
81
82
83/**
84 * The "sample data" of a STAMTYPE_INTERNAL_SUM sample.
85 */
86typedef struct STAMSUMSAMPLE
87{
88 /** The sum value. */
89 union
90 {
91 /** Any counter or unsigned number type. */
92 STAMCOUNTER Counter;
93 /** Profile or advance profile. */
94 STAMPROFILE Profile;
95 } u;
96 /** The actual type of the SUM. */
97 STAMTYPE enmType;
98 /** The type of the first sample. */
99 uint8_t enmTypeFirst;
100 /** Used to decide the unit when gathering summands during registration. */
101 uint8_t enmUnit : 7;
102 /** Used by pct-of-sum to decide whether to include the value in the sum. */
103 uint8_t fAddValueToSum : 1;
104 /** Max number of items paSummands can hold. */
105 uint8_t cSummandsAlloc;
106 /** The number of summands in paSummands. */
107 uint8_t cSummands;
108 /** Pointer to the description of each of the samples to be summed up. */
109 RT_FLEXIBLE_ARRAY_EXTENSION
110 PSTAMDESC apSummands[RT_FLEXIBLE_ARRAY];
111} STAMSUMSAMPLE;
112/** Pointer to the data for a sum sample. */
113typedef STAMSUMSAMPLE *PSTAMSUMSAMPLE;
114
115
116/**
117 * Sample descriptor.
118 */
119typedef struct STAMDESC
120{
121 /** Our entry in the big linear list. */
122 RTLISTNODE ListEntry;
123 /** Pointer to our lookup node. */
124 PSTAMLOOKUP pLookup;
125 /** Sample name. */
126 const char *pszName;
127 /** Sample type. */
128 STAMTYPE enmType;
129 /** Visibility type. */
130 STAMVISIBILITY enmVisibility;
131 /** Pointer to the sample data. */
132 union STAMDESCSAMPLEDATA
133 {
134 /** Counter. */
135 PSTAMCOUNTER pCounter;
136 /** Profile. */
137 PSTAMPROFILE pProfile;
138 /** Advanced profile. */
139 PSTAMPROFILEADV pProfileAdv;
140 /** Ratio, unsigned 32-bit. */
141 PSTAMRATIOU32 pRatioU32;
142 /** unsigned 8-bit. */
143 uint8_t *pu8;
144 /** unsigned 16-bit. */
145 uint16_t *pu16;
146 /** unsigned 32-bit. */
147 uint32_t *pu32;
148 /** unsigned 64-bit. */
149 uint64_t *pu64;
150 /** Simple void pointer. */
151 void *pv;
152 /** Boolean. */
153 bool *pf;
154 /** */
155 struct STAMDESCSAMPLEDATACALLBACKS
156 {
157 /** The same pointer. */
158 void *pvSample;
159 /** Pointer to the reset callback. */
160 PFNSTAMR3CALLBACKRESET pfnReset;
161 /** Pointer to the print callback. */
162 PFNSTAMR3CALLBACKPRINT pfnPrint;
163 } Callback;
164 /** Sum. This is allocated separately. */
165 PSTAMSUMSAMPLE pSum;
166 } u;
167 /** Unit. */
168 STAMUNIT enmUnit;
169 /** The refresh group number (STAM_REFRESH_GRP_XXX). */
170 uint8_t iRefreshGroup;
171 /** Description. */
172 const char *pszDesc;
173} STAMDESC;
174
175
176/**
177 * STAM data kept in the UVM.
178 */
179typedef struct STAMUSERPERVM
180{
181 /** List of samples. */
182 RTLISTANCHOR List;
183 /** Root of the lookup tree. */
184 PSTAMLOOKUP pRoot;
185
186 /** RW Lock for the list and tree. */
187 RTSEMRW RWSem;
188
189 /** The copy of the GVMM statistics. */
190 GVMMSTATS GVMMStats;
191 /** The number of registered host CPU leaves. */
192 uint32_t cRegisteredHostCpus;
193
194 /** Explicit alignment padding. */
195 uint32_t uAlignment;
196 /** The copy of the GMM statistics. */
197 GMMSTATS GMMStats;
198} STAMUSERPERVM;
199#ifdef IN_RING3
200AssertCompileMemberAlignment(STAMUSERPERVM, GMMStats, 8);
201#endif
202
203/** Pointer to the STAM data kept in the UVM. */
204typedef STAMUSERPERVM *PSTAMUSERPERVM;
205
206
207/** Locks the sample descriptors for reading. */
208#define STAM_LOCK_RD(pUVM) do { int rcSem = RTSemRWRequestRead(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
209/** Locks the sample descriptors for writing. */
210#define STAM_LOCK_WR(pUVM) do { int rcSem = RTSemRWRequestWrite(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
211/** UnLocks the sample descriptors after reading. */
212#define STAM_UNLOCK_RD(pUVM) do { int rcSem = RTSemRWReleaseRead(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
213/** UnLocks the sample descriptors after writing. */
214#define STAM_UNLOCK_WR(pUVM) do { int rcSem = RTSemRWReleaseWrite(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
215/** Lazy initialization */
216#define STAM_LAZY_INIT(pUVM) do { } while (0)
217
218/** @} */
219
220RT_C_DECLS_END
221
222#endif /* !VMM_INCLUDED_SRC_include_STAMInternal_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette