Changeset 54290 in vbox for trunk/src/VBox/HostDrivers/Support
- Timestamp:
- Feb 19, 2015 11:16:49 AM (10 years ago)
- Location:
- trunk/src/VBox/HostDrivers/Support
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r54282 r54290 6012 6012 RTSpinlockAcquire(pDevExt->hTscDeltaSpinlock); 6013 6013 6014 pDevExt->enmTscDelta State = kSupDrvTscDeltaState_Butchered;6014 pDevExt->enmTscDeltaThreadState = kTscDeltaThreadState_Butchered; 6015 6015 RTSpinlockRelease(pDevExt->hTscDeltaSpinlock); 6016 6016 OSDBGPRINT(("supdrvTscDeltaThreadButchered: %s. rc=%Rrc\n", rcFailed)); … … 6037 6037 * Switch on the current state. 6038 6038 */ 6039 SUPDRVTSCDELTA STATE enmState;6039 SUPDRVTSCDELTATHREADSTATE enmState; 6040 6040 RTSpinlockAcquire(pDevExt->hTscDeltaSpinlock); 6041 enmState = pDevExt->enmTscDelta State;6041 enmState = pDevExt->enmTscDeltaThreadState; 6042 6042 switch (enmState) 6043 6043 { 6044 case k SupDrvTscDeltaState_Creating:6045 { 6046 pDevExt->enmTscDelta State = kSupDrvTscDeltaState_Listening;6044 case kTscDeltaThreadState_Creating: 6045 { 6046 pDevExt->enmTscDeltaThreadState = kTscDeltaThreadState_Listening; 6047 6047 rc = RTSemEventSignal(pDevExt->hTscDeltaEvent); 6048 6048 if (RT_FAILURE(rc)) … … 6051 6051 } 6052 6052 6053 case k SupDrvTscDeltaState_Listening:6053 case kTscDeltaThreadState_Listening: 6054 6054 { 6055 6055 RTSpinlockRelease(pDevExt->hTscDeltaSpinlock); … … 6073 6073 } 6074 6074 6075 case k SupDrvTscDeltaState_WaitAndMeasure:6076 { 6077 pDevExt->enmTscDelta State = kSupDrvTscDeltaState_Measuring;6075 case kTscDeltaThreadState_WaitAndMeasure: 6076 { 6077 pDevExt->enmTscDeltaThreadState = kTscDeltaThreadState_Measuring; 6078 6078 rc = RTSemEventSignal(pDevExt->hTscDeltaEvent); 6079 6079 if (RT_FAILURE(rc)) … … 6085 6085 } 6086 6086 6087 case k SupDrvTscDeltaState_Measuring:6087 case kTscDeltaThreadState_Measuring: 6088 6088 { 6089 6089 cConsecutiveTimeouts = 0; … … 6117 6117 } 6118 6118 RTSpinlockAcquire(pDevExt->hTscDeltaSpinlock); 6119 if (pDevExt->enmTscDelta State == kSupDrvTscDeltaState_Measuring)6120 pDevExt->enmTscDelta State = kSupDrvTscDeltaState_Listening;6119 if (pDevExt->enmTscDeltaThreadState == kTscDeltaThreadState_Measuring) 6120 pDevExt->enmTscDeltaThreadState = kTscDeltaThreadState_Listening; 6121 6121 RTSpinlockRelease(pDevExt->hTscDeltaSpinlock); 6122 6122 Assert(rc != VERR_NOT_AVAILABLE); /* VERR_NOT_AVAILABLE is used as the initial value. */ … … 6125 6125 } 6126 6126 6127 case k SupDrvTscDeltaState_Terminating:6127 case kTscDeltaThreadState_Terminating: 6128 6128 RTSpinlockRelease(pDevExt->hTscDeltaSpinlock); 6129 6129 return VINF_SUCCESS; 6130 6130 6131 case k SupDrvTscDeltaState_Butchered:6131 case kTscDeltaThreadState_Butchered: 6132 6132 default: 6133 6133 return supdrvTscDeltaThreadButchered(pDevExt, true /* fSpinlockHeld */, "Invalid state", VERR_INVALID_STATE); … … 6149 6149 * @param enmNewState The new state we're waiting for it to enter. 6150 6150 */ 6151 static int supdrvTscDeltaThreadWait(PSUPDRVDEVEXT pDevExt, SUPDRVTSCDELTASTATE enmCurState, SUPDRVTSCDELTASTATE enmNewState) 6151 static int supdrvTscDeltaThreadWait(PSUPDRVDEVEXT pDevExt, SUPDRVTSCDELTATHREADSTATE enmCurState, 6152 SUPDRVTSCDELTATHREADSTATE enmNewState) 6152 6153 { 6153 6154 /* … … 6157 6158 RTSemEventWait(pDevExt->hTscDeltaEvent, RT_MS_1SEC); 6158 6159 RTSpinlockAcquire(pDevExt->hTscDeltaSpinlock); 6159 if (pDevExt->enmTscDelta State == enmNewState)6160 if (pDevExt->enmTscDeltaThreadState == enmNewState) 6160 6161 { 6161 6162 RTSpinlockRelease(pDevExt->hTscDeltaSpinlock); 6162 6163 rc = VINF_SUCCESS; 6163 6164 } 6164 else if (pDevExt->enmTscDelta State == enmCurState)6165 else if (pDevExt->enmTscDeltaThreadState == enmCurState) 6165 6166 { 6166 6167 /* … … 6175 6176 * Check the state whether we've succeeded. 6176 6177 */ 6177 SUPDRVTSCDELTA STATE enmState;6178 SUPDRVTSCDELTATHREADSTATE enmState; 6178 6179 RTSpinlockAcquire(pDevExt->hTscDeltaSpinlock); 6179 enmState = pDevExt->enmTscDelta State;6180 enmState = pDevExt->enmTscDeltaThreadState; 6180 6181 RTSpinlockRelease(pDevExt->hTscDeltaSpinlock); 6181 6182 if (enmState == enmNewState) … … 6217 6218 int rc; 6218 6219 RTSpinlockAcquire(pDevExt->hTscDeltaSpinlock); 6219 pDevExt->enmTscDelta State = kSupDrvTscDeltaState_Terminating;6220 pDevExt->enmTscDeltaThreadState = kTscDeltaThreadState_Terminating; 6220 6221 RTSpinlockRelease(pDevExt->hTscDeltaSpinlock); 6221 6222 RTThreadUserSignal(pDevExt->hTscDeltaThread); … … 6259 6260 if (RT_SUCCESS(rc)) 6260 6261 { 6261 pDevExt->enmTscDelta State = kSupDrvTscDeltaState_Creating;6262 pDevExt->enmTscDeltaThreadState = kTscDeltaThreadState_Creating; 6262 6263 pDevExt->cMsTscDeltaTimeout = 1; 6263 6264 RTCpuSetEmpty(&pDevExt->TscDeltaCpuSet); … … 6267 6268 if (RT_SUCCESS(rc)) 6268 6269 { 6269 rc = supdrvTscDeltaThreadWait(pDevExt, k SupDrvTscDeltaState_Creating, kSupDrvTscDeltaState_Listening);6270 rc = supdrvTscDeltaThreadWait(pDevExt, kTscDeltaThreadState_Creating, kTscDeltaThreadState_Listening); 6270 6271 if (RT_SUCCESS(rc)) 6271 6272 { … … 7102 7103 RTSpinlockAcquire(pDevExt->hTscDeltaSpinlock); 7103 7104 RTCpuSetAdd(&pDevExt->TscDeltaCpuSet, idCpu); 7104 if ( pDevExt->enmTscDelta State == kSupDrvTscDeltaState_Listening7105 || pDevExt->enmTscDelta State == kSupDrvTscDeltaState_Measuring)7106 { 7107 pDevExt->enmTscDelta State = kSupDrvTscDeltaState_WaitAndMeasure;7105 if ( pDevExt->enmTscDeltaThreadState == kTscDeltaThreadState_Listening 7106 || pDevExt->enmTscDeltaThreadState == kTscDeltaThreadState_Measuring) 7107 { 7108 pDevExt->enmTscDeltaThreadState = kTscDeltaThreadState_WaitAndMeasure; 7108 7109 } 7109 7110 RTSpinlockRelease(pDevExt->hTscDeltaSpinlock); … … 8348 8349 RTSpinlockAcquire(pDevExt->hTscDeltaSpinlock); 8349 8350 RTCpuSetAdd(&pDevExt->TscDeltaCpuSet, pGipCpuWorker->idCpu); 8350 if ( pDevExt->enmTscDelta State == kSupDrvTscDeltaState_Listening8351 || pDevExt->enmTscDelta State == kSupDrvTscDeltaState_Measuring)8351 if ( pDevExt->enmTscDeltaThreadState == kTscDeltaThreadState_Listening 8352 || pDevExt->enmTscDeltaThreadState == kTscDeltaThreadState_Measuring) 8352 8353 { 8353 pDevExt->enmTscDelta State = kSupDrvTscDeltaState_WaitAndMeasure;8354 pDevExt->enmTscDeltaThreadState = kTscDeltaThreadState_WaitAndMeasure; 8354 8355 } 8355 8356 RTSpinlockRelease(pDevExt->hTscDeltaSpinlock); … … 8357 8358 return VINF_SUCCESS; 8358 8359 } 8360 8361 /* 8362 * If a TSC-delta measurement request is already being serviced by the thread, 8363 * wait 'cTries' times if a retry-timeout is provided, otherwise bail as busy. 8364 */ 8365 while (cTries-- > 0) 8366 { 8367 SUPDRVTSCDELTATHREADSTATE enmState; 8368 RTSpinlockAcquire(pDevExt->hTscDeltaSpinlock); 8369 enmState = pDevExt->enmTscDeltaThreadState; 8370 RTSpinlockRelease(pDevExt->hTscDeltaSpinlock); 8371 8372 if ( enmState == kTscDeltaThreadState_Measuring 8373 || enmState == kTscDeltaThreadState_WaitAndMeasure) 8374 { 8375 if ( !cTries 8376 || !cMsWaitRetry) 8377 return VERR_SUPDRV_TSC_DELTA_MEASUREMENT_BUSY; 8378 if (cMsWaitRetry) 8379 RTThreadSleep(cMsWaitRetry); 8380 } 8381 } 8382 cTries = RT_MAX(pReq->u.In.cRetries + 1, 10); 8359 8383 #endif 8360 8384 -
trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h
r54262 r54290 231 231 #endif 232 232 233 #if 0233 #if 1 234 234 /** Use a dedicated kernel thread to service TSC-delta measurement requests. 235 235 * @todo Test on servers with many CPUs and sockets. */ … … 247 247 * TSC-delta measurement thread state machine. 248 248 */ 249 typedef enum SUPDRVTSCDELTA STATE249 typedef enum SUPDRVTSCDELTATHREADSTATE 250 250 { 251 251 /** Uninitialized/invalid value. */ 252 k SupDrvTscDeltaState_Invalid = 0,252 kTscDeltaThreadState_Invalid = 0, 253 253 /** The thread is being created. */ 254 k SupDrvTscDeltaState_Creating,254 kTscDeltaThreadState_Creating, 255 255 /** The thread is listening for events. */ 256 k SupDrvTscDeltaState_Listening,256 kTscDeltaThreadState_Listening, 257 257 /** The thread is sleeping before starting a measurement. */ 258 k SupDrvTscDeltaState_WaitAndMeasure,258 kTscDeltaThreadState_WaitAndMeasure, 259 259 /** The thread is currently servicing a measurement request. */ 260 k SupDrvTscDeltaState_Measuring,260 kTscDeltaThreadState_Measuring, 261 261 /** The thread is terminating. */ 262 k SupDrvTscDeltaState_Terminating,262 kTscDeltaThreadState_Terminating, 263 263 /** The thread is butchered due to an unexpected error. */ 264 k SupDrvTscDeltaState_Butchered,264 kTscDeltaThreadState_Butchered, 265 265 /** The thread is destroyed. */ 266 k SupDrvTscDeltaState_Destroyed,266 kTscDeltaThreadState_Destroyed, 267 267 /** The usual 32-bit blowup hack. */ 268 k SupDrvTscDeltaState_32BitHack = 0x7fffffff269 } SUPDRVTSCDELTA STATE;268 kTscDeltaThreadState_32BitHack = 0x7fffffff 269 } SUPDRVTSCDELTATHREADSTATE, *PSUPDRVTSCDELTATHREADSTATE; 270 270 #endif 271 271 … … 717 717 /** @name TSC-delta measurement thread. 718 718 * @{ */ 719 /** Spinlock protecting enmTscDelta State. */719 /** Spinlock protecting enmTscDeltaThreadState. */ 720 720 RTSPINLOCK hTscDeltaSpinlock; 721 721 /** TSC-delta measurement thread. */ … … 724 724 RTSEMEVENT hTscDeltaEvent; 725 725 /** The state of the TSC-delta measurement thread. */ 726 SUPDRVTSCDELTA STATE enmTscDeltaState;726 SUPDRVTSCDELTATHREADSTATE enmTscDeltaThreadState; 727 727 /** Thread timeout time before rechecking state in ms. */ 728 728 RTMSINTERVAL cMsTscDeltaTimeout;
Note:
See TracChangeset
for help on using the changeset viewer.