VirtualBox

Ignore:
Timestamp:
Oct 24, 2014 2:03:12 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
96675
Message:

HostDrivers/support: Fix sign while applying TSC deltas, fix GIP timer update interval, fix premature commit of switching to sync TSC.

File:
1 edited

Legend:

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

    r53106 r53142  
    59545954            /*
    59555955             * Sleep wait since the TSC frequency is constant, eases host load.
     5956             * Shorter interval produces more variance in the frequency (esp. Windows).
    59565957             */
    5957 #if 0
    5958             RTThreadSleep(98);
    5959             do
    5960             {
    5961                 int64_t cNsWaited;
    5962                 u64NanoTsAfter = RTTimeSystemNanoTS();
    5963                 cNsWaited      = u64NanoTsAfter - u64NanoTs;
    5964                 if (cNsWaited > RT_NS_100MS)
    5965                 {
    5966                     uint64_t cNsBusyWait = RT_NS_1MS;
    5967                     for (;;)
    5968                     {
    5969                         u64NanoTsAfter = RTTimeSystemNanoTS();
    5970                         if (u64NanoTsAfter < cNsBusyWait + cNsWaited + u64NanoTs)
    5971                             ASMNopPause();
    5972                         else
    5973                             break;
    5974                     }
    5975                     break;
    5976                 }
    5977             } while (1);
    5978 #else
    59795958            RTThreadSleep(200);   /* Sleeping shorter produces a tad more variance in the frequency than I'd like. */
    59805959            u64NanoTsAfter = RTTimeSystemNanoTS();
     
    59825961                ASMNopPause();
    59835962            u64NanoTsAfter = RTTimeSystemNanoTS();
    5984 #endif
    59855963        }
    59865964        else
     
    60185996                && pGipCpuAfter->i64TSCDelta  != INT64_MAX)
    60195997            {
    6020                 u64TscBefore += pGipCpuBefore->i64TSCDelta;
    6021                 u64TscAfter  += pGipCpuAfter->i64TSCDelta;
     5998                u64TscBefore -= pGipCpuBefore->i64TSCDelta;
     5999                u64TscAfter  -= pGipCpuAfter->i64TSCDelta;
    60226000
    60236001                SUPR0Printf("vboxdrv: TSC frequency is %lu Hz - invariant, kernel timer granularity is %lu Ns\n",
     
    60946072    /*
    60956073     * Find a reasonable update interval and initialize the structure.
    6096      *
    6097      * If we have an invariant TSC, use a larger update interval as then
    6098      * we get better accuracy along with lower host load.
    6099      */
    6100     u32MinInterval      = supdrvIsInvariantTsc() ? RT_NS_100MS : RT_NS_10MS;
     6074     */
     6075    /** @todo figure out why using a 100Ms interval upsets timekeeping in VMs.
     6076     *        See @bugref{6710}. */
     6077    u32MinInterval      = RT_NS_10MS;
    61016078    u32SystemResolution = RTTimerGetSystemGranularity();
    61026079    u32Interval         = u32MinInterval;
     
    62796256         */
    62806257        if (pGipCpu->i64TSCDelta != INT64_MAX)
    6281             u64TSC += pGipCpu->i64TSCDelta;
     6258            u64TSC -= pGipCpu->i64TSCDelta;
    62826259    }
    62836260
     
    70757052static SUPGIPMODE supdrvGipDeterminTscMode(PSUPDRVDEVEXT pDevExt)
    70767053{
     7054#if 0
    70777055    if (supdrvIsInvariantTsc())
    70787056        return SUPGIPMODE_SYNC_TSC;     /** @todo Switch to SUPGIPMODE_INVARIANT_TSC later. */
     7057#endif
    70797058
    70807059    /*
     
    73417320
    73427321    /*
    7343      * For invariant TSC support, we take only 1 interval as there is a problem on
    7344      * Windows where we have an occasional (but reccurring) sour value that messes up
    7345      * the history. Also, since the update interval is pretty long with the invariant
    7346      * TSC case this works accurately enough.
    7347      */
    7348     if (supdrvIsInvariantTsc())
    7349     {
    7350         u32UpdateIntervalTSC = (uint32_t)u64TSCDelta;
    7351         u32UpdateIntervalTSCSlack = u32UpdateIntervalTSC >> 6;
    7352     }
    7353     /*
    73547322     * UpdateIntervalTSC = average of last 8,2,1 intervals depending on update HZ.
    7355      */
    7356     else if (pGip->u32UpdateHz >= 1000)
     7323     *
     7324     * On Windows, we have an occasional (but recurring) sour value that messed up
     7325     * the history but taking only 1 interval reduces the precision overall.
     7326     * However, this problem existed before the invariant mode was introduced.
     7327     */
     7328    if (   supdrvIsInvariantTsc()
     7329        || pGip->u32UpdateHz >= 1000)
    73577330    {
    73587331        uint32_t u32;
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