VirtualBox

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

Last change on this file since 87766 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.3 KB
Line 
1/* $Id: STAMInternal.h 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * STAM Internal Header.
4 */
5
6/*
7 * Copyright (C) 2006-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef VMM_INCLUDED_SRC_include_STAMInternal_h
19#define VMM_INCLUDED_SRC_include_STAMInternal_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <VBox/cdefs.h>
25#include <VBox/types.h>
26#include <VBox/vmm/stam.h>
27#include <VBox/vmm/gvmm.h>
28#include <VBox/vmm/gmm.h>
29#include <iprt/list.h>
30#include <iprt/semaphore.h>
31
32
33
34RT_C_DECLS_BEGIN
35
36/** @defgroup grp_stam_int Internals
37 * @ingroup grp_stam
38 * @internal
39 * @{
40 */
41
42/** Pointer to sample descriptor. */
43typedef struct STAMDESC *PSTAMDESC;
44/** Pointer to a sample lookup node. */
45typedef struct STAMLOOKUP *PSTAMLOOKUP;
46
47/**
48 * Sample lookup node.
49 */
50typedef struct STAMLOOKUP
51{
52 /** The parent lookup record. This is NULL for the root node. */
53 PSTAMLOOKUP pParent;
54 /** Array of children (using array for binary searching). */
55 PSTAMLOOKUP *papChildren;
56 /** Pointer to the description node, if any. */
57 PSTAMDESC pDesc;
58 /** Number of decentants with descriptors. (Use for freeing up sub-trees.) */
59 uint32_t cDescsInTree;
60 /** The number of children. */
61 uint16_t cChildren;
62 /** The index in the parent paChildren array. UINT16_MAX for the root node. */
63 uint16_t iParent;
64 /** The path offset. */
65 uint16_t off;
66 /** The size of the path component. */
67 uint16_t cch;
68 /** The name (variable size). */
69 char szName[1];
70} STAMLOOKUP;
71
72
73/**
74 * Sample descriptor.
75 */
76typedef struct STAMDESC
77{
78 /** Our entry in the big linear list. */
79 RTLISTNODE ListEntry;
80 /** Pointer to our lookup node. */
81 PSTAMLOOKUP pLookup;
82 /** Sample name. */
83 const char *pszName;
84 /** Sample type. */
85 STAMTYPE enmType;
86 /** Visibility type. */
87 STAMVISIBILITY enmVisibility;
88 /** Pointer to the sample data. */
89 union STAMDESCSAMPLEDATA
90 {
91 /** Counter. */
92 PSTAMCOUNTER pCounter;
93 /** Profile. */
94 PSTAMPROFILE pProfile;
95 /** Advanced profile. */
96 PSTAMPROFILEADV pProfileAdv;
97 /** Ratio, unsigned 32-bit. */
98 PSTAMRATIOU32 pRatioU32;
99 /** unsigned 8-bit. */
100 uint8_t *pu8;
101 /** unsigned 16-bit. */
102 uint16_t *pu16;
103 /** unsigned 32-bit. */
104 uint32_t *pu32;
105 /** unsigned 64-bit. */
106 uint64_t *pu64;
107 /** Simple void pointer. */
108 void *pv;
109 /** Boolean. */
110 bool *pf;
111 /** */
112 struct STAMDESCSAMPLEDATACALLBACKS
113 {
114 /** The same pointer. */
115 void *pvSample;
116 /** Pointer to the reset callback. */
117 PFNSTAMR3CALLBACKRESET pfnReset;
118 /** Pointer to the print callback. */
119 PFNSTAMR3CALLBACKPRINT pfnPrint;
120 } Callback;
121 } u;
122 /** Unit. */
123 STAMUNIT enmUnit;
124 /** The refresh group number (STAM_REFRESH_GRP_XXX). */
125 uint8_t iRefreshGroup;
126 /** Description. */
127 const char *pszDesc;
128} STAMDESC;
129
130
131/**
132 * STAM data kept in the UVM.
133 */
134typedef struct STAMUSERPERVM
135{
136 /** List of samples. */
137 RTLISTANCHOR List;
138 /** Root of the lookup tree. */
139 PSTAMLOOKUP pRoot;
140
141 /** RW Lock for the list and tree. */
142 RTSEMRW RWSem;
143
144 /** The copy of the GVMM statistics. */
145 GVMMSTATS GVMMStats;
146 /** The number of registered host CPU leaves. */
147 uint32_t cRegisteredHostCpus;
148
149 /** Explicit alignment padding. */
150 uint32_t uAlignment;
151 /** The copy of the GMM statistics. */
152 GMMSTATS GMMStats;
153} STAMUSERPERVM;
154#ifdef IN_RING3
155AssertCompileMemberAlignment(STAMUSERPERVM, GMMStats, 8);
156#endif
157
158/** Pointer to the STAM data kept in the UVM. */
159typedef STAMUSERPERVM *PSTAMUSERPERVM;
160
161
162/** Locks the sample descriptors for reading. */
163#define STAM_LOCK_RD(pUVM) do { int rcSem = RTSemRWRequestRead(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
164/** Locks the sample descriptors for writing. */
165#define STAM_LOCK_WR(pUVM) do { int rcSem = RTSemRWRequestWrite(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
166/** UnLocks the sample descriptors after reading. */
167#define STAM_UNLOCK_RD(pUVM) do { int rcSem = RTSemRWReleaseRead(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
168/** UnLocks the sample descriptors after writing. */
169#define STAM_UNLOCK_WR(pUVM) do { int rcSem = RTSemRWReleaseWrite(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
170/** Lazy initialization */
171#define STAM_LAZY_INIT(pUVM) do { } while (0)
172
173/** @} */
174
175RT_C_DECLS_END
176
177#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