VirtualBox

Changeset 104885 in vbox for trunk/src/VBox/VMM/VMMR3


Ignore:
Timestamp:
Jun 11, 2024 12:37:11 PM (6 months ago)
Author:
vboxsync
Message:

VMM/PGM: Lockless PGMPhysIemGCPhys2PtrNoLock. bugref:10687

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

Legend:

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

    r104870 r104885  
    238238    AssertRCReturn(rc, rc);
    239239
    240     pgmR3PhysChunkInvalidateTLB(pVM); /* includes pgmPhysInvalidatePageMapTLB call */
     240    pgmR3PhysChunkInvalidateTLB(pVM, false /*fInRendezvous*/); /* includes pgmPhysInvalidatePageMapTLB call */
    241241
    242242    /*
  • trunk/src/VBox/VMM/VMMR3/PGM.cpp

    r104870 r104885  
    934934    AssertRCReturn(rc, rc);
    935935
    936     pgmR3PhysChunkInvalidateTLB(pVM); /* includes pgmPhysInvalidatePageMapTLB call */
     936    pgmR3PhysChunkInvalidateTLB(pVM, false /*fInRendezvous*/); /* includes pgmPhysInvalidatePageMapTLB call */
    937937
    938938    /*
     
    14171417        PGM_REG_COUNTER(&pPgmCpu->cA20Changes, "/PGM/CPU%u/cA20Changes",  "Number of A20 gate changes.");
    14181418
     1419        PGM_REG_COUNTER(&pPgmCpu->StatRZRamRangeTlbMisses,              "/PGM/CPU%u/RZ/RamRange/TlbMisses",         "TLB misses (lockless).");
     1420        PGM_REG_COUNTER(&pPgmCpu->StatRZRamRangeTlbLocking,             "/PGM/CPU%u/RZ/RamRange/TlbLocking",        "Lockless TLB failed, falling back on locked lookup.");
     1421        PGM_REG_COUNTER(&pPgmCpu->StatRZPageMapTlbMisses,               "/PGM/CPU%u/RZ/Page/MapTlbMisses",          "Lockless page map TLB failed, falling back on locked lookup.");
     1422
     1423        PGM_REG_COUNTER(&pPgmCpu->StatR3RamRangeTlbMisses,              "/PGM/CPU%u/R3/RamRange/TlbMisses",         "TLB misses (lockless).");
     1424        PGM_REG_COUNTER(&pPgmCpu->StatR3RamRangeTlbLocking,             "/PGM/CPU%u/R3/RamRange/TlbLocking",        "Lockless TLB failed, falling back on locked lookup.");
     1425        PGM_REG_COUNTER(&pPgmCpu->StatR3PageMapTlbMisses,               "/PGM/CPU%u/R3/Page/MapTlbMisses",          "Lockless page map TLB failed, falling back on locked lookup.");
     1426
    14191427#ifdef VBOX_WITH_STATISTICS
    14201428        PGMCPUSTATS *pCpuStats = &pVM->apCpusR3[idCpu]->pgm.s.Stats;
     
    14291437# endif
    14301438        /* R0 only: */
    1431         PGM_REG_PROFILE(&pCpuStats->StatR0NpMiscfg,                      "/PGM/CPU%u/R0/NpMiscfg",                     "PGMR0Trap0eHandlerNPMisconfig() profiling.");
    1432         PGM_REG_COUNTER(&pCpuStats->StatR0NpMiscfgSyncPage,              "/PGM/CPU%u/R0/NpMiscfgSyncPage",             "SyncPage calls from PGMR0Trap0eHandlerNPMisconfig().");
     1439        PGM_REG_PROFILE(&pCpuStats->StatR0NpMiscfg,                     "/PGM/CPU%u/R0/NpMiscfg",                     "PGMR0Trap0eHandlerNPMisconfig() profiling.");
     1440        PGM_REG_COUNTER(&pCpuStats->StatR0NpMiscfgSyncPage,             "/PGM/CPU%u/R0/NpMiscfgSyncPage",             "SyncPage calls from PGMR0Trap0eHandlerNPMisconfig().");
    14331441
    14341442        /* RZ only: */
     
    15691577        PGM_REG_COUNTER(&pCpuStats->StatRZFlushTLBSameCR3Global,       "/PGM/CPU%u/RZ/FlushTLB/SameCR3Global",     "The number of times PGMFlushTLB was called with the same CR3, global. (flush)");
    15701578        PGM_REG_PROFILE(&pCpuStats->StatRZGstModifyPage,               "/PGM/CPU%u/RZ/GstModifyPage",              "Profiling of the PGMGstModifyPage() body.");
     1579        PGM_REG_COUNTER(&pCpuStats->StatRZRamRangeTlbHits,             "/PGM/CPU%u/RZ/RamRange/TlbHits",           "TLB hits (lockless).");
     1580        PGM_REG_COUNTER(&pCpuStats->StatRZPageMapTlbHits,              "/PGM/CPU%u/RZ/Page/MapTlbHits",            "TLB hits (lockless).");
    15711581
    15721582        PGM_REG_PROFILE(&pCpuStats->StatR3SyncCR3,                     "/PGM/CPU%u/R3/SyncCR3",                        "Profiling of the PGMSyncCR3() body.");
     
    16141624        PGM_REG_COUNTER(&pCpuStats->StatR3FlushTLBSameCR3Global,       "/PGM/CPU%u/R3/FlushTLB/SameCR3Global",     "The number of times PGMFlushTLB was called with the same CR3, global. (flush)");
    16151625        PGM_REG_PROFILE(&pCpuStats->StatR3GstModifyPage,               "/PGM/CPU%u/R3/GstModifyPage",              "Profiling of the PGMGstModifyPage() body.");
     1626        PGM_REG_COUNTER(&pCpuStats->StatR3RamRangeTlbHits,             "/PGM/CPU%u/R3/RamRange/TlbHits",           "TLB hits (lockless).");
     1627        PGM_REG_COUNTER(&pCpuStats->StatR3PageMapTlbHits,              "/PGM/CPU%u/R3/Page/MapTlbHits",            "TLB hits (lockless).");
    16161628#endif /* VBOX_WITH_STATISTICS */
    16171629
    16181630#undef PGM_REG_PROFILE
    16191631#undef PGM_REG_COUNTER
    1620 
    16211632    }
    16221633
  • trunk/src/VBox/VMM/VMMR3/PGMPhys.cpp

    r104870 r104885  
    14221422    }
    14231423
    1424     /* Update the RAM range entry to indicate that it is no longer mapped. */
    1425     pRam->GCPhys     = NIL_RTGCPHYS;
     1424    /* Update the RAM range entry to indicate that it is no longer mapped.
     1425       The GCPhys member is accessed by the lockless TLB lookup code, so update
     1426       it last and atomically to be on the safe side. */
    14261427    pRam->GCPhysLast = NIL_RTGCPHYS;
     1428    ASMAtomicWriteU64(&pRam->GCPhys, NIL_RTGCPHYS);
    14271429
    14281430    /*
     
    26542656#endif
    26552657            {
    2656                 pgmPhysInvalidatePageMapTLB(pVM);
     2658                pgmPhysInvalidatePageMapTLB(pVM, false /*fInRendezvous*/);
    26572659                return VINF_SUCCESS;
    26582660            }
     
    26792681    }
    26802682
    2681     pgmPhysInvalidatePageMapTLB(pVM);
     2683    pgmPhysInvalidatePageMapTLB(pVM, false /*fInRendezvous*/);
    26822684    return rc;
    26832685}
     
    28512853    VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3);
    28522854
    2853     pgmPhysInvalidatePageMapTLB(pVM);
     2855    pgmPhysInvalidatePageMapTLB(pVM, false /*fInRendezvous*/);
    28542856    /*pgmPhysInvalidRamRangeTlbs(pVM); - not necessary */
    28552857
     
    34273429        }
    34283430    }
    3429     pgmPhysInvalidatePageMapTLB(pVM);
     3431    pgmPhysInvalidatePageMapTLB(pVM, false /*fInRendezvous*/);
    34303432    PGM_UNLOCK(pVM);
    34313433    return !cFound && hMmio2 != NIL_PGMMMIO2HANDLE ? VERR_NOT_FOUND : rc;
     
    36713673
    36723674    /* Flush physical page map TLB. */
    3673     pgmPhysInvalidatePageMapTLB(pVM);
     3675    pgmPhysInvalidatePageMapTLB(pVM, false /*fInRendezvous*/);
    36743676
    36753677#ifdef VBOX_WITH_NATIVE_NEM
     
    39053907    VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3);
    39063908
    3907     pgmPhysInvalidatePageMapTLB(pVM);
     3909    pgmPhysInvalidatePageMapTLB(pVM, false /*fInRendezvous*/);
    39083910    /* pgmPhysInvalidRamRangeTlbs(pVM); - not necessary */
    39093911
     
    47794781
    47804782            /* Flush physical page map TLB. */
    4781             pgmPhysInvalidatePageMapTLB(pVM);
     4783            pgmPhysInvalidatePageMapTLB(pVM, false /*fInRendezvous*/);
    47824784
    47834785            /*
     
    49384940        }
    49394941    }
    4940     pgmPhysInvalidatePageMapTLB(pVM);
     4942    pgmPhysInvalidatePageMapTLB(pVM, false /*fInRendezvous*/);
    49414943    pgmPhysInvalidRamRangeTlbs(pVM);
    49424944
     
    57775779#endif
    57785780
     5781#if 0 /* This is too much work with the PGMCPU::PhysTlb as well.  We flush them all instead. */
    57795782    for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.PhysTlbR3.aEntries); i++)
    57805783        if (pVM->pgm.s.PhysTlbR3.aEntries[i].pMap == pChunk)
    57815784            return 0;
     5785#endif
    57825786
    57835787    pArg->pChunk = pChunk;
     
    59015905                }
    59025906
    5903                 pgmR3PhysChunkInvalidateTLB(pVM); /* includes pgmPhysInvalidatePageMapTLB call */
     5907                pgmR3PhysChunkInvalidateTLB(pVM, true /*fInRendezvous*/); /* includes pgmPhysInvalidatePageMapTLB call */
    59045908            }
    59055909        }
     
    60436047 * Invalidates the TLB for the ring-3 mapping cache.
    60446048 *
    6045  * @param   pVM         The cross context VM structure.
    6046  */
    6047 DECLHIDDEN(void) pgmR3PhysChunkInvalidateTLB(PVM pVM)
     6049 * @param   pVM             The cross context VM structure.
     6050 * @param   fInRendezvous   Set if we're in a rendezvous.
     6051 */
     6052DECLHIDDEN(void) pgmR3PhysChunkInvalidateTLB(PVM pVM, bool fInRendezvous)
    60486053{
    60496054    PGM_LOCK_VOID(pVM);
     
    60546059    }
    60556060    /* The page map TLB references chunks, so invalidate that one too. */
    6056     pgmPhysInvalidatePageMapTLB(pVM);
     6061    pgmPhysInvalidatePageMapTLB(pVM, fInRendezvous);
    60576062    PGM_UNLOCK(pVM);
    60586063}
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