VirtualBox

Changeset 52815 in vbox


Ignore:
Timestamp:
Sep 22, 2014 10:33:36 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
96211
Message:

HostDrivers/Support: Comments and use a proper error code for failing to measure deltas.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/err.h

    r52740 r52815  
    17671767/** Type error opening the ApiPort LPC object. */
    17681768#define VERR_SUPDRV_APIPORT_OPEN_ERROR_TYPE         (-3742)
     1769/** Failed to measure the TSC delta between two CPUs. */
     1770#define VERR_SUPDRV_TSC_DELTA_MEASUREMENT_FAILED    (-3743)
    17691771/** @} */
    17701772
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r52780 r52815  
    60746074 * @remarks Measuring TSC deltas between the CPUs is tricky because we need to
    60756075 *     read the TSC at exactly the same time on both the master and the worker
    6076  *     CPUs. Due to DMA, bus arbitration, cache locality, contention etc. there
    6077  *     is no guaranteed way of doing this on x86 CPUs. We try to minimize the
    6078  *     measurement error by computing the minimum read time of the compare
    6079  *     statement in the worker by taking TSC measurements across it. We also
    6080  *     ignore the first few runs of the loop in order to prime the cache.
     6076 *     CPUs. Due to DMA, bus arbitration, cache locality, contention, pipelining
     6077 *     etc. there is no guaranteed way of doing this on x86 CPUs. We try to
     6078 *     minimize the measurement error by computing the minimum read time of the
     6079 *     compare statement in the worker by taking TSC measurements across it.
     6080 *
     6081 *     We ignore the first few runs of the loop in order to prime the cache.
     6082 *     Also, be careful about using 'pause' instruction in critical busy-wait
     6083 *     loops in this code - it can cause undesired behaviour with
     6084 *     hyperthreading.
    60816085 *
    60826086 *     It must be noted that the computed minimum read time is mostly to
     
    60876091 *     earlier. As long as these occasional negative deltas are lower than the
    60886092 *     time it takes to exit guest-context and the OS to reschedule EMT on a
    6089  *     different CPU we won't expose a TSC that jumped backwards.
     6093 *     different CPU we won't expose a TSC that jumped backwards. It is because
     6094 *     of the existence of the negative deltas we don't recompute the delta with
     6095 *     the master and worker interchanged to eliminate the remaining measurement
     6096 *     error.
    60906097 */
    60916098static DECLCALLBACK(void) supdrvMeasureTscDeltaCallback(RTCPUID idCpu, void *pvUser1, void *pvUser2)
     
    63046311    {
    63056312        /* Fire TSC-read workers on all CPUs but only synchronize between master and one worker to ease memory contention. */
     6313        ASMAtomicWriteS64(&pGipCpuWorker->i64TSCDelta, INT64_MAX);
    63066314        ASMAtomicWriteU32(&g_pTscDeltaSync->u, GIP_TSC_DELTA_SYNC_STOP);
    63076315        rc = RTMpOnAll(supdrvMeasureTscDeltaCallback, pGip, &pGipCpuWorker->idCpu);
     
    63096317        {
    63106318            if (RT_UNLIKELY(pGipCpuWorker->i64TSCDelta == INT64_MAX))
    6311                 rc = VERR_UNRESOLVED_ERROR;
     6319                rc = VERR_SUPDRV_TSC_DELTA_MEASUREMENT_FAILED;
    63126320        }
    63136321    }
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