VirtualBox

Changeset 22347 in vbox for trunk/src


Ignore:
Timestamp:
Aug 19, 2009 2:02:05 PM (15 years ago)
Author:
vboxsync
Message:

Solaris/mpnotification: Cache CPU set to avoid recursive calls to vbi_cpu_online.

Location:
trunk/src/VBox/Runtime/r0drv/solaris/vbi
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/mp-r0drv-solaris.c

    r22073 r22347  
    3838
    3939#include <iprt/asm.h>
    40 #include <iprt/cpuset.h>
    4140#include <iprt/err.h>
     41#include "internal-r0drv-solaris.h"
    4242#include "r0drv/mp-r0drv.h"
    4343
     
    7676RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
    7777{
     78    /*
     79     * We cannot query CPU status recursively, check cpu member from cached set.
     80     */
     81    if (idCpu >= vbi_cpu_count())
     82        return false;
     83
     84    return RTCpuSetIsMember(&g_rtMpSolarisCpuSet, idCpu);
     85
     86#if 0
    7887    return idCpu < vbi_cpu_count() && vbi_cpu_online(idCpu);
     88#endif
    7989}
    8090
     
    110120RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
    111121{
     122    /*
     123     * We cannot query CPU status recursively, return the cached set.
     124     */
     125    *pSet = g_rtMpSolarisCpuSet;
     126    return pSet;
     127
     128#if 0
    112129    RTCPUID idCpu;
    113130
     
    121138
    122139    return pSet;
     140#endif
    123141}
    124142
     
    126144RTDECL(RTCPUID) RTMpGetOnlineCount(void)
    127145{
     146    RTCPUSET Set;
     147    RTMpGetOnlineSet(&Set);
     148    return RTCpuSetCount(&Set);
     149
     150#if 0
    128151    int c;
    129152    int cnt = 0;
     
    135158    }
    136159    return cnt;
     160#endif
    137161}
    138162
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/mpnotification-r0drv-solaris.c

    r22073 r22347  
    3838#include <iprt/mp.h>
    3939#include "r0drv/mp-r0drv.h"
     40#include "internal-r0drv-solaris.h"
    4041
    4142
     
    4546static vbi_cpu_watch_t *g_hVbiCpuWatch = NULL;
    4647
     48RTCPUSET g_rtMpSolarisCpuSet;
    4749
    4850static void rtMpNotificationSolarisCallback(void *pvUser, int iCpu, int online)
     
    5254    /* ASSUMES iCpu == RTCPUID */
    5355    if (online)
     56    {
     57        RTCpuSetAdd(&g_rtMpSolarisCpuSet, iCpu);
    5458        rtMpNotificationDoCallbacks(RTMPEVENT_ONLINE, iCpu);
     59    }
    5560    else
     61    {
     62        RTCpuSetDel(&g_rtMpSolarisCpuSet, iCpu);
    5663        rtMpNotificationDoCallbacks(RTMPEVENT_OFFLINE, iCpu);
     64    }
    5765}
    5866
     
    6472    if (g_hVbiCpuWatch != NULL)
    6573        return VERR_WRONG_ORDER;
     74
     75    /*
     76     * Cache the list of online CPUs.
     77     */
     78    RTCpuSetEmpty(&g_rtMpSolarisCpuSet);
     79
    6680    g_hVbiCpuWatch = vbi_watch_cpus(rtMpNotificationSolarisCallback, NULL, 0);
     81
     82    RTCPUID idCpu = RTMpGetMaxCpuId();
     83    do
     84    {
     85        /** @todo vbi_cpu_online() should do boundary check "idCpu" rather than hang the system. */
     86        if (   RTMpIsCpuPossible(idCpu)
     87            && vbi_cpu_online(idCpu))
     88        {
     89            RTCpuSetAdd(&g_rtMpSolarisCpuSet, idCpu);
     90        }
     91    } while (idCpu-- > 0);
     92
    6793    return VINF_SUCCESS;
    6894}
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