VirtualBox

Changeset 2965 in vbox


Ignore:
Timestamp:
May 31, 2007 5:22:32 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
21673
Message:

Forgot to commit this the other day...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMEmt.cpp

    r2830 r2965  
    363363
    364364/**
    365  * Method 1 - Block whenever possible, and when lagging behind 
     365 * Method 1 - Block whenever possible, and when lagging behind
    366366 * switch to spinning for 10-30ms with occational blocking until
    367367 * the lag has been eliminated.
     
    377377    bool fBlockOnce = false;
    378378    bool fSpinning = false;
    379     if (TMVirtualSyncGetCatchUpPct(pVM) /* non-zero if catching up */)
    380     {
    381         const uint64_t u64Lag = TMVirtualSyncGetLag(pVM);
    382         fSpinning = u64Lag > 25000000 /* 25ms */;
    383         if (fSpinning)
    384         {
    385             if (!pVM->vm.s.Halt.Method12.u64StartSpinTS)
     379    uint32_t u32CatchUpPct = TMVirtualSyncGetCatchUpPct(pVM);
     380    if (u32CatchUpPct /* non-zero if catching up */)
     381    {
     382        if (pVM->vm.s.Halt.Method12.u64StartSpinTS)
     383        {
     384            fSpinning = TMVirtualSyncGetLag(pVM) >= 2*1000000;
     385            if (fSpinning)
     386            {
     387                uint64_t u64Lag = TMVirtualSyncGetLag(pVM);
     388                fBlockOnce = u64Now - pVM->vm.s.Halt.Method12.u64LastBlockTS
     389                           > RT_MAX(5*1000000, RT_MIN(u64Lag / 4, 200*1000000));
     390            }
     391            else
     392            {
     393RTLogRelPrintf("Stopped spinning (%u ms)\n", (u64Now - pVM->vm.s.Halt.Method12.u64StartSpinTS) / 1000000);
     394                pVM->vm.s.Halt.Method12.u64StartSpinTS = 0;
     395            }
     396        }
     397        else
     398        {
     399            fSpinning = TMVirtualSyncGetLag(pVM) >= 20*1000000;
     400            if (fSpinning)
    386401                pVM->vm.s.Halt.Method12.u64StartSpinTS = u64Now;
    387             else if (u64Now - pVM->vm.s.Halt.Method12.u64LastBlockTS > 32000000 /* 32ms */)
    388                 fBlockOnce = true;
    389         }
    390         else if (pVM->vm.s.Halt.Method12.u64StartSpinTS)
    391             pVM->vm.s.Halt.Method12.u64StartSpinTS = 0;
     402        }
    392403    }
    393404    else if (pVM->vm.s.Halt.Method12.u64StartSpinTS)
     405    {
     406RTLogRelPrintf("Stopped spinning (%u ms)\n", (u64Now - pVM->vm.s.Halt.Method12.u64StartSpinTS) / 1000000);
    394407        pVM->vm.s.Halt.Method12.u64StartSpinTS = 0;
     408    }
    395409
    396410    /*
     
    403417    {
    404418        /*
    405          * Work the timers and check if we can exit. 
     419         * Work the timers and check if we can exit.
    406420         */
    407421        STAM_REL_PROFILE_START(&pVM->vm.s.StatHaltPoll, a);
     
    424438         * Block if we're not spinning and the interval isn't all that small.
    425439         */
    426         if (    (   !fSpinning 
     440        if (    (   !fSpinning
    427441                 || fBlockOnce)
    428442            &&  u64NanoTS >= 250000) /* 0.250 ms */
     
    434448            if (cMilliSecs <= pVM->vm.s.Halt.Method12.cNSBlockedTooLongAvg)
    435449                cMilliSecs = 1;
    436             else 
     450            else
    437451                cMilliSecs -= pVM->vm.s.Halt.Method12.cNSBlockedTooLongAvg;
    438 //RTLogRelPrintf("u64NanoTS=%RI64 cLoops=%3d sleep %02dms (%7RU64) ", u64NanoTS, cLoops, cMilliSecs, u64NanoTS);
     452RTLogRelPrintf("u64NanoTS=%RI64 cLoops=%3d sleep %02dms (%7RU64) ", u64NanoTS, cLoops, cMilliSecs, u64NanoTS);
    439453            STAM_REL_PROFILE_START(&pVM->vm.s.StatHaltBlock, a);
    440454            rc = RTSemEventWait(pVM->vm.s.EventSemWait, cMilliSecs);
     
    451465            }
    452466
    453             /* 
    454              * Calc the statistics. 
     467            /*
     468             * Calc the statistics.
    455469             * Update averages every 16th time, and flush parts of the history every 64th time.
    456470             */
     
    469483                }
    470484            }
    471 //RTLogRelPrintf(" -> %7RU64 ns / %7RI64 ns delta%s\n", Elapsed, Elapsed - u64NanoTS, fBlockOnce ? " (block once)" : "");
     485RTLogRelPrintf(" -> %7RU64 ns / %7RI64 ns delta%s\n", Elapsed, Elapsed - u64NanoTS, fBlockOnce ? " (block once)" : "");
    472486
    473487            /*
     
    479493        }
    480494    }
     495if (fSpinning) RTLogRelPrintf("spun for %RU64 ns %u loops; lag=%RU64 pct=%d\n", RTTimeNanoTS() - u64Now, cLoops, TMVirtualSyncGetLag(pVM), u32CatchUpPct);
    481496
    482497    return rc;
     
    546561#else
    547562# error "misconfigured halt"
    548 #endif 
     563#endif
    549564
    550565    /*
Note: See TracChangeset for help on using the changeset viewer.

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