Changeset 57349 in vbox
- Timestamp:
- Aug 14, 2015 2:02:42 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/testcase/tstGIP-2.cpp
r57240 r57349 60 60 }; 61 61 62 uint32_t cIterations = 40; 63 bool fHex = true; 64 bool fSpin = false; 65 bool fCompat = true; 66 bool fTestMode = true; 67 int ch; 68 uint64_t uCpuHzRef = UINT64_MAX; 69 uint64_t uCpuHzOverallDeviation = 0; 70 uint32_t cCpuHzNotCompat = 0; 71 int64_t iCpuHzMaxDeviation = 0; 72 int32_t cCpuHzOverallDevCnt = 0; 62 bool fHex = true; 63 bool fSpin = false; 64 bool fCompat = true; 65 bool fTestMode = true; 66 int ch; 67 uint32_t cIterations = 40; 68 uint64_t uCpuHzRef = UINT64_MAX; 73 69 RTGETOPTUNION ValueUnion; 74 70 RTGETOPTSTATE GetState; … … 116 112 if (g_pSUPGlobalInfoPage) 117 113 { 114 uint64_t uCpuHzOverallDeviation = 0; 115 uint32_t cCpuHzNotCompat = 0; 116 int64_t iCpuHzMaxDeviation = 0; 117 int32_t cCpuHzOverallDevCnt = 0; 118 uint32_t cCpuHzChecked = 0; 119 118 120 /* Pick current CpuHz as the reference if none was specified. */ 119 121 if (uCpuHzRef == UINT64_MAX) … … 124 126 SUPR3GipSetFlags(SUPGIP_FLAGS_TESTING_ENABLE, UINT32_MAX); 125 127 126 RTPrintf("tstGIP-2: cCpus=%d u32UpdateHz=%RU32 u32UpdateIntervalNS=%RU32 u64NanoTSLastUpdateHz=%RX64 u64CpuHz=%RU64 uCpuHzRef=%RU64 u32Mode=%d (%s) u32Version=%#x\n",128 RTPrintf("tstGIP-2: cCpus=%d u32UpdateHz=%RU32 u32UpdateIntervalNS=%RU32 u64NanoTSLastUpdateHz=%RX64 u64CpuHz=%RU64 uCpuHzRef=%RU64 u32Mode=%d (%s) fTestMode=%RTbool u32Version=%#x\n", 127 129 g_pSUPGlobalInfoPage->cCpus, 128 130 g_pSUPGlobalInfoPage->u32UpdateHz, … … 132 134 uCpuHzRef, 133 135 g_pSUPGlobalInfoPage->u32Mode, 136 fTestMode, 134 137 SUPGetGIPModeName(g_pSUPGlobalInfoPage), 135 138 g_pSUPGlobalInfoPage->u32Version); … … 141 144 for (uint32_t i = 0; i < cIterations; i++) 142 145 { 143 /* copy the data*/146 /* Copy the data. */ 144 147 memcpy(&s_aaCPUs[i & 1][0], &g_pSUPGlobalInfoPage->aCPUs[0], g_pSUPGlobalInfoPage->cCpus * sizeof(g_pSUPGlobalInfoPage->aCPUs[0])); 145 148 146 /* display it & find something to spin on. */149 /* Display it & find something to spin on. */ 147 150 uint32_t u32TransactionId = 0; 148 151 uint32_t volatile *pu32TransactionId = NULL; … … 155 158 if (uCpuHzRef) 156 159 { 157 int64_t iCpuHzDeviation = pCpu->u64CpuHz - uCpuHzRef; 158 uint64_t uCpuHzDeviation = RT_ABS(iCpuHzDeviation); 159 if (uCpuHzDeviation > 999999999) 160 RTStrPrintf(szCpuHzDeviation, sizeof(szCpuHzDeviation), "%17s ", "?"); 161 else 160 /* Only CPU 0 is updated for invariant & sync modes, see supdrvGipUpdate(). */ 161 if ( iCpu == 0 162 || g_pSUPGlobalInfoPage->u32Mode == SUPGIPMODE_ASYNC_TSC) 162 163 { 163 164 /* Wait until the history validation code takes effect. */ 164 bool fCurHzCompat = true;165 165 if (pCpu->u32TransactionId > 23 + (8 * 2) + 1) 166 166 { 167 if (RT_ABS(iCpuHzDeviation) > RT_ABS(iCpuHzMaxDeviation)) 168 iCpuHzMaxDeviation = iCpuHzDeviation; 169 uCpuHzOverallDeviation += uCpuHzDeviation; 170 cCpuHzOverallDevCnt++; 171 fCurHzCompat = SUPIsTscFreqCompatibleEx(uCpuHzRef, pCpu->u64CpuHz, false /* fRelax */); 167 int64_t iCpuHzDeviation = pCpu->u64CpuHz - uCpuHzRef; 168 uint64_t uCpuHzDeviation = RT_ABS(iCpuHzDeviation); 169 bool fCurHzCompat = SUPIsTscFreqCompatibleEx(uCpuHzRef, pCpu->u64CpuHz, false /*fRelax*/); 170 if (uCpuHzDeviation <= 999999999) 171 { 172 if (RT_ABS(iCpuHzDeviation) > RT_ABS(iCpuHzMaxDeviation)) 173 iCpuHzMaxDeviation = iCpuHzDeviation; 174 uCpuHzOverallDeviation += uCpuHzDeviation; 175 cCpuHzOverallDevCnt++; 176 uint32_t uPct = (uint32_t)(uCpuHzDeviation * 100000 / uCpuHzRef + 5); 177 RTStrPrintf(szCpuHzDeviation, sizeof(szCpuHzDeviation), "%10RI64%3d.%02d%% %RTbool ", 178 iCpuHzDeviation, uPct / 1000, (uPct % 1000) / 10, fCurHzCompat); 179 } 180 else 181 { 182 RTStrPrintf(szCpuHzDeviation, sizeof(szCpuHzDeviation), "%17s %RTbool ", "?", 183 fCurHzCompat); 184 } 185 186 if (!fCurHzCompat) 187 ++cCpuHzNotCompat; 188 fCompat &= fCurHzCompat; 189 ++cCpuHzChecked; 172 190 } 173 uint32_t uPct = (uint32_t)(uCpuHzDeviation * 100000 / uCpuHzRef + 5); 174 RTStrPrintf(szCpuHzDeviation, sizeof(szCpuHzDeviation), "%10RI64%3d.%02d%% %RTbool ", 175 iCpuHzDeviation, uPct / 1000, (uPct % 1000) / 10, fCurHzCompat); 176 if (!fCurHzCompat) 177 ++cCpuHzNotCompat; 178 fCompat &= fCurHzCompat; 191 else 192 RTStrPrintf(szCpuHzDeviation, sizeof(szCpuHzDeviation), "%25s ", "priming"); 179 193 } 194 else 195 RTStrPrintf(szCpuHzDeviation, sizeof(szCpuHzDeviation), "%25s ", ""); 180 196 } 181 197 else … … 209 225 } 210 226 211 /* wait a bit / spin*/227 /* Wait a bit / spin. */ 212 228 if (!fSpin) 213 229 RTThreadSleep(9); … … 251 267 RTPrintf("tstGIP-2: enmUseTscDelta=%d fGetGipCpu=%#x\n", 252 268 g_pSUPGlobalInfoPage->enmUseTscDelta, g_pSUPGlobalInfoPage->fGetGipCpu); 253 if ( uCpuHzRef 254 && cCpuHzOverallDevCnt) 269 if (uCpuHzRef) 255 270 { 256 uint32_t uPct = (uint32_t)(uCpuHzOverallDeviation * 100000 / cCpuHzOverallDevCnt / uCpuHzRef + 5); 257 RTPrintf("tstGIP-2: Average CpuHz deviation: %d.%02d%%\n", 258 uPct / 1000, (uPct % 1000) / 10); 259 260 uint32_t uMaxPct = (uint32_t)(RT_ABS(iCpuHzMaxDeviation) * 100000 / uCpuHzRef + 5); 261 RTPrintf("tstGIP-2: Maximum CpuHz deviation: %d.%02d%% (%RI64 ticks)\n", 262 uMaxPct / 1000, (uMaxPct % 1000) / 10, iCpuHzMaxDeviation); 263 264 RTPrintf("tstGIP-2: CpuHz compatibility: %RTbool (incompatible %u of %u times w/ %RU64 Hz %s GIP)\n", fCompat, 265 cCpuHzNotCompat, cIterations * g_pSUPGlobalInfoPage->cCpus, uCpuHzRef, 266 SUPGetGIPModeName(g_pSUPGlobalInfoPage)); 271 if (cCpuHzOverallDevCnt) 272 { 273 uint32_t uPct = (uint32_t)(uCpuHzOverallDeviation * 100000 / cCpuHzOverallDevCnt / uCpuHzRef + 5); 274 RTPrintf("tstGIP-2: Average CpuHz deviation: %d.%02d%%\n", 275 uPct / 1000, (uPct % 1000) / 10); 276 277 uint32_t uMaxPct = (uint32_t)(RT_ABS(iCpuHzMaxDeviation) * 100000 / uCpuHzRef + 5); 278 RTPrintf("tstGIP-2: Maximum CpuHz deviation: %d.%02d%% (%RI64 ticks)\n", 279 uMaxPct / 1000, (uMaxPct % 1000) / 10, iCpuHzMaxDeviation); 280 } 281 else 282 { 283 RTPrintf("tstGIP-2: Average CpuHz deviation: ??.??\n"); 284 RTPrintf("tstGIP-2: Average CpuHz deviation: ??.??\n"); 285 } 286 287 RTPrintf("tstGIP-2: CpuHz compatibility: %RTbool (incompatible %u of %u times w/ %RU64 Hz - %s GIP)\n", fCompat, 288 cCpuHzNotCompat, cCpuHzChecked, uCpuHzRef, SUPGetGIPModeName(g_pSUPGlobalInfoPage)); 267 289 268 290 if ( !fCompat
Note:
See TracChangeset
for help on using the changeset viewer.