VirtualBox

Changeset 34321 in vbox


Ignore:
Timestamp:
Nov 24, 2010 1:35:10 PM (14 years ago)
Author:
vboxsync
Message:

SUPDrv.c: Set the windows timer granularity to 1024, 1000, 512 or 500 HZ (higher is prefered) while VMs are running (tied to GIP actually).

File:
1 edited

Legend:

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

    r33540 r34321  
    460460                    {
    461461                        pDevExt->u32Cookie = BIRD;  /** @todo make this random? */
    462                         pDevExt->cbSession = cbSession;
     462                        pDevExt->cbSession = (uint32_t)cbSession;
    463463
    464464                        /*
     
    33443344                PSUPGLOBALINFOPAGE pGipR0 = pDevExt->pGip;
    33453345                uint64_t u64NanoTS;
     3346                uint32_t u32SystemResolution;
    33463347                unsigned i;
    33473348
    33483349                LogFlow(("SUPR0GipMap: Resumes GIP updating\n"));
     3350
     3351                /*
     3352                 * Try bump up the system timer resolution.
     3353                 * The more interrupts the better...
     3354                 */
     3355                if (   RT_SUCCESS_NP(RTTimerRequestSystemGranularity(  976563 /* 1024 HZ */, &u32SystemResolution))
     3356                    || RT_SUCCESS_NP(RTTimerRequestSystemGranularity( 1000000 /* 1000 HZ */, &u32SystemResolution))
     3357                    || RT_SUCCESS_NP(RTTimerRequestSystemGranularity( 1953125 /*  512 HZ */, &u32SystemResolution))
     3358                    || RT_SUCCESS_NP(RTTimerRequestSystemGranularity( 2000000 /*  500 HZ */, &u32SystemResolution))
     3359                   )
     3360                {
     3361                    Assert(RTTimerGetSystemGranularity() <= u32SystemResolution);
     3362                    pDevExt->u32SystemTimerGranularityGrant = u32SystemResolution;
     3363                }
    33493364
    33503365                if (pGipR0->aCPUs[0].u32TransactionId != 2 /* not the first time */)
     
    34503465            rc = RTTimerStop(pDevExt->pGipTimer); AssertRC(rc); rc = VINF_SUCCESS;
    34513466#endif
     3467
     3468            if (pDevExt->u32SystemTimerGranularityGrant)
     3469            {
     3470                int rc2 = RTTimerReleaseSystemGranularity(pDevExt->u32SystemTimerGranularityGrant); AssertRC(rc);
     3471                pDevExt->u32SystemTimerGranularityGrant = 0;
     3472            }
    34523473        }
    34533474    }
     
    48674888    HCPhysGip = RTR0MemObjGetPagePhysAddr(pDevExt->GipMemObj, 0); Assert(HCPhysGip != NIL_RTHCPHYS);
    48684889
    4869 #if 0 /** @todo Disabled this as we didn't used to do it before and causes unnecessary stress on laptops.
    4870        * It only applies to Windows and should probably revisited later, if possible made part of the
    4871        * timer code (return min granularity in RTTimerGetSystemGranularity and set it in RTTimerStart). */
    4872     /*
    4873      * Try bump up the system timer resolution.
    4874      * The more interrupts the better...
    4875      */
    4876     if (   RT_SUCCESS(RTTimerRequestSystemGranularity(  488281 /* 2048 HZ */, &u32SystemResolution))
    4877         || RT_SUCCESS(RTTimerRequestSystemGranularity(  500000 /* 2000 HZ */, &u32SystemResolution))
    4878         || RT_SUCCESS(RTTimerRequestSystemGranularity(  976563 /* 1024 HZ */, &u32SystemResolution))
    4879         || RT_SUCCESS(RTTimerRequestSystemGranularity( 1000000 /* 1000 HZ */, &u32SystemResolution))
    4880         || RT_SUCCESS(RTTimerRequestSystemGranularity( 1953125 /*  512 HZ */, &u32SystemResolution))
    4881         || RT_SUCCESS(RTTimerRequestSystemGranularity( 2000000 /*  500 HZ */, &u32SystemResolution))
    4882         || RT_SUCCESS(RTTimerRequestSystemGranularity( 3906250 /*  256 HZ */, &u32SystemResolution))
    4883         || RT_SUCCESS(RTTimerRequestSystemGranularity( 4000000 /*  250 HZ */, &u32SystemResolution))
    4884         || RT_SUCCESS(RTTimerRequestSystemGranularity( 7812500 /*  128 HZ */, &u32SystemResolution))
    4885         || RT_SUCCESS(RTTimerRequestSystemGranularity(10000000 /*  100 HZ */, &u32SystemResolution))
    4886         || RT_SUCCESS(RTTimerRequestSystemGranularity(15625000 /*   64 HZ */, &u32SystemResolution))
    4887         || RT_SUCCESS(RTTimerRequestSystemGranularity(31250000 /*   32 HZ */, &u32SystemResolution))
    4888        )
    4889     {
    4890         Assert(RTTimerGetSystemGranularity() <= u32SystemResolution);
    4891         pDevExt->u32SystemTimerGranularityGrant = u32SystemResolution;
    4892     }
    4893 #endif
    4894 
    48954890    /*
    48964891     * Find a reasonable update interval and initialize the structure.
     
    49834978
    49844979    /*
    4985      * Finally, release the system timer resolution request if one succeeded.
     4980     * Finally, make sure we've release the system timer resolution request
     4981     * if one actually succeeded and is still pending.
    49864982     */
    49874983    if (pDevExt->u32SystemTimerGranularityGrant)
     
    52865282            = pGip->aCPUs[i].au32TSCHistory[6]
    52875283            = pGip->aCPUs[i].au32TSCHistory[7]
    5288             = /*pGip->aCPUs[i].u64CpuHz*/ _4G / uUpdateHz;
     5284            = /*pGip->aCPUs[i].u64CpuHz*/ (uint32_t)(_4G / uUpdateHz);
    52895285    }
    52905286
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