VirtualBox

Changeset 87748 in vbox for trunk/src/VBox/VMM/include


Ignore:
Timestamp:
Feb 13, 2021 3:03:20 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
142800
Message:

TM: Speed up TMNotifyEndOfExecution by using TSC instead of RTTimeNanoTS() to measure time spend in guest context. Should give 5-10% speedup. bugref:9941

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/include/TMInternal.h

    r87626 r87748  
    716716typedef struct TMCPU
    717717{
    718     /** Offset to the VMCPU structure.
    719      * See TMCPU2VM(). */
    720     RTUINT                      offVMCPU;
    721 
    722718    /** CPU timestamp ticking enabled indicator (bool). (RDTSC) */
    723719    bool                        fTSCTicking;
    724     bool                        afAlignment0[3]; /**< alignment padding */
    725 
     720    bool                        afAlignment0[7]; /**< alignment padding */
    726721    /** The offset between the host tick (TSC/virtual depending on the TSC mode) and
    727722     *  the guest tick. */
    728723    uint64_t                    offTSCRawSrc;
    729 
    730724    /** The guest TSC when fTicking is cleared. */
    731725    uint64_t                    u64TSC;
    732 
    733726    /** The last seen TSC by the guest. */
    734727    uint64_t                    u64TSCLastSeen;
    735728
    736729#ifndef VBOX_WITHOUT_NS_ACCOUNTING
     730    /** Align  */
     731    uint64_t                    au64Alignment[4];
     732
     733    /** @name Core accounting data.  Must be cache-line aligned.
     734     * @{ */
     735    /** The cNsXXX generation. */
     736    uint32_t volatile           uTimesGen;
     737    /** Set if executing (between TMNotifyStartOfExecution and
     738     *  TMNotifyEndOfExecution). */
     739    bool volatile               fExecuting;
     740    /** Set if halting (between TMNotifyStartOfHalt and TMNotifyEndOfHalt). */
     741    bool volatile               fHalting;
     742    /** Set if we're suspended and u64NsTsStartTotal is to be cNsTotal. */
     743    bool volatile               fSuspended;
     744    /** Set by the timer callback to trigger updating of statistics in
     745     *  TMNotifyEndOfExecution. */
     746    bool volatile               fUpdateStats;
    737747    /** The nanosecond timestamp of the CPU start or resume.
    738748     * This is recalculated when the VM is started so that
    739749     * cNsTotal = RTTimeNanoTS() - u64NsTsStartCpu. */
    740     uint64_t                    u64NsTsStartTotal;
    741     /** The nanosecond timestamp of the last start-execute notification. */
    742     uint64_t                    u64NsTsStartExecuting;
    743     /** The nanosecond timestamp of the last start-halt notification. */
    744     uint64_t                    u64NsTsStartHalting;
    745     /** The cNsXXX generation. */
    746     uint32_t volatile           uTimesGen;
    747     /** Explicit alignment padding.  */
    748     uint32_t                    u32Alignment;
    749     /** The number of nanoseconds total run time.
    750      * @remarks This is updated when cNsExecuting and cNsHalted are updated. */
    751     uint64_t                    cNsTotal;
     750    uint64_t                    nsStartTotal;
     751    /** The TSC of the last start-execute notification. */
     752    uint64_t                    uTscStartExecuting;
    752753    /** The number of nanoseconds spent executing. */
    753754    uint64_t                    cNsExecuting;
     755    /** The number of guest execution runs. */
     756    uint64_t                    cPeriodsExecuting;
     757    /** The nanosecond timestamp of the last start-halt notification. */
     758    uint64_t                    nsStartHalting;
    754759    /** The number of nanoseconds being halted. */
    755760    uint64_t                    cNsHalted;
    756     /** The number of nanoseconds spent on other things.
    757      * @remarks This is updated when cNsExecuting and cNsHalted are updated. */
    758     uint64_t                    cNsOther;
    759761    /** The number of halts. */
    760762    uint64_t                    cPeriodsHalted;
    761     /** The number of guest execution runs. */
    762     uint64_t                    cPeriodsExecuting;
     763    /** @} */
     764
    763765# if defined(VBOX_WITH_STATISTICS) || defined(VBOX_WITH_NS_ACCOUNTING_STATS)
    764     /** Resettable version of cNsTotal. */
    765     STAMCOUNTER                 StatNsTotal;
    766766    /** Resettable version of cNsExecuting. */
    767767    STAMPROFILE                 StatNsExecuting;
    768768    /** Long execution intervals. */
    769769    STAMPROFILE                 StatNsExecLong;
    770     /** Short execution intervals . */
     770    /** Short execution intervals. */
    771771    STAMPROFILE                 StatNsExecShort;
    772     /** Tiny execution intervals . */
     772    /** Tiny execution intervals. */
    773773    STAMPROFILE                 StatNsExecTiny;
    774774    /** Resettable version of cNsHalted. */
    775775    STAMPROFILE                 StatNsHalted;
    776     /** Resettable version of cNsOther. */
    777     STAMPROFILE                 StatNsOther;
     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;
    778783# 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;
    779790
    780791    /** CPU load state for this virtual CPU (tmR3CpuLoadTimer). */
     
    782793#endif
    783794} TMCPU;
     795#ifndef VBOX_WITHOUT_NS_ACCOUNTING
     796AssertCompileMemberAlignment(TMCPU, uTimesGen, 64);
     797# if defined(VBOX_WITH_STATISTICS) || defined(VBOX_WITH_NS_ACCOUNTING_STATS)
     798AssertCompileMemberAlignment(TMCPU, StatNsExecuting, 64);
     799# else
     800AssertCompileMemberAlignment(TMCPU, cNsOtherStat, 64);
     801# endif
     802#endif
    784803/** Pointer to TM VMCPU instance data. */
    785804typedef TMCPU *PTMCPU;
Note: See TracChangeset for help on using the changeset viewer.

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