VirtualBox

儲存庫 vbox 的更動 30836


忽略:
時間撮記:
2010-7-14 下午01:50:19 (14 年 以前)
作者:
vboxsync
訊息:

Removed aging tree code. Wasn't working at all. Do simple, but not so efficient complete enumeration.

位置:
trunk/src/VBox/VMM
檔案:
修改 2 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/VMM/PGMInternal.h

    r30815 r30836  
    14011401 *
    14021402 * The primary tree (Core) uses the chunk id as key.
    1403  * The secondary tree (AgeCore) is used for ageing and uses ageing sequence number as key.
    14041403 */
    14051404typedef struct PGMCHUNKR3MAP
     
    14071406    /** The key is the chunk id. */
    14081407    AVLU32NODECORE                      Core;
    1409     /** The key is the ageing sequence number. */
    1410     AVLLU32NODECORE                     AgeCore;
    14111408    /** The current age thingy. */
    14121409    uint32_t                            iAge;
     
    26702667        R3R0PTRTYPE(PAVLU32NODECORE) pTree;
    26712668#endif
    2672         /** The chunk age tree, ordered by ageing sequence number. */
    2673         R3PTRTYPE(PAVLLU32NODECORE) pAgeTree;
    26742669        /** The chunk mapping TLB. */
    26752670        PGMCHUNKR3MAPTLB            Tlb;
  • trunk/src/VBox/VMM/PGMPhys.cpp

    r30835 r30836  
    32063206    else /* iAge = 0 */
    32073207        pChunk->iAge = 4;
    3208 
    3209     /* reinsert */
    3210     PVM pVM = (PVM)pvUser;
    3211     RTAvllU32Remove(&pVM->pgm.s.ChunkR3Map.pAgeTree, pChunk->AgeCore.Key);
    3212     pChunk->AgeCore.Key = pChunk->iAge;
    3213     RTAvllU32Insert(&pVM->pgm.s.ChunkR3Map.pAgeTree, &pChunk->AgeCore);
    32143208    return 0;
    32153209}
     
    32263220    {
    32273221        PVM pVM = (PVM)pvUser;
    3228         RTAvllU32Remove(&pVM->pgm.s.ChunkR3Map.pAgeTree, pChunk->AgeCore.Key);
    3229         pChunk->AgeCore.Key = pChunk->iAge = pVM->pgm.s.ChunkR3Map.iNow;
    3230         RTAvllU32Insert(&pVM->pgm.s.ChunkR3Map.pAgeTree, &pChunk->AgeCore);
    3231     }
    3232 
     3222        pChunk->iAge = pVM->pgm.s.ChunkR3Map.iNow;
     3223    }
    32333224    return 0;
    32343225}
     
    32633254    PVM                 pVM;            /**< The VM handle. */
    32643255    PPGMCHUNKR3MAP      pChunk;         /**< The chunk to unmap. */
     3256    int32_t             iLastAge;       /**< Highest age found so far. */
    32653257} PGMR3PHYSCHUNKUNMAPCB, *PPGMR3PHYSCHUNKUNMAPCB;
    32663258
     
    32733265{
    32743266    PPGMCHUNKR3MAP pChunk = (PPGMCHUNKR3MAP)((uint8_t *)pNode - RT_OFFSETOF(PGMCHUNKR3MAP, AgeCore));
     3267    PPGMR3PHYSCHUNKUNMAPCB pArg = (PPGMR3PHYSCHUNKUNMAPCB)pvUser;
     3268
    32753269    if (    pChunk->iAge
    3276         &&  !pChunk->cRefs)
     3270        &&  !pChunk->cRefs
     3271        &&  pArg->iLastAge < pChunk->iAge)
    32773272    {
    32783273        /*
    32793274         * Check that it's not in any of the TLBs.
    32803275         */
    3281         PVM pVM = ((PPGMR3PHYSCHUNKUNMAPCB)pvUser)->pVM;
     3276        PVM pVM = pArg->pVM;
    32823277        for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.ChunkR3Map.Tlb.aEntries); i++)
    32833278            if (pVM->pgm.s.ChunkR3Map.Tlb.aEntries[i].pChunk == pChunk)
     
    32953290        if (pChunk)
    32963291        {
    3297             ((PPGMR3PHYSCHUNKUNMAPCB)pvUser)->pChunk = pChunk;
    3298             return 1; /* done */
     3292            pArg->pChunk = pChunk;
     3293            pArg->iLastAge = pChunk->iAge;
    32993294        }
    33003295    }
     
    33263321     */
    33273322    PGMR3PHYSCHUNKUNMAPCB Args;
    3328     Args.pVM = pVM;
    3329     Args.pChunk = NULL;
    3330     if (RTAvllU32DoWithAll(&pVM->pgm.s.ChunkR3Map.pAgeTree, true /*fFromLeft*/, pgmR3PhysChunkUnmapCandidateCallback, &Args))
    3331     {
    3332         Assert(Args.pChunk);
    3333         if (Args.pChunk)
    3334             return Args.pChunk->Core.Key;
    3335     }
     3323    Args.pVM      = pVM;
     3324    Args.pChunk   = NULL;
     3325    Args.iLastAge = 0;
     3326    RTAvlU32DoWithAll(&pVM->pgm.s.ChunkR3Map.pTree, true /*fFromLeft*/, pgmR3PhysChunkUnmapCandidateCallback, &Args);
     3327    Assert(Args.pChunk);
     3328    if (Args.pChunk)
     3329        return Args.pChunk->Core.Key;
     3330
    33363331    return INT32_MAX;
    33373332}
     
    33703365        Req.idChunkUnmap = pgmR3PhysChunkFindUnmapCandidate(pVM);
    33713366
    3372         rc = VMMR3CallR0(pVM, VMMR0_DO_GMM_MAP_UNMAP_CHUNK, 0, &Req.Hdr);
    3373         if (RT_SUCCESS(rc))
    3374         {
    3375             /* remove the unmapped one. */
    3376             PPGMCHUNKR3MAP pUnmappedChunk = (PPGMCHUNKR3MAP)RTAvlU32Remove(&pVM->pgm.s.ChunkR3Map.pTree, Req.idChunkUnmap);
    3377             AssertRelease(pUnmappedChunk);
    3378             pUnmappedChunk->pv = NULL;
    3379             pUnmappedChunk->Core.Key = UINT32_MAX;
     3367        if (Req.idChunkUnmap != INT32_MAX)
     3368        {
     3369            rc = VMMR3CallR0(pVM, VMMR0_DO_GMM_MAP_UNMAP_CHUNK, 0, &Req.Hdr);
     3370            if (RT_SUCCESS(rc))
     3371            {
     3372                /* remove the unmapped one. */
     3373                PPGMCHUNKR3MAP pUnmappedChunk = (PPGMCHUNKR3MAP)RTAvlU32Remove(&pVM->pgm.s.ChunkR3Map.pTree, Req.idChunkUnmap);
     3374                AssertRelease(pUnmappedChunk);
     3375                pUnmappedChunk->pv = NULL;
     3376                pUnmappedChunk->Core.Key = UINT32_MAX;
    33803377#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
    3381             MMR3HeapFree(pUnmappedChunk);
     3378                MMR3HeapFree(pUnmappedChunk);
    33823379#else
    3383             MMR3UkHeapFree(pVM, pUnmappedChunk, MM_TAG_PGM_CHUNK_MAPPING);
     3380                MMR3UkHeapFree(pVM, pUnmappedChunk, MM_TAG_PGM_CHUNK_MAPPING);
    33843381#endif
    3385             pVM->pgm.s.ChunkR3Map.c--;
    3386             pVM->pgm.s.cUnmappedChunks++;
    3387 
    3388             /* Flush dangling PGM pointers (R3 & R0 ptrs to GC physical addresses) */
    3389             /* todo: we should not flush chunks which include cr3 mappings. */
    3390             for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
    3391             {
    3392                 PPGMCPU pPGM = &pVM->aCpus[idCpu].pgm.s;
    3393 
    3394                 pPGM->pGst32BitPdR3    = NULL;
    3395                 pPGM->pGstPaePdptR3    = NULL;
    3396                 pPGM->pGstAmd64Pml4R3  = NULL;
     3382                pVM->pgm.s.ChunkR3Map.c--;
     3383                pVM->pgm.s.cUnmappedChunks++;
     3384
     3385                /* Flush dangling PGM pointers (R3 & R0 ptrs to GC physical addresses) */
     3386                /* todo: we should not flush chunks which include cr3 mappings. */
     3387                for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
     3388                {
     3389                    PPGMCPU pPGM = &pVM->aCpus[idCpu].pgm.s;
     3390
     3391                    pPGM->pGst32BitPdR3    = NULL;
     3392                    pPGM->pGstPaePdptR3    = NULL;
     3393                    pPGM->pGstAmd64Pml4R3  = NULL;
    33973394#ifndef VBOX_WITH_2X_4GB_ADDR_SPACE
    3398                 pPGM->pGst32BitPdR0    = NIL_RTR0PTR;
    3399                 pPGM->pGstPaePdptR0    = NIL_RTR0PTR;
    3400                 pPGM->pGstAmd64Pml4R0  = NIL_RTR0PTR;
     3395                    pPGM->pGst32BitPdR0    = NIL_RTR0PTR;
     3396                    pPGM->pGstPaePdptR0    = NIL_RTR0PTR;
     3397                    pPGM->pGstAmd64Pml4R0  = NIL_RTR0PTR;
    34013398#endif
    3402                 for (unsigned i = 0; i < RT_ELEMENTS(pPGM->apGstPaePDsR3); i++)
    3403                 {
    3404                     pPGM->apGstPaePDsR3[i]             = NULL;
     3399                    for (unsigned i = 0; i < RT_ELEMENTS(pPGM->apGstPaePDsR3); i++)
     3400                    {
     3401                        pPGM->apGstPaePDsR3[i]             = NULL;
    34053402#ifndef VBOX_WITH_2X_4GB_ADDR_SPACE
    3406                     pPGM->apGstPaePDsR0[i]             = NIL_RTR0PTR;
     3403                        pPGM->apGstPaePDsR0[i]             = NIL_RTR0PTR;
    34073404#endif
     3405                    }
     3406
     3407                    /* Flush REM TLBs. */
     3408                    CPUMSetChangedFlags(&pVM->aCpus[idCpu], CPUM_CHANGED_GLOBAL_TLB_FLUSH);
    34083409                }
    34093410
    3410                 /* Flush REM TLBs. */
    3411                 CPUMSetChangedFlags(&pVM->aCpus[idCpu], CPUM_CHANGED_GLOBAL_TLB_FLUSH);
     3411                /* Flush REM translation blocks. */
     3412                REMFlushTBs(pVM);
    34123413            }
    3413 
    3414             /* Flush REM translation blocks. */
    3415             REMFlushTBs(pVM);
    34163414        }
    34173415    }
     
    34603458    AssertReturn(pChunk, VERR_NO_MEMORY);
    34613459    pChunk->Core.Key = idChunk;
    3462     pChunk->AgeCore.Key = pVM->pgm.s.ChunkR3Map.iNow;
     3460    pChunk->iAge    = pVM->pgm.s.ChunkR3Map.iNow;
    34633461
    34643462    /*
     
    34863484        pVM->pgm.s.ChunkR3Map.c++;
    34873485        pVM->pgm.s.cMappedChunks++;
    3488 
    3489         fRc = RTAvllU32Insert(&pVM->pgm.s.ChunkR3Map.pAgeTree, &pChunk->AgeCore);
    3490         AssertRelease(fRc);
    34913486
    34923487        /* If we're running out of virtual address space, then we should unmap another chunk. */
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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