VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR0/GMMR0Internal.h@ 39333

Last change on this file since 39333 was 37248, checked in by vboxsync, 13 years ago

GMMR0: Rewrote the allocator.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.0 KB
Line 
1/* $Id: GMMR0Internal.h 37248 2011-05-30 10:02:24Z vboxsync $ */
2/** @file
3 * GMM - The Global Memory Manager, Internal Header.
4 */
5
6/*
7 * Copyright (C) 2007 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 ___GMMR0Internal_h
19#define ___GMMR0Internal_h
20
21#include <VBox/vmm/gmm.h>
22#include <iprt/avl.h>
23
24/**
25 * The allocation sizes.
26 */
27typedef struct GMMVMSIZES
28{
29 /** The number of pages of base memory.
30 * This is the sum of RAM, ROMs and handy pages. */
31 uint64_t cBasePages;
32 /** The number of pages for the shadow pool. (Can be squeezed for memory.) */
33 uint32_t cShadowPages;
34 /** The number of pages for fixed allocations like MMIO2 and the hyper heap. */
35 uint32_t cFixedPages;
36} GMMVMSIZES;
37/** Pointer to a GMMVMSIZES. */
38typedef GMMVMSIZES *PGMMVMSIZES;
39
40
41/**
42 * Shared module registration info (per VM)
43 */
44typedef struct GMMSHAREDMODULEPERVM
45{
46 /** Tree node. */
47 AVLGCPTRNODECORE Core;
48
49 /** Pointer to global shared module info. */
50 PGMMSHAREDMODULE pGlobalModule;
51
52 /** Set if another VM registered a different shared module at the same base address. */
53 bool fCollision;
54 /** Alignment. */
55 bool bAlignment[3];
56
57 /** Number of included region descriptors */
58 uint32_t cRegions;
59
60 /** Shared region descriptor(s). */
61 GMMSHAREDREGIONDESC aRegions[1];
62} GMMSHAREDMODULEPERVM;
63/** Pointer to a GMMSHAREDMODULEPERVM. */
64typedef GMMSHAREDMODULEPERVM *PGMMSHAREDMODULEPERVM;
65
66
67/** Pointer to a GMM allocation chunk. */
68typedef struct GMMCHUNK *PGMMCHUNK;
69
70
71/** The GMMCHUNK::cFree shift count employed by gmmR0SelectFreeSetList. */
72#define GMM_CHUNK_FREE_SET_SHIFT 4
73/** Index of the list containing completely unused chunks.
74 * The code ASSUMES this is the last list. */
75#define GMM_CHUNK_FREE_SET_UNUSED_LIST (GMM_CHUNK_NUM_PAGES >> GMM_CHUNK_FREE_SET_SHIFT)
76
77/**
78 * A set of free chunks.
79 */
80typedef struct GMMCHUNKFREESET
81{
82 /** The number of free pages in the set. */
83 uint64_t cFreePages;
84 /** The generation ID for the set. This is incremented whenever
85 * something is linked or unlinked from this set. */
86 uint64_t idGeneration;
87 /** Chunks ordered by increasing number of free pages.
88 * In the final list the chunks are completely unused. */
89 PGMMCHUNK apLists[GMM_CHUNK_FREE_SET_UNUSED_LIST + 1];
90} GMMCHUNKFREESET;
91
92
93
94/**
95 * The per-VM GMM data.
96 */
97typedef struct GMMPERVM
98{
99 /** Free set for use in bound mode. */
100 GMMCHUNKFREESET Private;
101
102 /** The reservations. */
103 GMMVMSIZES Reserved;
104 /** The actual allocations.
105 * This includes both private and shared page allocations. */
106 GMMVMSIZES Allocated;
107
108 /** The current number of private pages. */
109 uint64_t cPrivatePages;
110 /** The current number of shared pages. */
111 uint64_t cSharedPages;
112 /** The current over-commitment policy. */
113 GMMOCPOLICY enmPolicy;
114 /** The VM priority for arbitrating VMs in low and out of memory situation.
115 * Like which VMs to start squeezing first. */
116 GMMPRIORITY enmPriority;
117 /** Hints at the last chunk we allocated some memory from. */
118 uint32_t idLastChunkHint;
119
120 /** The current number of ballooned pages. */
121 uint64_t cBalloonedPages;
122 /** The max number of pages that can be ballooned. */
123 uint64_t cMaxBalloonedPages;
124 /** The number of pages we've currently requested the guest to give us.
125 * This is 0 if no pages currently requested. */
126 uint64_t cReqBalloonedPages;
127 /** The number of pages the guest has given us in response to the request.
128 * This is not reset on request completed and may be used in later decisions. */
129 uint64_t cReqActuallyBalloonedPages;
130 /** The number of pages we've currently requested the guest to take back. */
131 uint64_t cReqDeflatePages;
132
133 /** Shared module tree (per-vm). */
134 PAVLGCPTRNODECORE pSharedModuleTree;
135
136 /** Whether ballooning is enabled or not. */
137 bool fBallooningEnabled;
138
139 /** Whether shared paging is enabled or not. */
140 bool fSharedPagingEnabled;
141
142 /** Whether the VM is allowed to allocate memory or not.
143 * This is used when the reservation update request fails or when the VM has
144 * been told to suspend/save/die in an out-of-memory case. */
145 bool fMayAllocate;
146} GMMPERVM;
147/** Pointer to the per-VM GMM data. */
148typedef GMMPERVM *PGMMPERVM;
149
150#endif
151
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