- Timestamp:
- Feb 13, 2021 3:37:09 AM (4 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
-
VMMAll/TMAll.cpp (modified) (2 diffs)
-
include/TMInternal.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/TMAll.cpp
r87749 r87750 210 210 * Update the data. 211 211 * 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. 215 216 */ 216 217 uint64_t const cNsExecutingNew = pVCpu->tm.s.cNsExecuting + cNsExecutingDelta; 217 218 uint32_t uGen = ASMAtomicUoIncU32(&pVCpu->tm.s.uTimesGen); Assert(uGen & 1); 219 ASMCompilerBarrier(); 218 220 pVCpu->tm.s.fExecuting = false; 219 221 pVCpu->tm.s.cNsExecuting = cNsExecutingNew; 220 222 pVCpu->tm.s.cPeriodsExecuting++; 221 ASMAtomicWriteU32(&pVCpu->tm.s.uTimesGen, (uGen | 1) + 1); 223 ASMCompilerBarrier(); 224 ASMAtomicUoWriteU32(&pVCpu->tm.s.uTimesGen, (uGen | 1) + 1); 222 225 223 226 /* … … 309 312 uint64_t const cNsOtherNew = cNsTotalNew - pVCpu->tm.s.cNsExecuting - cNsHaltedNew; 310 313 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(); 312 316 pVCpu->tm.s.fHalting = false; 313 317 pVCpu->tm.s.fUpdateStats = false; 314 318 pVCpu->tm.s.cNsHalted = cNsHaltedNew; 315 319 pVCpu->tm.s.cPeriodsHalted++; 316 ASMAtomicWriteU32(&pVCpu->tm.s.uTimesGen, (uGen | 1) + 1); 320 ASMCompilerBarrier(); 321 ASMAtomicUoWriteU32(&pVCpu->tm.s.uTimesGen, (uGen | 1) + 1); 317 322 318 323 # if defined(VBOX_WITH_STATISTICS) || defined(VBOX_WITH_NS_ACCOUNTING_STATS) -
trunk/src/VBox/VMM/include/TMInternal.h
r87748 r87750 716 716 typedef struct TMCPU 717 717 { 718 /** CPU timestamp ticking enabled indicator (bool). (RDTSC) */719 bool fTSCTicking;720 bool afAlignment0[7]; /**< alignment padding */721 718 /** The offset between the host tick (TSC/virtual depending on the TSC mode) and 722 719 * the guest tick. */ … … 726 723 /** The last seen TSC by the guest. */ 727 724 uint64_t u64TSCLastSeen; 728 729 #ifndef VBOX_WITHOUT_NS_ACCOUNTING 730 /** Align */ 731 uint64_t au64Alignment[4]; 732 733 /** @name Core accounting data. Must be cache-line aligned. 725 /** CPU timestamp ticking enabled indicator (bool). (RDTSC) */ 726 bool fTSCTicking; 727 #ifdef VBOX_WITHOUT_NS_ACCOUNTING 728 bool afAlignment1[7]; /**< alignment padding */ 729 #else /* !VBOX_WITHOUT_NS_ACCOUNTING */ 730 731 /** Set by the timer callback to trigger updating of statistics in 732 * TMNotifyEndOfExecution. */ 733 bool volatile fUpdateStats; 734 bool afAlignment1[6]; 735 /** The time not spent executing or halted. 736 * @note Only updated after halting and after the timer runs. */ 737 uint64_t cNsOtherStat; 738 /** Reasonably up to date total run time value. 739 * @note Only updated after halting and after the timer runs. */ 740 uint64_t cNsTotalStat; 741 # if defined(VBOX_WITH_STATISTICS) || defined(VBOX_WITH_NS_ACCOUNTING_STATS) 742 /** Resettable copy of version of cNsOtherStat. 743 * @note Only updated after halting. */ 744 STAMCOUNTER StatNsOther; 745 /** Resettable copy of cNsTotalStat. 746 * @note Only updated after halting. */ 747 STAMCOUNTER StatNsTotal; 748 # else 749 uint64_t auAlignment2[2]; 750 # endif 751 752 /** @name Core accounting data. 753 * @note Must be cache-line aligned and only written to by the EMT owning it. 734 754 * @{ */ 735 755 /** The cNsXXX generation. */ … … 742 762 /** Set if we're suspended and u64NsTsStartTotal is to be cNsTotal. */ 743 763 bool volatile fSuspended; 744 /** Set by the timer callback to trigger updating of statistics in 745 * TMNotifyEndOfExecution. */ 746 bool volatile fUpdateStats; 764 bool afAlignment; 747 765 /** The nanosecond timestamp of the CPU start or resume. 748 766 * This is recalculated when the VM is started so that … … 774 792 /** Resettable version of cNsHalted. */ 775 793 STAMPROFILE StatNsHalted; 776 777 /** Resettable copy of version of cNsOtherStat.778 * @note Only updated after halting. */779 STAMCOUNTER StatNsOther;780 /** Resettable copy of cNsTotalStat.781 * @note Only updated after halting. */782 STAMCOUNTER StatNsTotal;783 794 # endif 784 /** The time not spent executing or halted.785 * @note Only updated after halting and after the timer runs. */786 uint64_t cNsOtherStat;787 /** Reasonably up to date total run time value.788 * @note Only updated after halting and after the timer runs. */789 uint64_t cNsTotalStat;790 795 791 796 /** CPU load state for this virtual CPU (tmR3CpuLoadTimer). */ … … 798 803 AssertCompileMemberAlignment(TMCPU, StatNsExecuting, 64); 799 804 # else 800 AssertCompileMemberAlignment(TMCPU, cNsOtherStat, 64);805 AssertCompileMemberAlignment(TMCPU, CpuLoad, 64); 801 806 # endif 802 807 #endif
Note:
See TracChangeset
for help on using the changeset viewer.

