VirtualBox

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

Last change on this file since 97441 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.6 KB
Line 
1/* $Id: STAMInternal.h 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * STAM Internal Header.
4 */
5
6/*
7 * Copyright (C) 2006-2022 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 * Sample descriptor.
85 */
86typedef struct STAMDESC
87{
88 /** Our entry in the big linear list. */
89 RTLISTNODE ListEntry;
90 /** Pointer to our lookup node. */
91 PSTAMLOOKUP pLookup;
92 /** Sample name. */
93 const char *pszName;
94 /** Sample type. */
95 STAMTYPE enmType;
96 /** Visibility type. */
97 STAMVISIBILITY enmVisibility;
98 /** Pointer to the sample data. */
99 union STAMDESCSAMPLEDATA
100 {
101 /** Counter. */
102 PSTAMCOUNTER pCounter;
103 /** Profile. */
104 PSTAMPROFILE pProfile;
105 /** Advanced profile. */
106 PSTAMPROFILEADV pProfileAdv;
107 /** Ratio, unsigned 32-bit. */
108 PSTAMRATIOU32 pRatioU32;
109 /** unsigned 8-bit. */
110 uint8_t *pu8;
111 /** unsigned 16-bit. */
112 uint16_t *pu16;
113 /** unsigned 32-bit. */
114 uint32_t *pu32;
115 /** unsigned 64-bit. */
116 uint64_t *pu64;
117 /** Simple void pointer. */
118 void *pv;
119 /** Boolean. */
120 bool *pf;
121 /** */
122 struct STAMDESCSAMPLEDATACALLBACKS
123 {
124 /** The same pointer. */
125 void *pvSample;
126 /** Pointer to the reset callback. */
127 PFNSTAMR3CALLBACKRESET pfnReset;
128 /** Pointer to the print callback. */
129 PFNSTAMR3CALLBACKPRINT pfnPrint;
130 } Callback;
131 } u;
132 /** Unit. */
133 STAMUNIT enmUnit;
134 /** The refresh group number (STAM_REFRESH_GRP_XXX). */
135 uint8_t iRefreshGroup;
136 /** Description. */
137 const char *pszDesc;
138} STAMDESC;
139
140
141/**
142 * STAM data kept in the UVM.
143 */
144typedef struct STAMUSERPERVM
145{
146 /** List of samples. */
147 RTLISTANCHOR List;
148 /** Root of the lookup tree. */
149 PSTAMLOOKUP pRoot;
150
151 /** RW Lock for the list and tree. */
152 RTSEMRW RWSem;
153
154 /** The copy of the GVMM statistics. */
155 GVMMSTATS GVMMStats;
156 /** The number of registered host CPU leaves. */
157 uint32_t cRegisteredHostCpus;
158
159 /** Explicit alignment padding. */
160 uint32_t uAlignment;
161 /** The copy of the GMM statistics. */
162 GMMSTATS GMMStats;
163} STAMUSERPERVM;
164#ifdef IN_RING3
165AssertCompileMemberAlignment(STAMUSERPERVM, GMMStats, 8);
166#endif
167
168/** Pointer to the STAM data kept in the UVM. */
169typedef STAMUSERPERVM *PSTAMUSERPERVM;
170
171
172/** Locks the sample descriptors for reading. */
173#define STAM_LOCK_RD(pUVM) do { int rcSem = RTSemRWRequestRead(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
174/** Locks the sample descriptors for writing. */
175#define STAM_LOCK_WR(pUVM) do { int rcSem = RTSemRWRequestWrite(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
176/** UnLocks the sample descriptors after reading. */
177#define STAM_UNLOCK_RD(pUVM) do { int rcSem = RTSemRWReleaseRead(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
178/** UnLocks the sample descriptors after writing. */
179#define STAM_UNLOCK_WR(pUVM) do { int rcSem = RTSemRWReleaseWrite(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
180/** Lazy initialization */
181#define STAM_LAZY_INIT(pUVM) do { } while (0)
182
183/** @} */
184
185RT_C_DECLS_END
186
187#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