VirtualBox

Changeset 54224 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Feb 16, 2015 10:41:32 PM (10 years ago)
Author:
vboxsync
Message:

SUP,IPRT: Started as a build fix ended up as a cleanup (mostly untested as I'm windows). We'll keep SUP_IOCTL_TSC_READ for the purpose of dealing with the i64TSCDelta == INT64_MAX in SUPReadTsc/SUPReadTscWithDelta. Moved the excessive inline code from sup.h to SUPLibAll.cpp (new file) and SUPDrv.c (apply delta). Don't bother too much about trying to share code between SUPLibAll.cpp and SUPDrv.c/++ as the SUPReadTsc[WithDelta] scenario does not care about knowing when things goes bad, it just needs a TSC that is as good as we can get. The SUPDrv.c code on the other hand probably needs other kind of status codes, assertions and whatnot to be better off with its own version of the code. Remove the now unused assembly macro for applying the delta - the way the delta is applied will not change, period, so better just document it instead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/time/timesup.cpp

    r54215 r54224  
    153153
    154154/**
    155  * Checks if we really need to apply the delta values.
    156  *
    157  * Getting the delta for a CPU is _very_ expensive, it more than doubles the
    158  * execution time for RTTimeNanoTS.
    159  *
    160  * @returns true if deltas needs to be applied, false if not.
    161  * @param   pGip                The GIP.
    162  *
    163  * @remarks If you change this, make sure to also change tmR3ReallyNeedDeltas().
    164  */
    165 static bool rtTimeNanoTsInternalReallyNeedDeltas(PSUPGLOBALINFOPAGE pGip)
    166 {
    167     return !pGip->fOsTscDeltasInSync && !pGip->fTscDeltasRoughlyInSync;
    168 #if 0
    169     if (!pGip->fOsTscDeltasInSync)
    170     {
    171         uint32_t i = pGip->cCpus;
    172         while (i-- > 0)
    173             if (   pGip->aCPUs[i].enmState == SUPGIPCPUSTATE_ONLINE
    174                 && (   pGip->aCPUs[i].i64TSCDelta > 384
    175                     || pGip->aCPUs[i].i64TSCDelta < -384) )
    176                 return true;
    177     }
    178     return false;
    179 #endif
    180 }
    181 
    182 
    183 /**
    184155 * Called the first time somebody asks for the time or when the GIP
    185156 * is mapped/unmapped.
     
    197168        if (ASMCpuId_EDX(1) & X86_CPUID_FEATURE_EDX_SSE2)
    198169            iWorker = pGip->u32Mode == SUPGIPMODE_INVARIANT_TSC
    199                     ? rtTimeNanoTsInternalReallyNeedDeltas(pGip)
     170                    ? !pGip->fOsTscDeltasInSync && !pGip->fTscDeltasRoughlyInSync
    200171                      ? RTTIMENANO_WORKER_LFENCE_INVAR_WITH_DELTA : RTTIMENANO_WORKER_LFENCE_INVAR_NO_DELTA
    201172                    : pGip->u32Mode == SUPGIPMODE_SYNC_TSC
    202                     ? false /** @todo !rtTimeNanoTsInternalReallyNeedDeltas(pGip) */
     173                    ? false /** @todo !pGip->fOsTscDeltasInSync && !pGip->fTscDeltasRoughlyInSync */
    203174                      ? RTTIMENANO_WORKER_LFENCE_SYNC_WITH_DELTA  : RTTIMENANO_WORKER_LFENCE_SYNC_NO_DELTA
    204175                    : RTTIMENANO_WORKER_LFENCE_ASYNC;
    205176        else
    206177            iWorker = pGip->u32Mode == SUPGIPMODE_INVARIANT_TSC
    207                     ? rtTimeNanoTsInternalReallyNeedDeltas(pGip)
     178                    ? !pGip->fOsTscDeltasInSync && !pGip->fTscDeltasRoughlyInSync
    208179                      ? RTTIMENANO_WORKER_LEGACY_INVAR_WITH_DELTA : RTTIMENANO_WORKER_LEGACY_INVAR_NO_DELTA
    209180                    : pGip->u32Mode == SUPGIPMODE_SYNC_TSC
    210                     ? false /** @todo rtTimeNanoTsInternalReallyNeedDeltas(pGip) */
     181                    ? false /** @todo !pGip->fOsTscDeltasInSync && !pGip->fTscDeltasRoughlyInSync */
    211182                      ? RTTIMENANO_WORKER_LEGACY_SYNC_WITH_DELTA  : RTTIMENANO_WORKER_LEGACY_SYNC_NO_DELTA
    212183                    : RTTIMENANO_WORKER_LEGACY_ASYNC;
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