VirtualBox

Changeset 37230 in vbox for trunk/src/VBox/HostDrivers


Ignore:
Timestamp:
May 27, 2011 11:20:19 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
71952
Message:

SUPDrv.c: A couple of small cleanups.

File:
1 edited

Legend:

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

    r37228 r37230  
    49934993
    49944994/**
    4995  * Helper for finding the CPU index from the CPU Id.
    4996  *
    4997  * @param    pGip               The GIP.
    4998  * @param    idCpu              The CPU ID.
     4995 * Finds our (@a idCpu) entry, or allocates a new one if not found.
    49994996 *
    50004997 * @returns Index of the CPU in the cache set.
    5001  */
    5002 DECLINLINE(uint32_t) supdrvGipCpuIndexFromCpuId(PSUPGLOBALINFOPAGE pGip, RTCPUID idCpu)
    5003 {
    5004     uint32_t i = 0;
    5005 
    5006     /*
    5007      * Find our entry, or allocate one if not found.
     4998 * @param   pGip                The GIP.
     4999 * @param   idCpu               The CPU ID.
     5000 */
     5001static uint32_t supdrvGipCpuIndexFromCpuId(PSUPGLOBALINFOPAGE pGip, RTCPUID idCpu)
     5002{
     5003    uint32_t i, cTries;
     5004
     5005    /*
    50085006     * ASSUMES that CPU IDs are constant.
    50095007     */
    50105008    for (i = 0; i < pGip->cCpus; i++)
    50115009        if (pGip->aCPUs[i].idCpu == idCpu)
    5012             break;
    5013 
    5014     if (i >= pGip->cCpus)
     5010            return i;
     5011
     5012    cTries = 0;
     5013    do
     5014    {
    50155015        for (i = 0; i < pGip->cCpus; i++)
    50165016        {
     
    50185018            ASMAtomicCmpXchgSize(&pGip->aCPUs[i].idCpu, idCpu, NIL_RTCPUID, fRc);
    50195019            if (fRc)
    5020                 break;
    5021         }
    5022 
    5023     AssertRelease(i < pGip->cCpus);
    5024     return i;
     5020                return i;
     5021        }
     5022    } while (cTries++ < 32);
     5023    AssertReleaseFailed();
     5024    return i - 1;
    50255025}
    50265026
     
    50565056    }
    50575057
     5058    /*
     5059     * Update the entry.
     5060     */
    50585061    i = supdrvGipCpuIndexFromCpuId(pGip, idCpu);
    5059 
    5060     /*
    5061      * Update the entry.
    5062      */
    50635062    idApic = ASMGetApicId();
    50645063    ASMAtomicUoWriteU16(&pGip->aCPUs[i].idApic,  idApic);
     
    50725071    ASMAtomicWriteU16(&pGip->aiCpuFromCpuSetIdx[iCpuSet], i);
    50735072
     5073    /* commit it */
    50745074    ASMAtomicWriteSize(&pGip->aCPUs[i].enmState, SUPGIPCPUSTATE_ONLINE);
    50755075}
     
    50985098    Assert(RTCpuSetIsMemberByIndex(&pGip->PossibleCpuSet, iCpuSet));
    50995099    RTCpuSetDelByIndex(&pGip->OnlineCpuSet, iCpuSet);
     5100
     5101    /* commit it */
    51005102    ASMAtomicWriteSize(&pGip->aCPUs[i].enmState, SUPGIPCPUSTATE_OFFLINE);
    51015103}
     
    56405642                                  RTCPUID idCpu, uint8_t idApic, uint64_t iTick)
    56415643{
    5642     /*
    5643      * Avoid a potential race when a CPU online notification doesn't fire on the onlined CPU
    5644      * but the tick creeps in before the event notification is run.
    5645      */
    5646     unsigned iCpu = 0;
    5647     if (iTick == 1)
    5648     {
    5649         uint32_t i = supdrvGipCpuIndexFromCpuId(pGip, idCpu);
    5650         if (pGip->aCPUs[i].enmState == SUPGIPCPUSTATE_OFFLINE)
     5644    uint32_t iCpu;
     5645
     5646    /*
     5647     * Avoid a potential race when a CPU online notification doesn't fire on
     5648     * the onlined CPU but the tick creeps in before the event notification is
     5649     * run.
     5650     */
     5651    if (RT_UNLIKELY(iTick == 1))
     5652    {
     5653        iCpu = supdrvGipCpuIndexFromCpuId(pGip, idCpu);
     5654        if (pGip->aCPUs[iCpu].enmState == SUPGIPCPUSTATE_OFFLINE)
    56515655            supdrvGipMpEventOnline(pGip, idCpu);
    56525656    }
    56535657
    56545658    iCpu = pGip->aiCpuFromApicId[idApic];
    5655 
    56565659    if (RT_LIKELY(iCpu < pGip->cCpus))
    56575660    {
     
    56595662        if (pGipCpu->idCpu == idCpu)
    56605663        {
    5661 
    56625664            /*
    56635665             * Start update transaction.
     
    56835685    }
    56845686}
     5687
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