VirtualBox

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

Last change on this file since 102828 was 102828, checked in by vboxsync, 11 months ago

VMM/STAM: Added two new aggregate sample types. bugref:10371

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 6.7 KB
Line 
1/* $Id: STAMInternal.h 102828 2024-01-11 01:47:40Z 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;
102 /** Max number of items paSummands can hold. */
103 uint8_t cSummandsAlloc;
104 /** The number of summands in paSummands. */
105 uint8_t cSummands;
106 /** Pointer to the description of each of the samples to be summed up. */
107 RT_FLEXIBLE_ARRAY_EXTENSION
108 PSTAMDESC apSummands[RT_FLEXIBLE_ARRAY];
109} STAMSUMSAMPLE;
110/** Pointer to the data for a sum sample. */
111typedef STAMSUMSAMPLE *PSTAMSUMSAMPLE;
112
113
114/**
115 * Sample descriptor.
116 */
117typedef struct STAMDESC
118{
119 /** Our entry in the big linear list. */
120 RTLISTNODE ListEntry;
121 /** Pointer to our lookup node. */
122 PSTAMLOOKUP pLookup;
123 /** Sample name. */
124 const char *pszName;
125 /** Sample type. */
126 STAMTYPE enmType;
127 /** Visibility type. */
128 STAMVISIBILITY enmVisibility;
129 /** Pointer to the sample data. */
130 union STAMDESCSAMPLEDATA
131 {
132 /** Counter. */
133 PSTAMCOUNTER pCounter;
134 /** Profile. */
135 PSTAMPROFILE pProfile;
136 /** Advanced profile. */
137 PSTAMPROFILEADV pProfileAdv;
138 /** Ratio, unsigned 32-bit. */
139 PSTAMRATIOU32 pRatioU32;
140 /** unsigned 8-bit. */
141 uint8_t *pu8;
142 /** unsigned 16-bit. */
143 uint16_t *pu16;
144 /** unsigned 32-bit. */
145 uint32_t *pu32;
146 /** unsigned 64-bit. */
147 uint64_t *pu64;
148 /** Simple void pointer. */
149 void *pv;
150 /** Boolean. */
151 bool *pf;
152 /** */
153 struct STAMDESCSAMPLEDATACALLBACKS
154 {
155 /** The same pointer. */
156 void *pvSample;
157 /** Pointer to the reset callback. */
158 PFNSTAMR3CALLBACKRESET pfnReset;
159 /** Pointer to the print callback. */
160 PFNSTAMR3CALLBACKPRINT pfnPrint;
161 } Callback;
162 /** Sum. This is allocated separately. */
163 PSTAMSUMSAMPLE pSum;
164 } u;
165 /** Unit. */
166 STAMUNIT enmUnit;
167 /** The refresh group number (STAM_REFRESH_GRP_XXX). */
168 uint8_t iRefreshGroup;
169 /** Description. */
170 const char *pszDesc;
171} STAMDESC;
172
173
174/**
175 * STAM data kept in the UVM.
176 */
177typedef struct STAMUSERPERVM
178{
179 /** List of samples. */
180 RTLISTANCHOR List;
181 /** Root of the lookup tree. */
182 PSTAMLOOKUP pRoot;
183
184 /** RW Lock for the list and tree. */
185 RTSEMRW RWSem;
186
187 /** The copy of the GVMM statistics. */
188 GVMMSTATS GVMMStats;
189 /** The number of registered host CPU leaves. */
190 uint32_t cRegisteredHostCpus;
191
192 /** Explicit alignment padding. */
193 uint32_t uAlignment;
194 /** The copy of the GMM statistics. */
195 GMMSTATS GMMStats;
196} STAMUSERPERVM;
197#ifdef IN_RING3
198AssertCompileMemberAlignment(STAMUSERPERVM, GMMStats, 8);
199#endif
200
201/** Pointer to the STAM data kept in the UVM. */
202typedef STAMUSERPERVM *PSTAMUSERPERVM;
203
204
205/** Locks the sample descriptors for reading. */
206#define STAM_LOCK_RD(pUVM) do { int rcSem = RTSemRWRequestRead(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
207/** Locks the sample descriptors for writing. */
208#define STAM_LOCK_WR(pUVM) do { int rcSem = RTSemRWRequestWrite(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
209/** UnLocks the sample descriptors after reading. */
210#define STAM_UNLOCK_RD(pUVM) do { int rcSem = RTSemRWReleaseRead(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
211/** UnLocks the sample descriptors after writing. */
212#define STAM_UNLOCK_WR(pUVM) do { int rcSem = RTSemRWReleaseWrite(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
213/** Lazy initialization */
214#define STAM_LAZY_INIT(pUVM) do { } while (0)
215
216/** @} */
217
218RT_C_DECLS_END
219
220#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