VirtualBox

Changeset 31356 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Aug 4, 2010 12:59:29 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
64405
Message:

Search first by host cpu id (most common case) and then by native thread id (page fusion case).

File:
1 edited

Legend:

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

    r31353 r31356  
    2727#include <VBox/param.h>
    2828#include <iprt/thread.h>
     29#include <iprt/mp.h>
    2930
    3031
     
    5960    if (pVM->cCpus == 1)
    6061        return 0;
     62
     63    /* Search first by host cpu id (most common case)
     64     * and then by native thread id (page fusion case).
     65     */
     66    /* RTMpCpuId had better be cheap. */
     67    RTCPUID idHostCpu = RTMpCpuId();
     68
     69    /** @todo optimize for large number of VCPUs when that becomes more common. */
     70    for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
     71    {
     72        PVMCPU pVCpu = &pVM->aCpus[idCpu];
     73
     74        if (pVCpu->idHostCpu == idHostCpu)
     75            return pVCpu->idCpu;
     76    }
    6177
    6278    /* RTThreadGetNativeSelf had better be cheap. */
     
    99115        return &pVM->aCpus[0];
    100116
     117    /* Search first by host cpu id (most common case)
     118     * and then by native thread id (page fusion case).
     119     */
     120
     121    /* RTMpCpuId had better be cheap. */
     122    RTCPUID idHostCpu = RTMpCpuId();
     123
     124    /** @todo optimize for large number of VCPUs when that becomes more common. */
     125    for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
     126    {
     127        PVMCPU pVCpu = &pVM->aCpus[idCpu];
     128
     129        if (pVCpu->idHostCpu == idHostCpu)
     130            return pVCpu;
     131    }
     132
    101133    /* RTThreadGetNativeSelf had better be cheap. */
    102134    RTNATIVETHREAD hThread = RTThreadNativeSelf();
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