VirtualBox

Changeset 87751 in vbox for trunk


Ignore:
Timestamp:
Feb 13, 2021 1:57:20 PM (4 years ago)
Author:
vboxsync
Message:

VMM: Eliminated one ASMReadTSC in TMNotifyEndOfExecution. Both VT-x and AMD-V has the TSC value handy. bugref:9941

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/tm.h

    r87747 r87751  
    8686
    8787VMMDECL(void)           TMNotifyStartOfExecution(PVMCC pVM, PVMCPUCC pVCpu);
    88 VMMDECL(void)           TMNotifyEndOfExecution(PVMCC pVM, PVMCPUCC pVCpu);
     88VMMDECL(void)           TMNotifyEndOfExecution(PVMCC pVM, PVMCPUCC pVCpu, uint64_t uTsc);
    8989VMM_INT_DECL(void)      TMNotifyStartOfHalt(PVMCPUCC pVCpu);
    9090VMM_INT_DECL(void)      TMNotifyEndOfHalt(PVMCPUCC pVCpu);
  • trunk/src/VBox/VMM/VMMAll/TMAll.cpp

    r87750 r87751  
    177177 * @param   pVM         The cross context VM structure.
    178178 * @param   pVCpu       The cross context virtual CPU structure.
    179  */
    180 VMMDECL(void) TMNotifyEndOfExecution(PVMCC pVM, PVMCPUCC pVCpu)
     179 * @param   uTsc        TSC value when exiting guest context.
     180 */
     181VMMDECL(void) TMNotifyEndOfExecution(PVMCC pVM, PVMCPUCC pVCpu, uint64_t uTsc)
    181182{
    182183    if (pVM->tm.s.fTSCTiedToExecution)
    183         tmCpuTickPause(pVCpu);
     184        tmCpuTickPause(pVCpu); /** @todo use uTsc here if we can. */
    184185
    185186#ifndef VBOX_WITHOUT_NS_ACCOUNTING
     
    187188     * Calculate the elapsed tick count and convert it to nanoseconds.
    188189     */
    189     /** @todo get TSC from caller (HMR0A.asm) */
    190     uint64_t       cTicks = SUPReadTsc() - pVCpu->tm.s.uTscStartExecuting;
    191190# ifdef IN_RING3
     191    uint64_t       cTicks = uTsc - pVCpu->tm.s.uTscStartExecuting - SUPGetTscDelta();
    192192    uint64_t const uCpuHz = SUPGetCpuHzFromGip(g_pSUPGlobalInfoPage);
    193193# else
     194    uint64_t       cTicks = uTsc - pVCpu->tm.s.uTscStartExecuting - SUPGetTscDeltaByCpuSetIndex(pVCpu->iHostCpuSet);
    194195    uint64_t const uCpuHz = SUPGetCpuHzFromGipBySetIndex(g_pSUPGlobalInfoPage, pVCpu->iHostCpuSet);
    195196# endif
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r87606 r87751  
    43824382    STAM_PROFILE_ADV_STOP_START(&pVCpu->hm.s.StatInGC, &pVCpu->hm.s.StatPreExit, x);
    43834383    PVMCC pVM = pVCpu->CTX_SUFF(pVM);
    4384     TMNotifyEndOfExecution(pVM, pVCpu);                         /* Notify TM that the guest is no longer running. */
     4384    TMNotifyEndOfExecution(pVM, pVCpu, uHostTsc);               /* Notify TM that the guest is no longer running. */
    43854385    VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED_HM);
    43864386
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r87690 r87751  
    1117711177
    1117811178    STAM_PROFILE_ADV_STOP_START(&pVCpu->hm.s.StatInGC, &pVCpu->hm.s.StatPreExit, x);
    11179     TMNotifyEndOfExecution(pVCpu->CTX_SUFF(pVM), pVCpu);                /* Notify TM that the guest is no longer running. */
     11179    TMNotifyEndOfExecution(pVCpu->CTX_SUFF(pVM), pVCpu, uHostTsc);      /* Notify TM that the guest is no longer running. */
    1118011180    VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED_HM);
    1118111181
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