Changeset 53091 in vbox for trunk/src/VBox
- Timestamp:
- Oct 20, 2014 12:57:42 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r53087 r53091 5927 5927 { 5928 5928 RTCCUINTREG uFlags; 5929 uint64_t u64NanoTS; 5930 uint64_t u64Before; 5931 uint64_t u64After; 5929 uint64_t u64NanoTs; 5930 uint64_t u64NanoTsAfter; 5931 uint64_t u64TscBefore; 5932 uint64_t u64TscAfter; 5932 5933 uint8_t idApicBefore; 5933 5934 uint8_t idApicAfter; … … 5940 5941 idApicBefore = ASMGetApicId(); 5941 5942 ASMSerializeInstruction(); 5942 u64 Before = ASMReadTSC();5943 u64TscBefore = ASMReadTSC(); 5943 5944 ASMSetFlags(uFlags); 5944 u64NanoTS = RTTimeSystemNanoTS(); 5945 5946 /** @todo change this to non-busy wait for invariant case. */ 5947 while (RTTimeSystemNanoTS() < RT_NS_10MS + u64NanoTS) 5948 ; 5949 5950 uFlags = ASMIntDisableFlags(); 5951 u64After = ASMReadTSC(); 5945 u64NanoTs = RTTimeSystemNanoTS(); 5946 5947 if (supdrvIsInvariantTsc()) 5948 { 5949 /* Sleep wait, eases host load, since the TSC frequency is reported as constant. */ 5950 RTThreadSleep(9); 5951 do 5952 { 5953 int64_t cNsDiff; 5954 u64NanoTsAfter = RTTimeSystemNanoTS(); 5955 cNsDiff = u64NanoTsAfter - u64NanoTs; 5956 if (cNsDiff > 9 * RT_NS_1MS) 5957 { 5958 uint64_t cNsWait = RT_NS_10MS; 5959 if (cNsDiff >= RT_NS_10MS) 5960 cNsWait += 2; 5961 for (;;) 5962 { 5963 u64NanoTsAfter = RTTimeSystemNanoTS(); 5964 if (u64NanoTsAfter < cNsWait - cNsDiff + u64NanoTs) 5965 ASMNopPause(); 5966 else 5967 break; 5968 } 5969 break; 5970 } 5971 } while (1); 5972 } 5973 else 5974 { 5975 /* Busy wait, ramps up the CPU frequency on async systems. */ 5976 for (;;) 5977 { 5978 u64NanoTsAfter = RTTimeSystemNanoTS(); 5979 if (u64NanoTsAfter < RT_NS_10MS + u64NanoTs) 5980 ASMNopPause(); 5981 else 5982 break; 5983 } 5984 } 5985 5986 uFlags = ASMIntDisableFlags(); 5987 u64TscAfter = ASMReadTSC(); 5952 5988 idApicAfter = ASMGetApicId(); 5953 5989 ASMSetFlags(uFlags); … … 5966 6002 && pGipCpuAfter->i64TSCDelta != INT64_MAX) 5967 6003 { 5968 u64 Before += pGipCpuBefore->i64TSCDelta;5969 u64 After += pGipCpuAfter->i64TSCDelta;6004 u64TscBefore += pGipCpuBefore->i64TSCDelta; 6005 u64TscAfter += pGipCpuAfter->i64TSCDelta; 5970 6006 5971 6007 SUPR0Printf("vboxdrv: TSC frequency is (%'RU64) Hz, kernel timer granularity is (%RU32) Ns\n", 5972 (u64After - u64Before) * 100, RTTimerGetSystemGranularity()); 6008 ((u64TscAfter - u64TscBefore) * RT_NS_1SEC_64) / (u64NanoTsAfter - u64NanoTs), 6009 RTTimerGetSystemGranularity()); 5973 6010 return VINF_SUCCESS; 5974 6011 } … … 5982 6019 { 5983 6020 SUPR0Printf("vboxdrv: TSC frequency is (%'RU64) Hz, kernel timer granularity is (%RU32) Ns\n", 5984 (u64After - u64Before) * 100, RTTimerGetSystemGranularity()); 6021 ((u64TscAfter - u64TscBefore) * RT_NS_1SEC_64) / (u64NanoTsAfter - u64NanoTs), 6022 RTTimerGetSystemGranularity()); 5985 6023 return VINF_SUCCESS; 5986 6024 }
Note:
See TracChangeset
for help on using the changeset viewer.