VirtualBox

Changeset 10868 in vbox for trunk/src/VBox/Main/linux


Ignore:
Timestamp:
Jul 24, 2008 6:34:35 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
33686
Message:

PerfAPI: Windows collector re-worked to extract raw counters via WMI. Filtering for queries added. Security initialization is added to svcmain to access perf enumerators.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/linux/PerformanceLinux.cpp

    r10754 r10868  
    3737    virtual int getProcessMemoryUsage(RTPROCESS process, unsigned long *used);
    3838
    39     virtual int getRawHostCpuLoad(unsigned long *user, unsigned long *kernel, unsigned long *idle);
    40     virtual int getRawProcessCpuLoad(RTPROCESS process, unsigned long *user, unsigned long *kernel);
     39    virtual int getRawHostCpuLoad(uint64_t *user, uint64_t *kernel, uint64_t *idle);
     40    virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total);
    4141};
    4242
     
    4949}
    5050
    51 BaseMetric *MetricFactoryLinux::createHostCpuLoad(ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
    52 {
    53     Assert(mHAL);
    54     return new HostCpuLoadRaw(mHAL, object, user, kernel, idle);
    55 }
    56 
    57 BaseMetric *MetricFactoryLinux::createMachineCpuLoad(ComPtr<IUnknown> object, RTPROCESS process, SubMetric *user, SubMetric *kernel)
    58 {
    59     Assert(mHAL);
    60     return new MachineCpuLoadRaw(mHAL, object, process, user, kernel);
    61 }
    62 
    6351// Collector HAL for Linux
    6452
    65 int CollectorLinux::getRawHostCpuLoad(unsigned long *user, unsigned long *kernel, unsigned long *idle)
     53int CollectorLinux::getRawHostCpuLoad(uint64_t *user, uint64_t *kernel, uint64_t *idle)
    6654{
    6755    int rc = VINF_SUCCESS;
    68     unsigned long nice;
     56    unsigned long u32user, u32nice, u32kernel, u32idle;
    6957    FILE *f = fopen("/proc/stat", "r");
    7058
    7159    if (f)
    7260    {
    73         if (fscanf(f, "cpu %lu %lu %lu %lu", user, &nice, kernel, idle) == 4)
    74             *user += nice;
     61        if (fscanf(f, "cpu %lu %lu %lu %lu", &u32user, &u32nice, &u32kernel, &u32idle) == 4)
     62        {
     63            *user   = (uint64_t)u32user + u32nice;
     64            *kernel = u32kernel;
     65            *idle   = u32idle;
     66        }
    7567        else
    7668            rc = VERR_FILE_IO_ERROR;
     
    8375}
    8476
    85 int CollectorLinux::getRawProcessCpuLoad(RTPROCESS process, unsigned long *user, unsigned long *kernel)
     77int CollectorLinux::getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total)
    8678{
    8779    int rc = VINF_SUCCESS;
     
    9183    int iTmp;
    9284    unsigned uTmp;
    93     unsigned long ulTmp;
     85    unsigned long ulTmp, u32user, u32kernel;
    9486    char buf[80]; /* @todo: this should be tied to max allowed proc name. */
     87
     88    uint64_t uHostUser, uHostKernel, uHostIdle;
     89    rc = getRawHostCpuLoad(uHostUser, uHostKernel, uHostIdle);
     90    if (RT_FAILURE(rc))
     91        return rc;
     92    *total = (uint64_t)uHostUser + uHostKernel + uHostIdle;
    9593
    9694    RTStrAPrintf(&pszName, "/proc/%d/stat", process);
     
    103101        if (fscanf(f, "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu",
    104102                   &pid2, buf, &c, &iTmp, &iTmp, &iTmp, &iTmp, &iTmp, &uTmp,
    105                    &ulTmp, &ulTmp, &ulTmp, &ulTmp, user, kernel) == 15)
     103                   &ulTmp, &ulTmp, &ulTmp, &ulTmp, &u32user, &u32kernel) == 15)
    106104        {
    107105            Assert((pid_t)process == pid2);
     106            *user = u32user;
     107            *kernel = u32kernel;
    108108        }
    109109        else
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