Changeset 54456 in vbox for trunk/src/VBox/HostDrivers/Support
- Timestamp:
- Feb 24, 2015 4:09:25 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrvGip.cpp
r54455 r54456 2400 2400 static DECLCALLBACK(void) supdrvGipSyncAndInvariantTimer(PRTTIMER pTimer, void *pvUser, uint64_t iTick) 2401 2401 { 2402 RTCCUINTREG uFlags; 2403 uint64_t u64TSC; 2404 uint64_t u64NanoTS; 2405 PSUPDRVDEVEXT pDevExt = (PSUPDRVDEVEXT)pvUser; 2406 PSUPGLOBALINFOPAGE pGip = pDevExt->pGip; 2407 2408 uFlags = ASMIntDisableFlags(); /* No interruptions please (real problem on S10). */ 2409 u64TSC = ASMReadTSC(); 2410 u64NanoTS = RTTimeSystemNanoTS(); 2402 PSUPDRVDEVEXT pDevExt = (PSUPDRVDEVEXT)pvUser; 2403 PSUPGLOBALINFOPAGE pGip = pDevExt->pGip; 2404 RTCCUINTREG fOldFlags = ASMIntDisableFlags(); /* No interruptions please (real problem on S10). */ 2405 uint64_t u64TSC = ASMReadTSC(); 2406 uint64_t u64NanoTS = RTTimeSystemNanoTS(); 2411 2407 2412 2408 if (pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_PRACTICALLY_ZERO) … … 2440 2436 supdrvGipUpdate(pDevExt, u64NanoTS, u64TSC, NIL_RTCPUID, iTick); 2441 2437 2442 ASMSetFlags( uFlags);2438 ASMSetFlags(fOldFlags); 2443 2439 } 2444 2440 … … 2452 2448 static DECLCALLBACK(void) supdrvGipAsyncTimer(PRTTIMER pTimer, void *pvUser, uint64_t iTick) 2453 2449 { 2450 PSUPDRVDEVEXT pDevExt = (PSUPDRVDEVEXT)pvUser; 2454 2451 RTCCUINTREG fOldFlags = ASMIntDisableFlags(); /* No interruptions please (real problem on S10). */ 2455 PSUPDRVDEVEXT pDevExt = (PSUPDRVDEVEXT)pvUser;2456 2452 RTCPUID idCpu = RTMpCpuId(); 2457 2453 uint64_t u64TSC = ASMReadTSC(); … … 2514 2510 { 2515 2511 /** Padding to make sure the iCurSeqNo is in its own cache line. */ 2516 uint64_t au64CacheLinePaddingBefore[GIP_TSC_DELTA_CACHE_LINE_SIZE / sizeof(uint64_t) - 1];2512 uint64_t au64CacheLinePaddingBefore[GIP_TSC_DELTA_CACHE_LINE_SIZE / sizeof(uint64_t)]; 2517 2513 /** The current sequence number of this worker. */ 2518 2514 uint32_t volatile iCurSeqNo; … … 2612 2608 /** Padding to make sure the master variables live in its own cache lines. */ 2613 2609 uint64_t au64CacheLinePaddingBefore[GIP_TSC_DELTA_CACHE_LINE_SIZE / sizeof(uint64_t)]; 2610 /** The time the master spent in the MP worker. */ 2611 uint64_t cElapsedMasterTscTicks; 2614 2612 /** Pointer to the master's synchronization struct (on stack). */ 2615 2613 PSUPTSCDELTASYNC2 volatile pSyncMaster; … … 2633 2631 /** Pointer to the worker's synchronization struct (on stack). */ 2634 2632 PSUPTSCDELTASYNC2 volatile pSyncWorker; 2633 /** The time the worker spent in the MP worker. */ 2634 uint64_t cElapsedWorkerTscTicks; 2635 2635 /** Verification test TSC values for the worker. */ 2636 2636 uint64_t volatile auVerifyWorkerTscs[32]; … … 2829 2829 2830 2830 #define TSCDELTA_MASTER_SYNC_BEFORE(a_pMySync, a_pOtherSync) \ 2831 do{ \2831 if (true) { \ 2832 2832 if (RT_LIKELY(supdrvTscDeltaSync2_Before(a_pMySync, a_pOtherSync, true /*fMaster*/, &uFlags))) \ 2833 2833 { /*likely*/ } \ 2834 2834 else break; \ 2835 } while (0)2835 } else do {} while (0) 2836 2836 #define TSCDELTA_OTHER_SYNC_BEFORE(a_pMySync, a_pOtherSync) \ 2837 do{ \2837 if (true) { \ 2838 2838 if (RT_LIKELY(supdrvTscDeltaSync2_Before(a_pMySync, a_pOtherSync, false /*fMaster*/, &uFlags))) \ 2839 2839 { /*likely*/ } \ 2840 2840 else break; \ 2841 } while (0)2841 } else do {} while (0) 2842 2842 2843 2843 … … 2868 2868 2869 2869 #define TSCDELTA_MASTER_SYNC_AFTER(a_pMySync, a_pOtherSync) \ 2870 do{ \2871 if ( supdrvTscDeltaSync2_After(a_pMySync, a_pOtherSync, uFlags)) \2870 if (true) { \ 2871 if (RT_LIKELY(supdrvTscDeltaSync2_After(a_pMySync, a_pOtherSync, uFlags))) \ 2872 2872 { /* likely */ } \ 2873 2873 else break; \ 2874 } while (0)2874 } else do {} while (0) 2875 2875 2876 2876 #define TSCDELTA_MASTER_KICK_OTHER_OUT_OF_AFTER(a_pMySync, a_pOtherSync) \ 2877 do {\2877 if (true) { \ 2878 2878 /* \ 2879 * Tell the wo ker that we're done processing the data and ready for the next round. \2879 * Tell the worker that we're done processing the data and ready for the next round. \ 2880 2880 */ \ 2881 if (!ASMAtomicCmpXchgU32(&(a_pOtherSync)->uSyncVar, GIP_TSC_DELTA_SYNC2_READY, GIP_TSC_DELTA_SYNC2_GO)) \ 2881 if (RT_LIKELY(ASMAtomicCmpXchgU32(&(a_pOtherSync)->uSyncVar, GIP_TSC_DELTA_SYNC2_READY, GIP_TSC_DELTA_SYNC2_GO))) \ 2882 { /* likely */ } \ 2883 else break; \ 2884 } else do {} while (0) 2885 2886 #define TSCDELTA_OTHER_SYNC_AFTER(a_pMySync, a_pOtherSync) \ 2887 if (true) { \ 2888 /* \ 2889 * Tell the master that we're done collecting data and wait for the next round to start. \ 2890 */ \ 2891 if (RT_LIKELY(ASMAtomicCmpXchgU32(&(a_pOtherSync)->uSyncVar, GIP_TSC_DELTA_SYNC2_READY, GIP_TSC_DELTA_SYNC2_GO))) \ 2892 { /* likely */ } \ 2893 else \ 2882 2894 { \ 2883 2895 ASMSetFlags(uFlags); \ 2884 2896 break; \ 2885 2897 } \ 2886 } while (0) 2887 2888 #define TSCDELTA_OTHER_SYNC_AFTER(a_pMySync, a_pOtherSync) \ 2889 do { \ 2890 /* \ 2891 * Tell the master that we're done collecting data and wait for the next round to start. \ 2892 */ \ 2893 if (!ASMAtomicCmpXchgU32(&(a_pOtherSync)->uSyncVar, GIP_TSC_DELTA_SYNC2_READY, GIP_TSC_DELTA_SYNC2_GO)) \ 2894 { \ 2895 ASMSetFlags(uFlags); \ 2896 break; \ 2897 } \ 2898 if (supdrvTscDeltaSync2_After(a_pMySync, a_pOtherSync, uFlags)) \ 2898 if (RT_LIKELY(supdrvTscDeltaSync2_After(a_pMySync, a_pOtherSync, uFlags))) \ 2899 2899 { /* likely */ } \ 2900 2900 else break; \ 2901 } while (0)2901 } else do {} while (0) 2902 2902 /** @} */ 2903 2903 … … 3119 3119 pArgs->M2.cHits += cHits; 3120 3120 3121 #if 1 3121 3122 /* 3122 3123 * Check and see if we can quit a little early. If the result is already … … 3147 3148 } 3148 3149 } 3150 #endif 3149 3151 } 3150 3152 … … 3623 3625 * This should normally be the case. 3624 3626 */ 3627 #if 1 3625 3628 rc = supdrvTscDeltaVerify(pArgs, &MySync, pOtherSync, fIsMaster, GIP_TSC_DELTA_INITIAL_MASTER_VALUE); 3629 #else 3630 rc = VERR_OUT_OF_RANGE; 3631 #endif 3626 3632 if (RT_SUCCESS(rc)) 3627 3633 { … … 3666 3672 * Success? If so, stop trying. 3667 3673 */ 3674 #if 1 3668 3675 if (pGipCpuWorker->i64TSCDelta != INT64_MAX) 3676 #else 3677 if (pGipCpuWorker->i64TSCDelta != INT64_MAX && iTry >= 11) 3678 #endif 3669 3679 { 3670 3680 if (fIsMaster) … … 3701 3711 } 3702 3712 3713 /* 3714 * Collect some runtime stats. 3715 */ 3716 if (fIsMaster) 3717 pArgs->cElapsedMasterTscTicks = ASMReadTSC() - MySync.uTscStart; 3718 else 3719 pArgs->cElapsedWorkerTscTicks = ASMReadTSC() - MySync.uTscStart; 3703 3720 return 0; 3704 3721 } … … 3848 3865 if (RT_SUCCESS(rc)) 3849 3866 { 3867 #if 0 3868 SUPR0Printf("mponpair ticks: %9llu %9llu max: %9llu\n", pArgs->cElapsedMasterTscTicks, 3869 pArgs->cElapsedWorkerTscTicks, pArgs->cMaxTscTicks); 3870 #endif 3850 3871 #if 0 3851 3872 SUPR0Printf("rcVerify=%d iVerifyBadTscDiff=%lld cMinVerifyTscTicks=%lld cMaxVerifyTscTicks=%lld\n",
Note:
See TracChangeset
for help on using the changeset viewer.