VirtualBox

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

Last change on this file since 72580 was 72300, checked in by vboxsync, 7 years ago

NEM,STAM: Partition memory statistics for NEM. bugref:9044

  • STAM: Redid the way we handle statistics requiring fetching data from ring-0 (or elsewhere) by introducing a refresh group concept. We'll refresh the statistics for a group if needed and only once per enumeration/query. There's a new registration API for these.
  • NEM: Added memory balance statistics for the partition. Some failed fumbling thru VID.DLL/SYS, before realizing that hypercall is the only way to get at them.
  • NEM: Added a hypervisor input/output page buffer for non-EMT threads so we can get statistics. Put the related data and code into separate structure to save duplication.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.3 KB
Line 
1/* $Id: STAMInternal.h 72300 2018-05-23 15:13:06Z vboxsync $ */
2/** @file
3 * STAM Internal Header.
4 */
5
6/*
7 * Copyright (C) 2006-2017 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 ___STAMInternal_h
19#define ___STAMInternal_h
20
21#include <VBox/cdefs.h>
22#include <VBox/types.h>
23#include <VBox/vmm/stam.h>
24#include <VBox/vmm/gvmm.h>
25#include <VBox/vmm/gmm.h>
26#include <iprt/list.h>
27#include <iprt/semaphore.h>
28
29
30
31RT_C_DECLS_BEGIN
32
33/** @defgroup grp_stam_int Internals
34 * @ingroup grp_stam
35 * @internal
36 * @{
37 */
38
39/** Enables the lookup tree.
40 * This is an optimization for speeding up registration as well as query. */
41#define STAM_WITH_LOOKUP_TREE
42
43
44/** Pointer to sample descriptor. */
45typedef struct STAMDESC *PSTAMDESC;
46/** Pointer to a sample lookup node. */
47typedef struct STAMLOOKUP *PSTAMLOOKUP;
48
49/**
50 * Sample lookup node.
51 */
52typedef struct STAMLOOKUP
53{
54 /** The parent lookup record. This is NULL for the root node. */
55 PSTAMLOOKUP pParent;
56 /** Array of children (using array for binary searching). */
57 PSTAMLOOKUP *papChildren;
58 /** Pointer to the description node, if any. */
59 PSTAMDESC pDesc;
60 /** Number of decentants with descriptors. (Use for freeing up sub-trees.) */
61 uint32_t cDescsInTree;
62 /** The number of children. */
63 uint16_t cChildren;
64 /** The index in the parent paChildren array. UINT16_MAX for the root node. */
65 uint16_t iParent;
66 /** The path offset. */
67 uint16_t off;
68 /** The size of the path component. */
69 uint16_t cch;
70 /** The name (variable size). */
71 char szName[1];
72} STAMLOOKUP;
73
74
75/**
76 * Sample descriptor.
77 */
78typedef struct STAMDESC
79{
80 /** Our entry in the big linear list. */
81 RTLISTNODE ListEntry;
82 /** Pointer to our lookup node. */
83 PSTAMLOOKUP pLookup;
84 /** Sample name. */
85 const char *pszName;
86 /** Sample type. */
87 STAMTYPE enmType;
88 /** Visibility type. */
89 STAMVISIBILITY enmVisibility;
90 /** Pointer to the sample data. */
91 union STAMDESCSAMPLEDATA
92 {
93 /** Counter. */
94 PSTAMCOUNTER pCounter;
95 /** Profile. */
96 PSTAMPROFILE pProfile;
97 /** Advanced profile. */
98 PSTAMPROFILEADV pProfileAdv;
99 /** Ratio, unsigned 32-bit. */
100 PSTAMRATIOU32 pRatioU32;
101 /** unsigned 8-bit. */
102 uint8_t *pu8;
103 /** unsigned 16-bit. */
104 uint16_t *pu16;
105 /** unsigned 32-bit. */
106 uint32_t *pu32;
107 /** unsigned 64-bit. */
108 uint64_t *pu64;
109 /** Simple void pointer. */
110 void *pv;
111 /** Boolean. */
112 bool *pf;
113 /** */
114 struct STAMDESCSAMPLEDATACALLBACKS
115 {
116 /** The same pointer. */
117 void *pvSample;
118 /** Pointer to the reset callback. */
119 PFNSTAMR3CALLBACKRESET pfnReset;
120 /** Pointer to the print callback. */
121 PFNSTAMR3CALLBACKPRINT pfnPrint;
122 } Callback;
123 } u;
124 /** Unit. */
125 STAMUNIT enmUnit;
126 /** The refresh group number (STAM_REFRESH_GRP_XXX). */
127 uint8_t iRefreshGroup;
128 /** Description. */
129 const char *pszDesc;
130} STAMDESC;
131
132
133/**
134 * STAM data kept in the UVM.
135 */
136typedef struct STAMUSERPERVM
137{
138 /** List of samples. */
139 RTLISTANCHOR List;
140 /** Root of the lookup tree. */
141 PSTAMLOOKUP pRoot;
142
143 /** RW Lock for the list and tree. */
144 RTSEMRW RWSem;
145
146 /** The copy of the GVMM statistics. */
147 GVMMSTATS GVMMStats;
148 /** The number of registered host CPU leaves. */
149 uint32_t cRegisteredHostCpus;
150
151 /** Explicit alignment padding. */
152 uint32_t uAlignment;
153 /** The copy of the GMM statistics. */
154 GMMSTATS GMMStats;
155} STAMUSERPERVM;
156#ifdef IN_RING3
157AssertCompileMemberAlignment(STAMUSERPERVM, GMMStats, 8);
158#endif
159
160/** Pointer to the STAM data kept in the UVM. */
161typedef STAMUSERPERVM *PSTAMUSERPERVM;
162
163
164/** Locks the sample descriptors for reading. */
165#define STAM_LOCK_RD(pUVM) do { int rcSem = RTSemRWRequestRead(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
166/** Locks the sample descriptors for writing. */
167#define STAM_LOCK_WR(pUVM) do { int rcSem = RTSemRWRequestWrite(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
168/** UnLocks the sample descriptors after reading. */
169#define STAM_UNLOCK_RD(pUVM) do { int rcSem = RTSemRWReleaseRead(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
170/** UnLocks the sample descriptors after writing. */
171#define STAM_UNLOCK_WR(pUVM) do { int rcSem = RTSemRWReleaseWrite(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
172/** Lazy initialization */
173#define STAM_LAZY_INIT(pUVM) do { } while (0)
174
175/** @} */
176
177RT_C_DECLS_END
178
179#endif
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