VirtualBox

Changeset 92383 in vbox for trunk/src


Ignore:
Timestamp:
Nov 11, 2021 10:44:05 PM (3 years ago)
Author:
vboxsync
Message:

VMM/PGM: Tweaking pgmR0PhysAllocateLargePage a bit to hope to speed it up a little bit. bugref:10093

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/PGMR0.cpp

    r92381 r92383  
    365365    while (cLeft-- > 0)
    366366    {
    367         PPGMPAGE pPage;
    368         int rc2 = pgmPhysGetPageEx(pGVM, GCPhys, &pPage);
    369         AssertRCReturn(rc2, rc2);
    370         AssertReturn(PGM_PAGE_GET_TYPE(pPage) == PGMPAGETYPE_RAM, VERR_PGM_PHYS_NOT_RAM);
    371         AssertReturn(PGM_PAGE_IS_ZERO(pPage), VERR_PGM_UNEXPECTED_PAGE_STATE);
     367        PPGMPAGE const pPage = pgmPhysGetPage(pGVM, GCPhys);
     368        AssertReturn(pPage && PGM_PAGE_GET_TYPE(pPage) == PGMPAGETYPE_RAM && PGM_PAGE_IS_ZERO(pPage), VERR_PGM_UNEXPECTED_PAGE_STATE);
    372369
    373370        /* Make sure there are no zero mappings. */
    374371        uint16_t const u16Tracking = PGM_PAGE_GET_TRACKING(pPage);
    375372        if (u16Tracking == 0)
    376         { /* likely */ }
     373            Assert(PGM_PAGE_GET_PTE_INDEX(pPage) == 0);
    377374        else
    378375        {
     
    382379            if (rc3 != VINF_SUCCESS && rc == VINF_SUCCESS)
    383380                rc = rc3; /** @todo not perfect... */
     381            PGM_PAGE_SET_PTE_INDEX(pGVM, pPage, 0);
     382            PGM_PAGE_SET_TRACKING(pGVM, pPage, 0);
    384383        }
    385384
    386385        /* Setup the new page. */
    387         STAM_COUNTER_INC(&pGVM->pgm.s.Stats.StatRZPageReplaceZero);
    388         pGVM->pgm.s.cZeroPages--;
    389         pGVM->pgm.s.cPrivatePages++;
    390386        PGM_PAGE_SET_HCPHYS(pGVM, pPage, HCPhys);
    391         PGM_PAGE_SET_PAGEID(pGVM, pPage, idPage);
    392387        PGM_PAGE_SET_STATE(pGVM, pPage, PGM_PAGE_STATE_ALLOCATED);
    393388        PGM_PAGE_SET_PDE_TYPE(pGVM, pPage, PGM_PAGE_PDE_TYPE_PDE);
    394         PGM_PAGE_SET_PTE_INDEX(pGVM, pPage, 0);
    395         PGM_PAGE_SET_TRACKING(pGVM, pPage, 0);
     389        PGM_PAGE_SET_PAGEID(pGVM, pPage, idPage);
    396390        Log3(("PGMR0PhysAllocateLargePage: GCPhys=%RGp: idPage=%#x HCPhys=%RGp (old tracking=%#x)\n",
    397391              GCPhys, idPage, HCPhys, u16Tracking));
     
    403397    }
    404398
     399    STAM_COUNTER_ADD(&pGVM->pgm.s.Stats.StatRZPageReplaceZero, _2M / PAGE_SIZE);
     400    pGVM->pgm.s.cZeroPages    -= _2M / PAGE_SIZE;
     401    pGVM->pgm.s.cPrivatePages += _2M / PAGE_SIZE;
     402
    405403    /*
    406404     * Flush all TLBs.
    407405     */
    408406    if (!fFlushTLBs)
    409     { /* likely */ }
     407    { /* likely as we shouldn't normally map zero pages */ }
    410408    else
    411409    {
     
    418416
    419417    STAM_PROFILE_STOP(&pGVM->pgm.s.Stats.StatLargePageSetup, b);
    420     /** @todo returning info statuses here might not be a great idea... */
    421 #if 0
     418#if 0 /** @todo returning info statuses here might not be a great idea... */
    422419    LogFlow(("PGMR0PhysAllocateLargePage: returns %Rrc\n", VBOXSTRICTRC_VAL(rc) ));
    423420    return VBOXSTRICTRC_TODO(rc);
  • trunk/src/VBox/VMM/include/PGMInline.h

    r91904 r92383  
    103103    PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(apRamRangesTlb)[PGM_RAMRANGE_TLB_IDX(GCPhys)];
    104104    RTGCPHYS off;
    105     if (   !pRam
    106         || (off = GCPhys - pRam->GCPhys) >= pRam->cb)
    107         return pgmPhysGetPageSlow(pVM, GCPhys);
    108     STAM_COUNTER_INC(&pVM->pgm.s.Stats.CTX_MID_Z(Stat,RamRangeTlbHits));
    109     return &pRam->aPages[off >> PAGE_SHIFT];
     105    if (   pRam
     106        && (off = GCPhys - pRam->GCPhys) < pRam->cb)
     107    {
     108        STAM_COUNTER_INC(&pVM->pgm.s.Stats.CTX_MID_Z(Stat,RamRangeTlbHits));
     109        return &pRam->aPages[off >> PAGE_SHIFT];
     110    }
     111    return pgmPhysGetPageSlow(pVM, GCPhys);
    110112}
    111113
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