VirtualBox

Changeset 54262 in vbox for trunk


Ignore:
Timestamp:
Feb 18, 2015 2:15:18 PM (10 years ago)
Author:
vboxsync
Message:

HostDrivers/support: keep the TSC-delta thread stuff working.

Location:
trunk/src/VBox/HostDrivers/Support
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r54252 r54262  
    40424042     *  initially). The callback clears the methods not detected. */
    40434043    uint32_t volatile   fSupported;
    4044     /** The first callback detecting any kind of range issues (initializsed to
     4044    /** The first callback detecting any kind of range issues (initialized to
    40454045     * NIL_RTCPUID). */
    40464046    RTCPUID volatile    idCpuProblem;
     
    41374137        AssertCompile(sizeof(pState->bmApicId) * 8 == RT_ELEMENTS(pGip->aiCpuFromApicId));
    41384138        ASMAtomicCmpXchgU32(&pState->idCpuProblem, idCpu, NIL_RTCPUID);
    4139         LogRel(("supdrvGipDetectGetGipCpuCallback: idCpu=%#x iCpuSet=%d idApic=%#x - duplicate APIC ID.\n", 
     4139        LogRel(("supdrvGipDetectGetGipCpuCallback: idCpu=%#x iCpuSet=%d idApic=%#x - duplicate APIC ID.\n",
    41404140                idCpu, iCpuSet, idApic));
    41414141    }
     
    41494149    {
    41504150        ASMAtomicCmpXchgU32(&pState->idCpuProblem, idCpu, NIL_RTCPUID);
    4151         LogRel(("supdrvGipDetectGetGipCpuCallback: idCpu=%#x iCpuSet=%d idApic=%#x - CPU set index is out of range.\n", 
     4151        LogRel(("supdrvGipDetectGetGipCpuCallback: idCpu=%#x iCpuSet=%d idApic=%#x - CPU set index is out of range.\n",
    41524152                idCpu, iCpuSet, idApic));
    41534153    }
     
    61206120                    pDevExt->enmTscDeltaState = kSupDrvTscDeltaState_Listening;
    61216121                RTSpinlockRelease(pDevExt->hTscDeltaSpinlock);
    6122                 pDevExt->rcTscDelta = rc;
     6122                Assert(rc != VERR_NOT_AVAILABLE);   /* VERR_NOT_AVAILABLE is used as the initial value. */
     6123                ASMAtomicWriteS32(&pDevExt->rcTscDelta, rc);
    61236124                break;
    61246125            }
     
    62506251static int supdrvTscDeltaThreadInit(PSUPDRVDEVEXT pDevExt)
    62516252{
     6253    int rc;
    62526254    Assert(pDevExt->pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_ZERO_CLAIMED);
    6253 
    6254     int rc = RTSpinlockCreate(&pDevExt->hTscDeltaSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "VBoxTscSpnLck");
     6255    rc = RTSpinlockCreate(&pDevExt->hTscDeltaSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "VBoxTscSpnLck");
    62556256    if (RT_SUCCESS(rc))
    62566257    {
     
    62696270                if (RT_SUCCESS(rc))
    62706271                {
    6271                     pDevExt->rcTscDelta = VERR_NOT_AVAILABLE;
     6272                    ASMAtomicWriteS32(&pDevExt->rcTscDelta, VERR_NOT_AVAILABLE);
    62726273                    return rc;
    62736274                }
     
    63186319    }
    63196320
    6320     pDevExt->rcTscDelta = VERR_NOT_AVAILABLE;
     6321    ASMAtomicWriteS32(&pDevExt->rcTscDelta, VERR_NOT_AVAILABLE);
    63216322}
    63226323
     
    63376338    PSUPGLOBALINFOPAGE pGip = pDevExt->pGip;
    63386339    AssertReturn(pGip, VERR_INVALID_POINTER);
     6340
     6341    if (RT_UNLIKELY(pDevExt->hTscDeltaThread == NIL_RTTHREAD))
     6342        return VERR_THREAD_NOT_WAITABLE;
    63396343
    63406344    cMsTotalWait = RT_MIN(pGip->cPresentCpus + 2, 150);
     
    65826586    u64DeltaTsc = u64Tsc - pDevExt->u64TscAnchor;
    65836587
    6584     if (   pGip->u32Mode == SUPGIPMODE_INVARIANT_TSC
    6585         && !fDeltaApplied)
    6586     {
    6587         SUPR0Printf("vboxdrv: failed to refine TSC frequency as TSC-deltas unavailable after %d seconds!\n",
    6588                     GIP_TSC_REFINE_INTERVAL);
     6588    if (RT_UNLIKELY(   pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_PRACTICALLY_ZERO
     6589                    && !fDeltaApplied))
     6590    {
     6591        Log(("vboxdrv: failed to refine TSC frequency as TSC-deltas unavailable after %d seconds!\n",
     6592                    GIP_TSC_REFINE_INTERVAL));
    65896593        return;
    65906594    }
     
    66206624    uint8_t             idApic;
    66216625    int                 rc;
    6622     bool                fDeltaApplied = false;
    66236626    PSUPGLOBALINFOPAGE  pGip;
    66246627
     
    66266629    Assert(pDevExt);
    66276630    Assert(pDevExt->pGip);
    6628 
    6629     /*
    6630      * <Insert missing comment [it's not "Validate.", I think...]>
    6631      */
    66326631    pGip = pDevExt->pGip;
     6632
     6633#ifdef SUPDRV_USE_TSC_DELTA_THREAD
     6634    /*
     6635     * If the TSC-delta thread is created, wait until it's done calculating
     6636     * the TSC-deltas on the relevant online CPUs before we start the TSC refinement.
     6637     */
     6638    if (   pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_ZERO_CLAIMED
     6639        && ASMAtomicReadS32(&pDevExt->rcTscDelta) == VERR_NOT_AVAILABLE)
     6640    {
     6641        rc = supdrvTscDeltaThreadWaitForOnlineCpus(pDevExt);
     6642        if (rc == VERR_TIMEOUT)
     6643        {
     6644            SUPR0Printf("vboxdrv: Skipping refinement of TSC frequency as TSC-delta measurement timed out!\n");
     6645            return;
     6646        }
     6647    }
     6648#endif
     6649
     6650    /*
     6651     * Record the TSC and NanoTS as the starting anchor point for refinement of the
     6652     * TSC. We deliberately avoid using SUPReadTSC() here as we want to keep the
     6653     * reading of the TSC and the NanoTS as close as possible.
     6654     */
    66336655    u64NanoTS = RTTimeSystemNanoTS();
    66346656    while (RTTimeSystemNanoTS() == u64NanoTS)
     
    66406662    ASMSetFlags(uFlags);
    66416663    if (pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_PRACTICALLY_ZERO)
    6642         supdrvTscDeltaApply(pGip, &pDevExt->u64TscAnchor, idApic, &fDeltaApplied);
    6643 
    6644 #ifdef SUPDRV_USE_TSC_DELTA_THREAD
    6645     /*
    6646      * <Explain yourself>
    6647      */
    6648     /** @todo r=bird: This is (and was) bogus on systems where we don't need to
    6649      *        apply any delta (not used on windows doesn't stick without comments).
    6650      *        What is the logic you want here exactly? */
    6651     if (   pGip->u32Mode == SUPGIPMODE_INVARIANT_TSC
    6652         && !fDeltaApplied)
    6653     {
    6654         rc = supdrvTscDeltaThreadWaitForOnlineCpus(pDevExt);
    6655         if (rc == VERR_TIMEOUT)
    6656         {
    6657             SUPR0Printf("vboxdrv: Skipping refinement of TSC frequency as TSC-delta measurement timed out!\n");
    6658             return;
    6659         }
    6660     }
    6661 #endif
     6664        supdrvTscDeltaApply(pGip, &pDevExt->u64TscAnchor, idApic, NULL /* pfDeltaApplied */);
    66626665
    66636666    rc = RTTimerCreateEx(&pDevExt->pTscRefineTimer, 0 /* one-shot */, RTTIMER_FLAGS_CPU_ANY, supdrvRefineTscTimer, pDevExt);
     
    67736776            if (RT_SUCCESS(rc))
    67746777            {
     6778#ifndef SUPDRV_USE_TSC_DELTA_THREAD
    67756779                uint16_t iCpu;
    6776 #ifndef SUPDRV_USE_TSC_DELTA_THREAD
    67776780                if (pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_ZERO_CLAIMED)
    67786781                {
     
    68166819                        }
    68176820                        if (pGip->u32Mode != SUPGIPMODE_ASYNC_TSC)
    6818                             rc = RTTimerCreateEx(&pDevExt->pGipTimer, u32Interval, 0 /* fFlags */, 
     6821                            rc = RTTimerCreateEx(&pDevExt->pGipTimer, u32Interval, 0 /* fFlags */,
    68196822                                                 supdrvGipSyncAndInvariantTimer, pDevExt);
    68206823                        if (RT_SUCCESS(rc))
     
    69316934
    69326935/**
    6933  * Timer callback function for the sync and invariant  GIP modes.
    6934  * 
     6936 * Timer callback function for the sync and invariant GIP modes.
     6937 *
    69356938 * @param   pTimer      The timer.
    69366939 * @param   pvUser      Opaque pointer to the device extension.
     
    83208323    cMsWaitRetry = RT_MAX(pReq->u.In.cMsWaitRetry, 5);
    83218324
    8322     /* 
     8325    /*
    83238326     * The request is a noop if the TSC delta isn't being used.
    83248327     */
  • trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h

    r54013 r54262  
    732732    RTCPUSET                        TscDeltaObtainedCpuSet;
    733733    /** Whether the TSC-delta measurement was successful. */
    734     int                             rcTscDelta;
     734    int32_t volatile                rcTscDelta;
    735735    /** @} */
    736736#endif
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette