VirtualBox

Changeset 50059 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jan 13, 2014 9:10:18 AM (11 years ago)
Author:
vboxsync
Message:

Runtime/r3/linux: when determining the number of physical cores, also consider the physical package ID of each core

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/linux/mp-linux.cpp

    r48935 r50059  
    185185    RTCPUID     cMax      = rtMpLinuxMaxCpus();
    186186    uint32_t   *paidCores = (uint32_t *)alloca(sizeof(paidCores[0]) * (cMax + 1));
     187    uint32_t   *paidPckgs = (uint32_t *)alloca(sizeof(paidPckgs[0]) * (cMax + 1));
    187188    uint32_t    cCores    = 0;
    188189    for (RTCPUID idCpu = 0; idCpu < cMax; idCpu++)
     
    191192        {
    192193            uint32_t idCore = (uint32_t)RTLinuxSysFsReadIntFile(0, "devices/system/cpu/cpu%d/topology/core_id", (int)idCpu);
     194            uint32_t idPckg = (uint32_t)RTLinuxSysFsReadIntFile(0, "devices/system/cpu/cpu%d/topology/physical_package_id", (int)idCpu);
    193195            uint32_t i;
    194196            for (i = 0; i < cCores; i++)
    195                 if (paidCores[i] == idCore)
     197                if (   paidCores[i] == idCore
     198                    && paidPckgs[i] == idPckg)
    196199                    break;
    197200            if (i >= cCores)
    198                 paidCores[cCores++] = idCore;
     201            {
     202                paidCores[cCores] = idCore;
     203                paidPckgs[cCores] = idPckg;
     204                cCores++;
     205            }
    199206        }
    200207    }
     
    227234    RTCPUID     cMax      = rtMpLinuxMaxCpus();
    228235    uint32_t   *paidCores = (uint32_t *)alloca(sizeof(paidCores[0]) * (cMax + 1));
     236    uint32_t   *paidPckgs = (uint32_t *)alloca(sizeof(paidPckgs[0]) * (cMax + 1));
    229237    uint32_t    cCores    = 0;
    230238    for (RTCPUID idCpu = 0; idCpu < cMax; idCpu++)
     
    233241        {
    234242            uint32_t idCore = (uint32_t)RTLinuxSysFsReadIntFile(0, "devices/system/cpu/cpu%d/topology/core_id", (int)idCpu);
     243            uint32_t idPckg = (uint32_t)RTLinuxSysFsReadIntFile(0, "devices/system/cpu/cpu%d/topology/physical_package_id", (int)idCpu);
    235244            uint32_t i;
    236245            for (i = 0; i < cCores; i++)
    237                 if (paidCores[i] == idCore)
     246                if (   paidCores[i] == idCore
     247                    && paidPckgs[i] == idPckg)
    238248                    break;
    239249            if (i >= cCores)
    240                 paidCores[cCores++] = idCore;
     250            {
     251                paidCores[cCores] = idCore;
     252                paidPckgs[cCores] = idPckg;
     253                cCores++;
     254            }
    241255        }
    242256    }
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