VirtualBox

Changeset 87750 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Feb 13, 2021 3:37:09 AM (4 years ago)
Author:
vboxsync
Message:

VMM/TM: Further relax memory ordering when signaling update-in-progress in both TMNotifyEndOfExecution and TMNotifyEndOfHalt by ensuring only the EMT writes to the memory. bugref:9941

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/TMAll.cpp

    r87749 r87750  
    210210     * Update the data.
    211211     *
    212      * Note! Using ASMAtomicUoIncU32 instead of ASMAtomicIncU32 here to
    213      *       save a tiny bit of time here.  Currently, the only user
    214      *       is tmR3CpuLoadTimer(), so nothing terribly important.
     212     * Note! We're not using strict memory ordering here to speed things us.
     213     *       The data is in a single cache line and this thread is the only
     214     *       one writing to that line, so I cannot quite imagine why we would
     215     *       need any strict ordering here.
    215216     */
    216217    uint64_t const cNsExecutingNew = pVCpu->tm.s.cNsExecuting + cNsExecutingDelta;
    217218    uint32_t uGen = ASMAtomicUoIncU32(&pVCpu->tm.s.uTimesGen); Assert(uGen & 1);
     219    ASMCompilerBarrier();
    218220    pVCpu->tm.s.fExecuting   = false;
    219221    pVCpu->tm.s.cNsExecuting = cNsExecutingNew;
    220222    pVCpu->tm.s.cPeriodsExecuting++;
    221     ASMAtomicWriteU32(&pVCpu->tm.s.uTimesGen, (uGen | 1) + 1);
     223    ASMCompilerBarrier();
     224    ASMAtomicUoWriteU32(&pVCpu->tm.s.uTimesGen, (uGen | 1) + 1);
    222225
    223226    /*
     
    309312    uint64_t const cNsOtherNew    = cNsTotalNew - pVCpu->tm.s.cNsExecuting - cNsHaltedNew;
    310313
    311     uint32_t uGen = ASMAtomicIncU32(&pVCpu->tm.s.uTimesGen); Assert(uGen & 1);
     314    uint32_t uGen = ASMAtomicUoIncU32(&pVCpu->tm.s.uTimesGen); Assert(uGen & 1);
     315    ASMCompilerBarrier();
    312316    pVCpu->tm.s.fHalting     = false;
    313317    pVCpu->tm.s.fUpdateStats = false;
    314318    pVCpu->tm.s.cNsHalted    = cNsHaltedNew;
    315319    pVCpu->tm.s.cPeriodsHalted++;
    316     ASMAtomicWriteU32(&pVCpu->tm.s.uTimesGen, (uGen | 1) + 1);
     320    ASMCompilerBarrier();
     321    ASMAtomicUoWriteU32(&pVCpu->tm.s.uTimesGen, (uGen | 1) + 1);
    317322
    318323# if defined(VBOX_WITH_STATISTICS) || defined(VBOX_WITH_NS_ACCOUNTING_STATS)
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