VirtualBox

Changeset 44466 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jan 30, 2013 2:16:31 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
83474
Message:

Main/Metrics: Per-VM CPU load on Darwin brought in line with other platforms (#6345)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/darwin/PerformanceDarwin.cpp

    r43836 r44466  
    2525#include <iprt/err.h>
    2626#include <iprt/log.h>
     27#include <iprt/mp.h>
    2728#include <iprt/param.h>
    2829#include <iprt/system.h>
     
    9899    }
    99100
    100     *user = (uint64_t)info.cpu_ticks[CPU_STATE_USER]
    101                     + info.cpu_ticks[CPU_STATE_NICE];
    102     *kernel = (uint64_t)info.cpu_ticks[CPU_STATE_SYSTEM];
    103     *idle = (uint64_t)info.cpu_ticks[CPU_STATE_IDLE];
     101    int nCpus = RTMpGetOnlineCount();
     102    Assert(nCpus);
     103    if (nCpus)
     104    {
     105        *user = ((uint64_t)info.cpu_ticks[CPU_STATE_USER]
     106                 + info.cpu_ticks[CPU_STATE_NICE]) / nCpus;
     107        *kernel = ((uint64_t)info.cpu_ticks[CPU_STATE_SYSTEM]) / nCpus;
     108        *idle = ((uint64_t)info.cpu_ticks[CPU_STATE_IDLE]) / nCpus;
     109    }
     110    else
     111    {
     112        /* It is rather unsual to have no CPUs, but the show must go on. */
     113        *user = (uint64_t)info.cpu_ticks[CPU_STATE_USER]
     114            + info.cpu_ticks[CPU_STATE_NICE];
     115        *kernel = (uint64_t)info.cpu_ticks[CPU_STATE_SYSTEM];
     116        *idle = (uint64_t)info.cpu_ticks[CPU_STATE_IDLE];
     117    }
     118
    104119    return VINF_SUCCESS;
    105120}
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