VirtualBox

Changeset 94087 in vbox for trunk/src/VBox/Runtime/r3/darwin


Ignore:
Timestamp:
Mar 4, 2022 2:03:32 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
150332
Message:

IPRT/mp/darwin: Reimplemented RTMpGetOnlineSet to avoid getting the same information over and over again for each CPU. Updated comment in RTMpGetCurFrequency explaining how seemingly difficult it would be to implement. Updated todo in RTMpGetDescription. bugref:9898

Location:
trunk/src/VBox/Runtime/r3/darwin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/darwin/RTMpGetDescription-generic.cpp

    r93115 r94087  
    5050     * Just use the sysctl machdep.cpu.brand_string value for now.
    5151     */
    52     /** @todo on arm this is very boring, so we could use the cpufamily and
    53      *        cpusubfamily instead... */
     52    /** @todo on arm this is very boring and there are two different types of
     53     *        cores in the system, "E" and "P" cores. The I/O registry can
     54     *        be used to find out which @a idCpu is.  There are also codename
     55     *        available there. */
    5456    char szBrand[128] = {0};
    5557    size_t cb = sizeof(szBrand);
  • trunk/src/VBox/Runtime/r3/darwin/mp-darwin.cpp

    r93115 r94087  
    5454
    5555#include <iprt/mp.h>
     56#include <iprt/assert.h>
    5657#include <iprt/cpuset.h>
    57 #include <iprt/assert.h>
    5858#include <iprt/log.h>
    5959#include <iprt/string.h>
     
    174174#else
    175175    /** @todo proper ring-3 support on darwin, see @bugref{3014}. */
    176     natural_t nCpus;
    177     processor_basic_info_t pinfo;
    178     mach_msg_type_number_t count;
    179     kern_return_t krc = host_processor_info(mach_host_self(),
    180         PROCESSOR_BASIC_INFO, &nCpus, (processor_info_array_t*)&pinfo, &count);
    181     AssertReturn (krc == KERN_SUCCESS, true);
    182     bool isOnline = idCpu < nCpus ? pinfo[idCpu].running : false;
    183     vm_deallocate(mach_task_self(), (vm_address_t)pinfo, count * sizeof(*pinfo));
    184     return isOnline;
     176    natural_t              cCpus;
     177    processor_basic_info_t paInfo;
     178    mach_msg_type_number_t cInfo;
     179    kern_return_t krc = host_processor_info(mach_host_self(), PROCESSOR_BASIC_INFO,
     180                                            &cCpus, (processor_info_array_t*)&paInfo, &cInfo);
     181    AssertReturn(krc == KERN_SUCCESS, true);
     182    bool const fIsOnline = idCpu < cCpus ? paInfo[idCpu].running : false;
     183    vm_deallocate(mach_task_self(), (vm_address_t)paInfo, cInfo * sizeof(paInfo[0]));
     184    return fIsOnline;
    185185#endif
    186186}
     
    225225RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
    226226{
     227    RTCpuSetEmpty(pSet);
    227228#if 0
    228     return RTMpGetSet(pSet);
    229 #else
    230     RTCpuSetEmpty(pSet);
    231229    RTCPUID cMax = rtMpDarwinMaxLogicalCpus();
    232230    for (RTCPUID idCpu = 0; idCpu < cMax; idCpu++)
    233231        if (RTMpIsCpuOnline(idCpu))
    234232            RTCpuSetAdd(pSet, idCpu);
     233#else
     234    natural_t              cCpus  = 0;
     235    processor_basic_info_t paInfo = NULL;
     236    mach_msg_type_number_t cInfo  = 0;
     237    kern_return_t krc = host_processor_info(mach_host_self(), PROCESSOR_BASIC_INFO,
     238                                            &cCpus, (processor_info_array_t *)&paInfo, &cInfo);
     239    AssertReturn(krc == KERN_SUCCESS, pSet);
     240
     241    AssertStmt(cCpus <= RTCPUSET_MAX_CPUS, cCpus = RTCPUSET_MAX_CPUS);
     242    for (natural_t idCpu = 0; idCpu < cCpus; idCpu++)
     243        if (paInfo[idCpu].running)
     244            RTCpuSetAdd(pSet, idCpu);
     245
     246    vm_deallocate(mach_task_self(), (vm_address_t)paInfo, cInfo * sizeof(paInfo[0]));
     247#endif
    235248    return pSet;
    236 #endif
    237249}
    238250
     
    254266RTDECL(uint32_t) RTMpGetCurFrequency(RTCPUID idCpu)
    255267{
    256     /** @todo figure out how to get the current cpu speed on darwin. Have to check what powermanagement does. */
     268    /** @todo figure out how to get the current cpu speed on darwin. Have to
     269     *  check what powermanagement does.  The powermetrics uses a private
     270     *  IOReportXxxx interface and *seems* (guessing) to calculate the frequency
     271     *  based on the frequency distribution over the last report period...  This
     272     *  means that it's not really an suitable API for here.  */
    257273    NOREF(idCpu);
    258274    return 0;
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