VirtualBox

Changeset 54447 in vbox


Ignore:
Timestamp:
Feb 24, 2015 1:38:39 PM (10 years ago)
Author:
vboxsync
Message:

SUPDrvGip.cpp: Use a interval timer as solaris cannot restart one-shot timers from the callback. This is a better idea anyway as I get ticks I can use to record the refinement history in the u64CpuHz members of CPU entries 1+ :-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrvGip.cpp

    r54409 r54447  
    712712 * @param   nsElapsed           The number of nano seconds elapsed.
    713713 * @param   cElapsedTscTicks    The corresponding number of TSC ticks.
    714  */
    715 static void supdrvGipInitSetCpuFreq(PSUPGLOBALINFOPAGE pGip, uint64_t nsElapsed, uint64_t cElapsedTscTicks)
     714 * @param   iTick               The tick number for debugging.
     715 */
     716static void supdrvGipInitSetCpuFreq(PSUPGLOBALINFOPAGE pGip, uint64_t nsElapsed, uint64_t cElapsedTscTicks, uint32_t iTick)
    716717{
    717718    /*
     
    736737    ASMAtomicWriteU64(&pGip->u64CpuHz, uCpuHz);
    737738    if (pGip->u32Mode != SUPGIPMODE_ASYNC_TSC)
     739    {
    738740        ASMAtomicWriteU64(&pGip->aCPUs[0].u64CpuHz, uCpuHz);
     741
     742        /* For inspecting the frequency calcs using tstGIP-2, debugger or similar. */
     743        if (iTick + 1 < pGip->cCpus)
     744            ASMAtomicWriteU64(&pGip->aCPUs[iTick + 1].u64CpuHz, uCpuHz);
     745    }
    739746}
    740747
     
    833840         * calculations.
    834841         */
    835         else if (cNsElapsed <= GIP_TSC_REFINE_PERIOD_IN_SECS * 5 * RT_NS_1SEC_64)
    836         {
    837             int rc = RTTimerStart(pTimer, RT_NS_1SEC);
    838             AssertRC(rc);
    839             return;
    840         }
    841         else
     842        else if (cNsElapsed > GIP_TSC_REFINE_PERIOD_IN_SECS * 5 * RT_NS_1SEC_64)
    842843        {
    843844            SUPR0Printf("vboxdrv: Failed to refine invariant TSC frequency because deltas are unavailable after %u (%u) seconds\n",
     
    845846            SUPR0Printf("vboxdrv: start: %u, %u, %#llx  stop: %u, %u, %#llx\n",
    846847                        iStartCpuSet, iStartGipCpu, iStartTscDelta, iStopCpuSet, iStopGipCpu, iStopTscDelta);
     848            int rc = RTTimerStop(pTimer);
     849            AssertRC(rc);
    847850            return;
    848851        }
     
    859862        || cNsElapsed < RT_NS_1SEC * 2)
    860863    {
    861         supdrvGipInitSetCpuFreq(pGip, cNsElapsed, cTscTicksElapsed);
     864        supdrvGipInitSetCpuFreq(pGip, cNsElapsed, cTscTicksElapsed, iTick);
    862865
    863866        /*
    864          * Reschedule the timer if we haven't yet reached the defined refinement period.
     867         * Stop the timer once we've reached the defined refinement period.
    865868         */
    866         if (cNsElapsed < GIP_TSC_REFINE_PERIOD_IN_SECS * RT_NS_1SEC_64)
    867         {
    868             int rc = RTTimerStart(pTimer, RT_NS_1SEC);
     869        if (cNsElapsed > GIP_TSC_REFINE_PERIOD_IN_SECS * RT_NS_1SEC_64)
     870        {
     871            int rc = RTTimerStop(pTimer);
    869872            AssertRC(rc);
    870873        }
     874    }
     875    else
     876    {
     877        int rc = RTTimerStop(pTimer);
     878        AssertRC(rc);
    871879    }
    872880}
     
    927935     * mapped (we want a stable frequency for all VMs).
    928936     */
    929     rc = RTTimerCreateEx(&pDevExt->pInvarTscRefineTimer, 0 /* one-shot */,
     937    rc = RTTimerCreateEx(&pDevExt->pInvarTscRefineTimer, RT_NS_1SEC,
    930938                         RTTIMER_FLAGS_CPU(RTMpCpuIdToSetIndex(pDevExt->idCpuInvarTscRefine)),
    931939                         supdrvInitRefineInvariantTscFreqTimer, pDevExt);
     
    940948    if (rc == VERR_CPU_OFFLINE || rc == VERR_NOT_SUPPORTED)
    941949    {
    942         rc = RTTimerCreateEx(&pDevExt->pInvarTscRefineTimer, 0 /* one-shot */, RTTIMER_FLAGS_CPU_ANY,
     950        rc = RTTimerCreateEx(&pDevExt->pInvarTscRefineTimer, RT_NS_1SEC, RTTIMER_FLAGS_CPU_ANY,
    943951                             supdrvInitRefineInvariantTscFreqTimer, pDevExt);
    944952        if (RT_SUCCESS(rc))
     
    11691177         * Calculate the TSC frequency and update it (shared with the refinement timer).
    11701178         */
    1171         supdrvGipInitSetCpuFreq(pGip, nsStop - nsStart, uTscStop - uTscStart);
     1179        supdrvGipInitSetCpuFreq(pGip, nsStop - nsStart, uTscStop - uTscStart, 0);
    11721180        return VINF_SUCCESS;
    11731181    }
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