MMPagePool.cpp revision 06bd6c6a26b2e582764aecd3ef178ed77da6fcb5
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller * MM - Memory Manager - Page Pool.
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller * Copyright (C) 2006-2007 Sun Microsystems, Inc.
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller * This file is part of VirtualBox Open Source Edition (OSE), as
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller * available from http://www.virtualbox.org. This file is free software;
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller * you can redistribute it and/or modify it under the terms of the GNU
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller * General Public License (GPL) as published by the Free Software
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller * Foundation, in version 2 as it comes in the "COPYING" file of the
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller * Clara, CA 95054 USA or visit http://www.sun.com if you need
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller * additional information or have any questions.
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller/*******************************************************************************
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller* Header Files *
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller*******************************************************************************/
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller/*******************************************************************************
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller* Internal Functions *
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Miller*******************************************************************************/
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Millerstatic void * mmR3PagePoolAlloc(PMMPAGEPOOL pPool);
ac3d0527956d93d93c68e3cd2d70d15ee1e654f6Brendan Millerstatic void mmR3PagePoolFree(PMMPAGEPOOL pPool, void *pv);
AssertReleaseReturn(sizeof(*pVM->mm.s.pPagePoolR3) + sizeof(*pVM->mm.s.pPagePoolLowR3) < PAGE_SIZE, VERR_INTERNAL_ERROR);
return rc;
STAM_REG(pVM, &pVM->mm.s.pPagePoolR3->cPages, STAMTYPE_U32, "/MM/Page/Def/cPages", STAMUNIT_PAGES, "Number of pages in the default pool.");
STAM_REG(pVM, &pVM->mm.s.pPagePoolR3->cFreePages, STAMTYPE_U32, "/MM/Page/Def/cFreePages", STAMUNIT_PAGES, "Number of free pages in the default pool.");
STAM_REG(pVM, &pVM->mm.s.pPagePoolR3->cSubPools, STAMTYPE_U32, "/MM/Page/Def/cSubPools", STAMUNIT_COUNT, "Number of sub pools in the default pool.");
STAM_REG(pVM, &pVM->mm.s.pPagePoolR3->cAllocCalls, STAMTYPE_COUNTER, "/MM/Page/Def/cAllocCalls", STAMUNIT_CALLS, "Number of MMR3PageAlloc() calls for the default pool.");
STAM_REG(pVM, &pVM->mm.s.pPagePoolR3->cFreeCalls, STAMTYPE_COUNTER, "/MM/Page/Def/cFreeCalls", STAMUNIT_CALLS, "Number of MMR3PageFree()+MMR3PageFreeByPhys() calls for the default pool.");
STAM_REG(pVM, &pVM->mm.s.pPagePoolR3->cToPhysCalls, STAMTYPE_COUNTER, "/MM/Page/Def/cToPhysCalls", STAMUNIT_CALLS, "Number of MMR3Page2Phys() calls for this pool.");
STAM_REG(pVM, &pVM->mm.s.pPagePoolR3->cToVirtCalls, STAMTYPE_COUNTER, "/MM/Page/Def/cToVirtCalls", STAMUNIT_CALLS, "Number of MMR3PagePhys2Page()+MMR3PageFreeByPhys() calls for the default pool.");
STAM_REG(pVM, &pVM->mm.s.pPagePoolR3->cErrors, STAMTYPE_COUNTER, "/MM/Page/Def/cErrors", STAMUNIT_ERRORS,"Number of errors for the default pool.");
STAM_REG(pVM, &pVM->mm.s.pPagePoolLowR3->cPages, STAMTYPE_U32, "/MM/Page/Low/cPages", STAMUNIT_PAGES, "Number of pages in the <4GB pool.");
STAM_REG(pVM, &pVM->mm.s.pPagePoolLowR3->cFreePages, STAMTYPE_U32, "/MM/Page/Low/cFreePages", STAMUNIT_PAGES, "Number of free pages in the <4GB pool.");
STAM_REG(pVM, &pVM->mm.s.pPagePoolLowR3->cSubPools, STAMTYPE_U32, "/MM/Page/Low/cSubPools", STAMUNIT_COUNT, "Number of sub pools in the <4GB pool.");
STAM_REG(pVM, &pVM->mm.s.pPagePoolLowR3->cAllocCalls, STAMTYPE_COUNTER, "/MM/Page/Low/cAllocCalls", STAMUNIT_CALLS, "Number of MMR3PageAllocLow() calls for the <4GB pool.");
STAM_REG(pVM, &pVM->mm.s.pPagePoolLowR3->cFreeCalls, STAMTYPE_COUNTER, "/MM/Page/Low/cFreeCalls", STAMUNIT_CALLS, "Number of MMR3PageFreeLow()+MMR3PageFreeByPhys() calls for the <4GB pool.");
STAM_REG(pVM, &pVM->mm.s.pPagePoolLowR3->cToPhysCalls,STAMTYPE_COUNTER, "/MM/Page/Low/cToPhysCalls", STAMUNIT_CALLS, "Number of MMR3Page2Phys() calls for the <4GB pool.");
STAM_REG(pVM, &pVM->mm.s.pPagePoolLowR3->cToVirtCalls,STAMTYPE_COUNTER, "/MM/Page/Low/cToVirtCalls", STAMUNIT_CALLS, "Number of MMR3PagePhys2Page()+MMR3PageFreeByPhys() calls for the <4GB pool.");
STAM_REG(pVM, &pVM->mm.s.pPagePoolLowR3->cErrors, STAMTYPE_COUNTER, "/MM/Page/Low/cErrors", STAMUNIT_ERRORS,"Number of errors for the <4GB pool.");
#ifndef VBOX_WITH_2X_4GB_ADDR_SPACE
return VINF_SUCCESS;
while (pSubPool)
while (pSubPool)
#ifndef VBOX_WITH_2X_4GB_ADDR_SPACE
#ifdef VBOX_WITH_STATISTICS
#ifdef USE_INLINE_ASM_BIT_OPS
if (iPage >= 0)
if ((u = *pu) != ~0U)
unsigned iBit = 0;
if (!(u & uMask))
iBit++;
pu++;
#ifdef VBOX_WITH_STATISTICS
AssertMsgFailed(("how strange, expected to find a free bit in %p, but didn't (%d pages supposed to be free!)\n", pSub, pSub->cPagesFree + 1));
+ sizeof(MMPPLOOKUPHCPTR),
(void **)&pSub);
return NULL;
#ifdef VBOX_WITH_STATISTICS
unsigned i = cPages;
i = cPages;
return NULL;
if ( !pLookup
|| (uint8_t *)pv >= (uint8_t *)pLookup->pSubPool->pvPages + (pLookup->pSubPool->cPages << PAGE_SHIFT)
#ifdef USE_INLINE_ASM_BIT_OPS
#ifdef VBOX_WITH_STATISTICS
if (pv)
return NIL_RTHCPHYS;
if (!pvPage)
if (pvPage)