Changeset 52815 in vbox
- Timestamp:
- Sep 22, 2014 10:33:36 AM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 96211
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/err.h
r52740 r52815 1767 1767 /** Type error opening the ApiPort LPC object. */ 1768 1768 #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) 1769 1771 /** @} */ 1770 1772 -
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r52780 r52815 6074 6074 * @remarks Measuring TSC deltas between the CPUs is tricky because we need to 6075 6075 * 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. 6081 6085 * 6082 6086 * It must be noted that the computed minimum read time is mostly to … … 6087 6091 * earlier. As long as these occasional negative deltas are lower than the 6088 6092 * 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. 6090 6097 */ 6091 6098 static DECLCALLBACK(void) supdrvMeasureTscDeltaCallback(RTCPUID idCpu, void *pvUser1, void *pvUser2) … … 6304 6311 { 6305 6312 /* 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); 6306 6314 ASMAtomicWriteU32(&g_pTscDeltaSync->u, GIP_TSC_DELTA_SYNC_STOP); 6307 6315 rc = RTMpOnAll(supdrvMeasureTscDeltaCallback, pGip, &pGipCpuWorker->idCpu); … … 6309 6317 { 6310 6318 if (RT_UNLIKELY(pGipCpuWorker->i64TSCDelta == INT64_MAX)) 6311 rc = VERR_ UNRESOLVED_ERROR;6319 rc = VERR_SUPDRV_TSC_DELTA_MEASUREMENT_FAILED; 6312 6320 } 6313 6321 }
Note:
See TracChangeset
for help on using the changeset viewer.