VirtualBox

Changeset 14877 in vbox


Ignore:
Timestamp:
Dec 1, 2008 4:37:38 PM (16 years ago)
Author:
vboxsync
Message:

PGMR0DynMap: bigger cache (4x), even fewer unrolled/inlined collision checks (3 pages now, was 5).

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

Legend:

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

    r14868 r14877  
    16061606    STAM_REG(pVM, &pPGM->StatR0DynMapPageHit1,              STAMTYPE_COUNTER, "/PGM/R0/DynMapPage/Hit1",            STAMUNIT_OCCURENCES,     "Hit at iPage+1");
    16071607    STAM_REG(pVM, &pPGM->StatR0DynMapPageHit2,              STAMTYPE_COUNTER, "/PGM/R0/DynMapPage/Hit2",            STAMUNIT_OCCURENCES,     "Hit at iPage+2");
    1608     STAM_REG(pVM, &pPGM->StatR0DynMapPageHit3,              STAMTYPE_COUNTER, "/PGM/R0/DynMapPage/Hit3",            STAMUNIT_OCCURENCES,     "Hit at iPage+3");
    16091608    STAM_REG(pVM, &pPGM->StatR0DynMapPageInvlPg,            STAMTYPE_COUNTER, "/PGM/R0/DynMapPage/InvlPg",          STAMUNIT_OCCURENCES,     "invlpg count in pgmR0DynMapPageSlow.");
    16101609    STAM_REG(pVM, &pPGM->StatR0DynMapPageSlow,              STAMTYPE_COUNTER, "/PGM/R0/DynMapPage/Slow",            STAMUNIT_OCCURENCES,     "Calls to pgmR0DynMapPageSlow - subtract this from pgmR0DynMapPage to get 1st level hits.");
  • trunk/src/VBox/VMM/PGMInternal.h

    r14868 r14877  
    25702570    STAMCOUNTER StatR0DynMapPageHit1;               /**< R0: Hit at iPage+1. */
    25712571    STAMCOUNTER StatR0DynMapPageHit2;               /**< R0: Hit at iPage+2. */
    2572     STAMCOUNTER StatR0DynMapPageHit3;               /**< R0: Hit at iPage+3. */
    25732572    STAMCOUNTER StatR0DynMapPageInvlPg;             /**< R0: invlpg. */
    25742573    STAMCOUNTER StatR0DynMapPageSlow;               /**< R0: Calls to pgmR0DynMapPageSlow. */
  • trunk/src/VBox/VMM/VMMR0/PGMR0DynMap.cpp

    r14868 r14877  
    4444*******************************************************************************/
    4545/** The max size of the mapping cache (in pages). */
    46 #define PGMR0DYNMAP_MAX_PAGES               ((8*_1M) >> PAGE_SHIFT)
     46#define PGMR0DYNMAP_MAX_PAGES               ((16*_1M) >> PAGE_SHIFT)
    4747/** The small segment size that is adopted on out-of-memory conditions with a
    4848 * single big segment. */
    4949#define PGMR0DYNMAP_SMALL_SEG_PAGES         128
    5050/** The number of pages we reserve per CPU. */
    51 #define PGMR0DYNMAP_PAGES_PER_CPU           64
     51#define PGMR0DYNMAP_PAGES_PER_CPU           256
     52/** The minimum number of pages we reserve per CPU.
     53 * This must be equal or larger than the autoset size.  */
     54#define PGMR0DYNMAP_PAGES_PER_CPU_MIN       32
    5255/** The number of guard pages.
    5356 * @remarks Never do tuning of the hashing or whatnot with a strict build!  */
     
    534537    Assert(pThis->cPages <= PGMR0DYNMAP_MAX_PAGES);
    535538
    536     /* cCpus * PGMR0DYNMAP_PAGES_PER_CPU (/2). */
     539    /* cCpus * PGMR0DYNMAP_PAGES_PER_CPU(_MIN). */
    537540    RTCPUID     cCpus     = RTMpGetCount();
    538541    AssertReturn(cCpus > 0 && cCpus <= RTCPUSET_MAX_CPUS, 0);
    539     uint32_t    cPages    = cCpus *  PGMR0DYNMAP_PAGES_PER_CPU;
    540     uint32_t    cMinPages = cCpus * (PGMR0DYNMAP_PAGES_PER_CPU / 2);
     542    uint32_t    cPages    = cCpus * PGMR0DYNMAP_PAGES_PER_CPU;
     543    uint32_t    cMinPages = cCpus * PGMR0DYNMAP_PAGES_PER_CPU_MIN;
    541544
    542545    /* adjust against cMaxLoad. */
     
    11741177
    11751178    /*
    1176      * Check if any of the first 4 pages are unreferenced since the caller
     1179     * Check if any of the first 3 pages are unreferenced since the caller
    11771180     * already has made sure they aren't matching.
    11781181     */
     
    11891192    else if (!paPages[(iPage + 2) % cPages].cRefs)
    11901193        iFreePage   = (iPage + 2) % cPages;
    1191     else if (!paPages[(iPage + 3) % cPages].cRefs)
    1192         iFreePage   = (iPage + 3) % cPages;
    11931194    else
    11941195    {
     
    11961197         * Search for an unused or matching entry.
    11971198         */
    1198         iFreePage = (iPage + 4) % cPages;
     1199        iFreePage = (iPage + 3) % cPages;
    11991200        for (;;)
    12001201        {
     
    12221223    /* Check for lost hits. */
    12231224    if (!fLooped)
    1224         for (uint32_t iPage2 = (iPage + 4) % cPages; iPage2 != iPage; iPage2 = (iPage2 + 1) % cPages)
     1225        for (uint32_t iPage2 = (iPage + 3) % cPages; iPage2 != iPage; iPage2 = (iPage2 + 1) % cPages)
    12251226            if (paPages[iPage2].HCPhys == HCPhys)
    12261227                STAM_COUNTER_INC(&pVM->pgm.s.StatR0DynMapPageSlowLostHits);
     
    12781279    /*
    12791280     * Find an entry, if possible a matching one. The HCPhys address is hashed
    1280      * down to a page index, collisions are handled by linear searching. Optimize
    1281      * for a hit in the first 4 pages.
     1281     * down to a page index, collisions are handled by linear searching.
     1282     * Optimized for a hit in the first 3 pages.
    12821283     *
    12831284     * To the cheap hits here and defer the tedious searching and inserting
     
    13071308            else
    13081309            {
    1309                 iPage2 = (iPage + 3) % cPages;
    1310                 if (paPages[iPage2].HCPhys == HCPhys)
     1310                iPage = pgmR0DynMapPageSlow(pThis, HCPhys, iPage, pVM);
     1311                if (RT_UNLIKELY(iPage == UINT32_MAX))
    13111312                {
    1312                     iPage = iPage2;
    1313                     STAM_COUNTER_INC(&pVM->pgm.s.StatR0DynMapPageHit3);
    1314                 }
    1315                 else
    1316                 {
    1317                     iPage = pgmR0DynMapPageSlow(pThis, HCPhys, iPage, pVM);
    1318                     if (RT_UNLIKELY(iPage == UINT32_MAX))
    1319                     {
    1320                         RTSpinlockRelease(pThis->hSpinlock, &Tmp);
    1321                         return iPage;
    1322                     }
     1313                    RTSpinlockRelease(pThis->hSpinlock, &Tmp);
     1314                    return iPage;
    13231315                }
    13241316            }
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