Changeset 56387 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Jun 12, 2015 1:32:01 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceStats.cpp
r56376 r56387 218 218 && cbReturned == cbStruct) 219 219 { 220 for (uint32_t i = 0; i < systemInfo.dwNumberOfProcessors ; i++)220 for (uint32_t i = 0; i < systemInfo.dwNumberOfProcessors && i < VMM_MAX_CPU_COUNT; i++) 221 221 { 222 222 if (gCtx.au64LastCpuLoad_Kernel[i] == 0) … … 252 252 } 253 253 } 254 RTMemFree(pProcInfo); 254 255 255 256 for (uint32_t i = 0; i < systemInfo.dwNumberOfProcessors; i++) 256 257 { 257 req.guestStats.u32CpuId = i; 258 259 rc = VbglR3StatReport(&req); 260 if (RT_SUCCESS(rc)) 261 VBoxServiceVerbose(3, "VBoxStatsReportStatistics: new statistics (CPU %u) reported successfully!\n", i); 258 if (i < VMM_MAX_CPU_COUNT) 259 { 260 req.guestStats.u32CpuId = i; 261 rc = VbglR3StatReport(&req); 262 if (RT_SUCCESS(rc)) 263 VBoxServiceVerbose(3, "VBoxStatsReportStatistics: new statistics (CPU %u) reported successfully!\n", i); 264 else 265 VBoxServiceVerbose(3, "VBoxStatsReportStatistics: DeviceIoControl (stats report) failed with %d\n", GetLastError()); 266 } 262 267 else 263 VBoxServiceVerbose(3, "VBoxStatsReportStatistics: DeviceIoControl (stats report) failed with %d\n", GetLastError()); 264 } 265 266 RTMemFree(pProcInfo); 268 VBoxServiceVerbose(3, "VBoxStatsReportStatistics: skipping information for CPU%u\n", u32CpuId); 269 } 267 270 268 271 #elif defined(RT_OS_LINUX) … … 532 535 break; 533 536 534 uint64_t u64Idle = StatCPU.cpu_sysinfo.cpu[CPU_IDLE]; 535 uint64_t u64User = StatCPU.cpu_sysinfo.cpu[CPU_USER]; 536 uint64_t u64System = StatCPU.cpu_sysinfo.cpu[CPU_KERNEL]; 537 538 uint64_t u64DeltaIdle = u64Idle - gCtx.au64LastCpuLoad_Idle[cCPUs]; 539 uint64_t u64DeltaSystem = u64System - gCtx.au64LastCpuLoad_Kernel[cCPUs]; 540 uint64_t u64DeltaUser = u64User - gCtx.au64LastCpuLoad_User[cCPUs]; 541 542 uint64_t u64DeltaAll = u64DeltaIdle + u64DeltaSystem + u64DeltaUser; 543 if (u64DeltaAll == 0) /* Prevent division through zero. */ 544 u64DeltaAll = 1; 545 546 gCtx.au64LastCpuLoad_Idle[cCPUs] = u64Idle; 547 gCtx.au64LastCpuLoad_Kernel[cCPUs] = u64System; 548 gCtx.au64LastCpuLoad_User[cCPUs] = u64User; 549 550 req.guestStats.u32CpuId = cCPUs; 551 req.guestStats.u32CpuLoad_Idle = (uint32_t)(u64DeltaIdle * 100 / u64DeltaAll); 552 req.guestStats.u32CpuLoad_Kernel = (uint32_t)(u64DeltaSystem * 100 / u64DeltaAll); 553 req.guestStats.u32CpuLoad_User = (uint32_t)(u64DeltaUser * 100 / u64DeltaAll); 554 555 req.guestStats.u32StatCaps |= VBOX_GUEST_STAT_CPU_LOAD_IDLE 556 | VBOX_GUEST_STAT_CPU_LOAD_KERNEL 557 | VBOX_GUEST_STAT_CPU_LOAD_USER; 558 fCpuInfoAvail = true; 559 560 rc = VbglR3StatReport(&req); 561 if (RT_SUCCESS(rc)) 562 VBoxServiceVerbose(3, "VBoxStatsReportStatistics: new statistics (CPU %u) reported successfully!\n", cCPUs); 537 if (cCPUs >= VMM_MAX_CPU_COUNT) 538 VBoxServiceVerbose(3, "VBoxStatsReportStatistics: skipping information for CPU%u\n", cCPUs); 563 539 else 564 VBoxServiceVerbose(3, "VBoxStatsReportStatistics: stats report failed with rc=%Rrc\n", rc); 565 cCPUs++; 540 { 541 uint64_t u64Idle = StatCPU.cpu_sysinfo.cpu[CPU_IDLE]; 542 uint64_t u64User = StatCPU.cpu_sysinfo.cpu[CPU_USER]; 543 uint64_t u64System = StatCPU.cpu_sysinfo.cpu[CPU_KERNEL]; 544 545 uint64_t u64DeltaIdle = u64Idle - gCtx.au64LastCpuLoad_Idle[cCPUs]; 546 uint64_t u64DeltaSystem = u64System - gCtx.au64LastCpuLoad_Kernel[cCPUs]; 547 uint64_t u64DeltaUser = u64User - gCtx.au64LastCpuLoad_User[cCPUs]; 548 549 uint64_t u64DeltaAll = u64DeltaIdle + u64DeltaSystem + u64DeltaUser; 550 if (u64DeltaAll == 0) /* Prevent division through zero. */ 551 u64DeltaAll = 1; 552 553 gCtx.au64LastCpuLoad_Idle[cCPUs] = u64Idle; 554 gCtx.au64LastCpuLoad_Kernel[cCPUs] = u64System; 555 gCtx.au64LastCpuLoad_User[cCPUs] = u64User; 556 557 req.guestStats.u32CpuId = cCPUs; 558 req.guestStats.u32CpuLoad_Idle = (uint32_t)(u64DeltaIdle * 100 / u64DeltaAll); 559 req.guestStats.u32CpuLoad_Kernel = (uint32_t)(u64DeltaSystem * 100 / u64DeltaAll); 560 req.guestStats.u32CpuLoad_User = (uint32_t)(u64DeltaUser * 100 / u64DeltaAll); 561 562 req.guestStats.u32StatCaps |= VBOX_GUEST_STAT_CPU_LOAD_IDLE 563 | VBOX_GUEST_STAT_CPU_LOAD_KERNEL 564 | VBOX_GUEST_STAT_CPU_LOAD_USER; 565 fCpuInfoAvail = true; 566 567 rc = VbglR3StatReport(&req); 568 if (RT_SUCCESS(rc)) 569 VBoxServiceVerbose(3, "VBoxStatsReportStatistics: new statistics (CPU %u) reported successfully!\n", cCPUs); 570 else 571 VBoxServiceVerbose(3, "VBoxStatsReportStatistics: stats report failed with rc=%Rrc\n", rc); 572 cCPUs++; 573 } 566 574 } 567 575 }
Note:
See TracChangeset
for help on using the changeset viewer.