VirtualBox

Changeset 27182 in vbox


Ignore:
Timestamp:
Mar 8, 2010 5:28:01 PM (15 years ago)
Author:
vboxsync
Message:

Saved the state of ballooned memory and reinflate when loading the saved state.

Location:
trunk/src/VBox/VMM
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PGM.cpp

    r27163 r27182  
    15741574    STAM_REL_REG(pVM, &pPGM->cWriteLockedPages,                  STAMTYPE_U32,     "/PGM/Page/cWriteLockedPages",        STAMUNIT_COUNT,     "The number of write(/read) locked pages.");
    15751575    STAM_REL_REG(pVM, &pPGM->cReadLockedPages,                   STAMTYPE_U32,     "/PGM/Page/cReadLockedPages",         STAMUNIT_COUNT,     "The number of read (only) locked pages.");
     1576    STAM_REL_REG(pVM, &pPGM->cBalloonedPages,                    STAMTYPE_U32,     "/PGM/Page/cBalloonedPages",          STAMUNIT_COUNT,     "The number of ballooned pages.");
    15761577    STAM_REL_REG(pVM, &pPGM->cHandyPages,                        STAMTYPE_U32,     "/PGM/Page/cHandyPages",              STAMUNIT_COUNT,     "The number of handy pages (not included in cAllPages).");
    15771578    STAM_REL_REG(pVM, &pPGM->cRelocations,                       STAMTYPE_COUNTER, "/PGM/cRelocations",                  STAMUNIT_OCCURENCES,"Number of hypervisor relocations.");
  • trunk/src/VBox/VMM/PGMInternal.h

    r27163 r27182  
    27822782    uint32_t                        cWriteLockedPages;  /**< The number of write locked pages. */
    27832783    uint32_t                        cReadLockedPages;   /**< The number of read locked pages. */
     2784    uint32_t                        cBalloonedPages;    /**< The number of ballooned pages. */
    27842785
    27852786    /** The number of times we were forced to change the hypervisor region location. */
  • trunk/src/VBox/VMM/PGMPhys.cpp

    r27173 r27182  
    843843    /* Notify GMM about the balloon change. */
    844844    rc = GMMR3BalloonedPages(pVM, (fInflate) ? GMMBALLOONACTION_INFLATE : GMMBALLOONACTION_DEFLATE, cPages);
     845    if (RT_SUCCESS(rc))
     846    {
     847        if (!fInflate)
     848        {
     849            Assert(pVM->pgm.s.cBalloonedPages >= cPages);
     850            pVM->pgm.s.cBalloonedPages -= cPages;
     851        }
     852        else
     853            pVM->pgm.s.cBalloonedPages += cPages;
     854    }
     855
    845856    pgmUnlock(pVM);
    846857    AssertLogRelRC(rc);
  • trunk/src/VBox/VMM/PGMSavedState.cpp

    r26165 r27182  
    5151/** Saved state data unit version.
    5252 * @todo remove the guest mappings from the saved state at next version change! */
    53 #define PGM_SAVED_STATE_VERSION                 11
     53#define PGM_SAVED_STATE_VERSION                 12
     54/** Saved state before the balloon change. */
     55#define PGM_SAVED_STATE_VERSION_PRE_BALLOON     11
    5456/** Saved state data unit version used during 3.1 development, misses the RAM
    5557 *  config. */
     
    114116    /** A20 gate mask.
    115117     * Our current approach to A20 emulation is to let REM do it and don't bother
    116      * anywhere else. The interesting Guests will be operating with it enabled anyway.
    117      * But whould need arrise, we'll subject physical addresses to this mask. */
     118     * anywhere else. The interesting guests will be operating with it enabled anyway.
     119     * But should the need arise, we'll subject physical addresses to this mask. */
    118120    RTGCPHYS                        GCPhysA20Mask;
    119121    /** A20 gate state - boolean! */
     
    128130*******************************************************************************/
    129131/** PGM fields to save/load. */
     132
    130133static const SSMFIELD s_aPGMFields[] =
    131134{
     
    133136    SSMFIELD_ENTRY_GCPTR(   PGM, GCPtrMappingFixed),
    134137    SSMFIELD_ENTRY(         PGM, cbMappingFixed),
     138    SSMFIELD_ENTRY(         PGM, cBalloonedPages),
     139    SSMFIELD_ENTRY_TERM()
     140};
     141
     142static const SSMFIELD s_aPGMFieldsPreBalloon[] =
     143{
     144    SSMFIELD_ENTRY(         PGM, fMappingsFixed),
     145    SSMFIELD_ENTRY_GCPTR(   PGM, GCPtrMappingFixed),
     146    SSMFIELD_ENTRY(         PGM, cbMappingFixed),
     147    SSMFIELD_ENTRY(         PGM, cBalloonedPages),
    135148    SSMFIELD_ENTRY_TERM()
    136149};
     
    27552768    if (uVersion >= PGM_SAVED_STATE_VERSION_3_0_0)
    27562769    {
    2757         rc = SSMR3GetStruct(pSSM, pPGM, &s_aPGMFields[0]);
     2770        if (uVersion > PGM_SAVED_STATE_VERSION_PRE_BALLOON)
     2771        {
     2772            rc = SSMR3GetStruct(pSSM, pPGM, &s_aPGMFields[0]);
     2773            if (    RT_SUCCESS(rc)
     2774                &&  pVM->pgm.s.cBalloonedPages)
     2775            {
     2776                rc = GMMR3BalloonedPages(pVM, GMMBALLOONACTION_INFLATE, pVM->pgm.s.cBalloonedPages);
     2777                AssertRC(rc);
     2778            }
     2779        }
     2780        else
     2781            rc = SSMR3GetStruct(pSSM, pPGM, &s_aPGMFieldsPreBalloon[0]);
     2782
    27582783        AssertLogRelRCReturn(rc, rc);
    27592784
     
    28852910    if (   (   uPass != SSM_PASS_FINAL
    28862911            && uVersion != PGM_SAVED_STATE_VERSION
     2912            && uVersion != PGM_SAVED_STATE_VERSION_PRE_BALLOON
    28872913            && uVersion != PGM_SAVED_STATE_VERSION_NO_RAM_CFG)
    28882914        || (   uVersion != PGM_SAVED_STATE_VERSION
     2915            && uVersion != PGM_SAVED_STATE_VERSION_PRE_BALLOON
    28892916            && uVersion != PGM_SAVED_STATE_VERSION_NO_RAM_CFG
    28902917            && uVersion != PGM_SAVED_STATE_VERSION_3_0_0
  • trunk/src/VBox/VMM/VMMR0/GMMR0.cpp

    r27162 r27182  
    28382838 *
    28392839 * The request may or may not have been initiated by the GMM. If it was initiated
    2840  * by the GMM it is important that this function is called even if no pages was
     2840 * by the GMM it is important that this function is called even if no pages were
    28412841 * ballooned.
    28422842 *
    28432843 * @returns VBox status code:
    28442844 * @retval  VERR_GMM_ATTEMPT_TO_FREE_TOO_MUCH
    2845  * @retval  VERR_GMM_ATTEMPT_TO_DEFLATE_TOO_MUCH
     2845 * @retval  VERR_GMM_ATTEMPT_TO_DEFLATE_TOO_MUCH 
    28462846 * @retval  VERR_GMM_OVERCOMMITED_TRY_AGAIN_IN_A_BIT - reset condition
    2847  *          indicating that we won't neceessarily have sufficient RAM to boot
     2847 *          indicating that we won't necessarily have sufficient RAM to boot
    28482848 *          the VM again and that it should pause until this changes (we'll try
    28492849 *          balloon some other VM).  (For standard deflate we have little choice
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette