Changeset 27930 in vbox
- Timestamp:
- Apr 1, 2010 11:07:21 AM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 7 edited
-
GuestImpl.cpp (modified) (1 diff)
-
Performance.cpp (modified) (9 diffs)
-
PerformanceImpl.cpp (modified) (4 diffs)
-
VMMDevInterface.cpp (modified) (1 diff)
-
include/Performance.h (modified) (15 diffs)
-
include/PerformanceImpl.h (modified) (1 diff)
-
testcase/tstCollector.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/GuestImpl.cpp
r27896 r27930 291 291 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 292 292 293 if (enmType > GUESTSTATTYPE_MAX)293 if (enmType >= GUESTSTATTYPE_MAX) 294 294 return E_INVALIDARG; 295 295 -
trunk/src/VBox/Main/Performance.cpp
r27885 r27930 135 135 if (ASMAtomicIncU32(&cEnabled) == 1) 136 136 { 137 #if 0138 137 ComPtr<IInternalSessionControl> directControl; 139 138 … … 142 141 return ret; 143 142 144 /* get the associated console */ 145 ComPtr<IConsole> console; 146 ret = directControl->COMGETTER(Console)(console.asOutParam())); 143 /* get the associated console; this is a remote call (!) */ 144 ret = directControl->GetRemoteConsole(mConsole.asOutParam()); 147 145 if (ret != S_OK) 148 146 return ret; 149 147 150 ComPtr<IGuest> guest; 151 ret = console->COMGETTER(Guest)(guest.asOutParam()); 148 ret = mConsole->COMGETTER(Guest)(mGuest.asOutParam()); 152 149 if (ret == S_OK) 153 { 154 } 155 #endif 150 mGuest->COMSETTER(StatisticsUpdateInterval)(1000 /* 1000 ms */); 156 151 } 157 152 return ret; … … 162 157 if (ASMAtomicDecU32(&cEnabled) == 0) 163 158 { 159 Assert(mGuest && mConsole); 160 mGuest->COMSETTER(StatisticsUpdateInterval)(0 /* off */); 164 161 } 165 162 return S_OK; 166 163 } 164 165 int CollectorGuestHAL::preCollect(const CollectorHints& hints, uint64_t iTick) 166 { 167 if ( mGuest 168 && iTick != mLastTick) 169 { 170 mGuest->InternalGetStatistics(0, &mCpuUser, &mCpuKernel, &mCpuIdle, 171 &mMemTotal, &mMemFree, &mMemBalloon, &mMemCache, 172 &mPageTotal, &mPageFree); 173 mLastTick = iTick; 174 } 175 return S_OK; 176 } 177 167 178 #endif /* VBOX_COLLECTOR_TEST_CASE */ 168 179 … … 209 220 } 210 221 211 void HostCpuLoadRaw::preCollect(CollectorHints& hints )222 void HostCpuLoadRaw::preCollect(CollectorHints& hints, uint64_t iTick) 212 223 { 213 224 hints.collectHostCpuLoad(); … … 273 284 } 274 285 275 void HostRamUsage::preCollect(CollectorHints& hints )286 void HostRamUsage::preCollect(CollectorHints& hints, uint64_t iTick) 276 287 { 277 288 hints.collectHostRamUsage(); … … 311 322 } 312 323 313 void MachineCpuLoadRaw::preCollect(CollectorHints& hints )324 void MachineCpuLoadRaw::preCollect(CollectorHints& hints, uint64_t iTick) 314 325 { 315 326 hints.collectProcessCpuLoad(mProcess); … … 348 359 } 349 360 350 void MachineRamUsage::preCollect(CollectorHints& hints )361 void MachineRamUsage::preCollect(CollectorHints& hints, uint64_t iTick) 351 362 { 352 363 hints.collectProcessRamUsage(mProcess); … … 372 383 } 373 384 374 void GuestCpuLoad::preCollect(CollectorHints& /* hints */) 375 { 385 void GuestCpuLoad::preCollect(CollectorHints& hints, uint64_t iTick) 386 { 387 mHAL->preCollect(hints, iTick); 376 388 } 377 389 378 390 void GuestCpuLoad::collect() 379 391 { 380 #if 0 381 uint64_t processUser, processKernel, hostTotal; 382 383 int rc = mHAL->getRawProcessCpuLoad(mProcess, &processUser, &processKernel, &hostTotal); 384 if (RT_SUCCESS(rc)) 385 { 386 if (hostTotal == mHostTotalPrev) 387 { 388 /* Nearly impossible, but... */ 389 mUser->put(0); 390 mKernel->put(0); 391 } 392 else 393 { 394 mUser->put((ULONG)(PM_CPU_LOAD_MULTIPLIER * (processUser - mProcessUserPrev) / (hostTotal - mHostTotalPrev))); 395 mKernel->put((ULONG)(PM_CPU_LOAD_MULTIPLIER * (processKernel - mProcessKernelPrev ) / (hostTotal - mHostTotalPrev))); 396 } 397 398 mHostTotalPrev = hostTotal; 399 mProcessUserPrev = processUser; 400 mProcessKernelPrev = processKernel; 401 } 402 #endif 392 ULONG CpuUser = 0, CpuKernel = 0, CpuIdle = 0; 393 394 mGuestHAL->getGuestCpuLoad(&CpuUser, &CpuKernel, &CpuIdle); 395 mUser->put((ULONG)(PM_CPU_LOAD_MULTIPLIER * CpuUser) / 100); 396 mKernel->put((ULONG)(PM_CPU_LOAD_MULTIPLIER * CpuKernel) / 100); 397 mIdle->put((ULONG)(PM_CPU_LOAD_MULTIPLIER * CpuIdle) / 100); 403 398 } 404 399 … … 416 411 } 417 412 418 void GuestRamUsage::preCollect(CollectorHints& /* hints */) 419 { 413 void GuestRamUsage::preCollect(CollectorHints& hints, uint64_t iTick) 414 { 415 mHAL->preCollect(hints, iTick); 420 416 } 421 417 422 418 void GuestRamUsage::collect() 423 419 { 424 #if 0 425 ULONG used; 426 int rc = mHAL->getProcessMemoryUsage(mProcess, &used); 427 if (RT_SUCCESS(rc)) 428 mUsed->put(used); 429 #endif 420 ULONG ulMemTotal = 0, ulMemFree = 0, ulMemBalloon = 0, ulMemCache = 0, ulPageTotal = 0, ulPageFree = 0; 421 422 mGuestHAL->getGuestMemLoad(&ulMemTotal, &ulMemFree, &ulMemBalloon, &ulMemCache, &ulPageTotal, &ulPageFree); 423 mTotal->put(ulMemTotal); 424 mFree->put(ulMemFree); 425 mBallooned->put(ulMemBalloon); 426 mCache->put(ulMemCache); 427 mPagedTotal->put(ulPageTotal); 428 mPagedFree->put(ulPageFree); 430 429 } 431 430 -
trunk/src/VBox/Main/PerformanceImpl.cpp
r27885 r27930 564 564 /* static */ 565 565 void PerformanceCollector::staticSamplerCallback(RTTIMERLR hTimerLR, void *pvUser, 566 uint64_t /* iTick */)566 uint64_t iTick) 567 567 { 568 568 AssertReturnVoid (pvUser != NULL); … … 570 570 Assert(collector->mMagic == MAGIC); 571 571 if (collector->mMagic == MAGIC) 572 { 573 collector->samplerCallback(); 574 } 572 collector->samplerCallback(iTick); 573 575 574 NOREF (hTimerLR); 576 575 } 577 576 578 void PerformanceCollector::samplerCallback( )577 void PerformanceCollector::samplerCallback(uint64_t iTick) 579 578 { 580 579 Log4(("{%p} " LOG_FN_FMT ": ENTER\n", this, __PRETTY_FUNCTION__)); … … 589 588 if ((*it)->collectorBeat(timestamp)) 590 589 { 591 (*it)->preCollect(hints );590 (*it)->preCollect(hints, iTick); 592 591 toBeCollected.push_back(*it); 593 592 } … … 597 596 598 597 /* Let know the platform specific code what is being collected */ 599 m.hal->preCollect(hints );598 m.hal->preCollect(hints, iTick); 600 599 601 600 /* Finally, collect the data */ -
trunk/src/VBox/Main/VMMDevInterface.cpp
r27896 r27930 468 468 469 469 470 /* Note that reported values are in pages; upper layers expect them in megabytes */471 Assert(pGuestStats->u32PageSize == 4096);472 if (pGuestStats->u32PageSize != 4096)473 pGuestStats->u32PageSize = 4096;474 475 470 if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_TOTAL) 476 guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMTOTAL, (pGuestStats->u32PhysMemTotal + (_1M/pGuestStats->u32PageSize)-1) / (_1M/pGuestStats->u32PageSize));471 guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMTOTAL, pGuestStats->u32PhysMemTotal); 477 472 478 473 if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_AVAIL) 479 guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMFREE, pGuestStats->u32PhysMemAvail / (_1M/pGuestStats->u32PageSize));474 guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMFREE, pGuestStats->u32PhysMemAvail); 480 475 481 476 if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_BALLOON) 482 guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMBALLOON, pGuestStats->u32PhysMemBalloon / (_1M/pGuestStats->u32PageSize));477 guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMBALLOON, pGuestStats->u32PhysMemBalloon); 483 478 484 479 if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_SYSTEM_CACHE) 485 guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMCACHE, pGuestStats->u32MemSystemCache / (_1M/pGuestStats->u32PageSize));480 guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMCACHE, pGuestStats->u32MemSystemCache); 486 481 487 482 if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PAGE_FILE_SIZE) 488 guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_PAGETOTAL, pGuestStats->u32PageFileSize / (_1M/pGuestStats->u32PageSize));483 guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_PAGETOTAL, pGuestStats->u32PageFileSize); 489 484 490 485 return VINF_SUCCESS; -
trunk/src/VBox/Main/include/Performance.h
r27885 r27930 27 27 #include <VBox/com/ptr.h> 28 28 #include <VBox/com/string.h> 29 #include <VBox/com/VirtualBox.h> 29 30 30 31 #include <iprt/types.h> … … 139 140 public: 140 141 virtual ~CollectorHAL() { }; 141 virtual int preCollect(const CollectorHints& /* hints */ ) { return VINF_SUCCESS; }142 virtual int preCollect(const CollectorHints& /* hints */, uint64_t iTick) { return VINF_SUCCESS; } 142 143 /** Returns averaged CPU usage in 1/1000th per cent across all host's CPUs. */ 143 144 virtual int getHostCpuLoad(ULONG *user, ULONG *kernel, ULONG *idle); … … 165 166 { 166 167 public: 167 CollectorGuestHAL(Machine *machine) : cEnabled(0), mMachine(machine) {}; 168 CollectorGuestHAL(Machine *machine) : cEnabled(0), mMachine(machine), mConsole(NULL), mGuest(NULL), mLastTick(0), 169 mCpuUser(0), mCpuKernel(0), mCpuIdle(0), mMemTotal(0), mMemFree(0), mMemBalloon(0), 170 mMemCache(0), mPageTotal(0), mPageFree(0) {}; 168 171 ~CollectorGuestHAL(); 172 173 virtual int preCollect(const CollectorHints& hints, uint64_t iTick); 169 174 170 175 /** Enable metrics collecting (if applicable) */ … … 172 177 /** Disable metrics collecting (if applicable) */ 173 178 virtual int disable(); 179 180 /** Return guest cpu absolute load values (0-100). */ 181 void getGuestCpuLoad(ULONG *pulCpuUser, ULONG *pulCpuKernel, ULONG *pulCpuIdle) 182 { 183 *pulCpuUser = mCpuUser; 184 *pulCpuKernel = mCpuKernel; 185 *pulCpuIdle = mCpuIdle; 186 } 187 188 /** Return guest memory information in kb. */ 189 void getGuestMemLoad(ULONG *pulMemTotal, ULONG *pulMemFree, ULONG *pulMemBalloon, ULONG *pulMemCache, ULONG *pulPageTotal, ULONG *pulPageFree) 190 { 191 *pulMemTotal = mMemTotal; 192 *pulMemFree = mMemFree; 193 *pulMemBalloon = mMemBalloon; 194 *pulMemCache = mMemCache; 195 *pulPageTotal = mPageTotal; 196 *pulPageFree = mPageFree; 197 } 198 199 174 200 protected: 175 uint32_t cEnabled; 176 Machine *mMachine; 201 uint32_t cEnabled; 202 Machine *mMachine; 203 ComPtr<IConsole> mConsole; 204 ComPtr<IGuest> mGuest; 205 uint64_t mLastTick; 206 207 ULONG mCpuUser; 208 ULONG mCpuKernel; 209 ULONG mCpuIdle; 210 ULONG mMemTotal; 211 ULONG mMemFree; 212 ULONG mMemBalloon; 213 ULONG mMemCache; 214 ULONG mPageTotal; 215 ULONG mPageFree; 177 216 }; 178 217 … … 188 227 189 228 virtual void init(ULONG period, ULONG length) = 0; 190 virtual void preCollect(CollectorHints& hints ) = 0;229 virtual void preCollect(CollectorHints& hints, uint64_t iTick) = 0; 191 230 virtual void collect() = 0; 192 231 virtual const char *getUnit() = 0; … … 216 255 217 256 protected: 257 ULONG mPeriod; 258 ULONG mLength; 218 259 CollectorHAL *mHAL; 219 ULONG mPeriod;220 ULONG mLength;221 260 const char *mName; 222 261 ComPtr<IUnknown> mObject; … … 252 291 : HostCpuLoad(hal, object, user, kernel, idle), mUserPrev(0), mKernelPrev(0), mIdlePrev(0) {}; 253 292 254 void preCollect(CollectorHints& hints );293 void preCollect(CollectorHints& hints, uint64_t iTick); 255 294 void collect(); 256 295 private: … … 268 307 269 308 void init(ULONG period, ULONG length); 270 void preCollect(CollectorHints& /* hints */ ) {}309 void preCollect(CollectorHints& /* hints */, uint64_t /* iTick */) {} 271 310 void collect(); 272 311 const char *getUnit() { return "MHz"; }; … … 286 325 287 326 void init(ULONG period, ULONG length); 288 void preCollect(CollectorHints& hints );327 void preCollect(CollectorHints& hints, uint64_t iTick); 289 328 void collect(); 290 329 const char *getUnit() { return "kB"; }; … … 323 362 : MachineCpuLoad(hal, object, process, user, kernel), mHostTotalPrev(0), mProcessUserPrev(0), mProcessKernelPrev(0) {}; 324 363 325 void preCollect(CollectorHints& hints );364 void preCollect(CollectorHints& hints, uint64_t iTick); 326 365 void collect(); 327 366 private: … … 339 378 340 379 void init(ULONG period, ULONG length); 341 void preCollect(CollectorHints& hints );380 void preCollect(CollectorHints& hints, uint64_t iTick); 342 381 void collect(); 343 382 const char *getUnit() { return "kB"; }; … … 355 394 public: 356 395 GuestCpuLoad(CollectorGuestHAL *hal, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle) 357 : BaseMetric(hal, "CPU/Load", object), mUser(user), mKernel(kernel), mIdle(idle) {};396 : BaseMetric(hal, "CPU/Load", object), mUser(user), mKernel(kernel), mIdle(idle), mGuestHAL(hal) {}; 358 397 ~GuestCpuLoad() { delete mUser; delete mKernel; delete mIdle; }; 359 398 360 399 void init(ULONG period, ULONG length); 361 void preCollect(CollectorHints& hints );400 void preCollect(CollectorHints& hints, uint64_t iTick); 362 401 void collect(); 363 402 const char *getUnit() { return "%"; }; … … 369 408 SubMetric *mKernel; 370 409 SubMetric *mIdle; 410 CollectorGuestHAL *mGuestHAL; 371 411 }; 372 412 … … 375 415 public: 376 416 GuestRamUsage(CollectorGuestHAL *hal, ComPtr<IUnknown> object, SubMetric *total, SubMetric *free, SubMetric *balloon, SubMetric *cache, SubMetric *pagedtotal, SubMetric *pagedfree) 377 : BaseMetric(hal, "RAM/Usage", object), mTotal(total), mFree(free), mBallooned(balloon), mCache(cache), mPagedTotal(pagedtotal), mPagedFree(pagedfree) {};417 : BaseMetric(hal, "RAM/Usage", object), mTotal(total), mFree(free), mBallooned(balloon), mCache(cache), mPagedTotal(pagedtotal), mPagedFree(pagedfree), mGuestHAL(hal) {}; 378 418 ~GuestRamUsage() { delete mTotal; delete mFree; delete mBallooned; delete mCache; delete mPagedTotal; delete mPagedFree; }; 379 419 380 420 void init(ULONG period, ULONG length); 381 void preCollect(CollectorHints& hints );421 void preCollect(CollectorHints& hints, uint64_t iTick); 382 422 void collect(); 383 423 const char *getUnit() { return "kB"; }; … … 387 427 private: 388 428 SubMetric *mTotal, *mFree, *mBallooned, *mCache, *mPagedTotal, *mPagedFree; 429 CollectorGuestHAL *mGuestHAL; 389 430 }; 390 431 -
trunk/src/VBox/Main/include/PerformanceImpl.h
r26044 r27930 200 200 201 201 static void staticSamplerCallback (RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick); 202 void samplerCallback( );202 void samplerCallback(uint64_t iTick); 203 203 204 204 typedef std::list<pm::Metric*> MetricList; -
trunk/src/VBox/Main/testcase/tstCollector.cpp
r16018 r27930 110 110 unsigned int nCalls; 111 111 /* Pre-collect */ 112 CALLS_PER_SECOND(preCollect(hints ));112 CALLS_PER_SECOND(preCollect(hints, 0)); 113 113 /* Host CPU load */ 114 114 CALLS_PER_SECOND(getRawHostCpuLoad(&tmp64, &tmp64, &tmp64)); … … 128 128 { 129 129 /* Pre-collect */ 130 N_CALLS(1, preCollect(hints ));130 N_CALLS(1, preCollect(hints, 0)); 131 131 /* Host CPU load */ 132 132 N_CALLS(1, getRawHostCpuLoad(&tmp64, &tmp64, &tmp64)); … … 202 202 RTPrintf("tstCollector: TESTING - CPU load, sleeping for 5 sec\n"); 203 203 204 rc = collector->preCollect(hints );204 rc = collector->preCollect(hints, 0); 205 205 if (RT_FAILURE(rc)) 206 206 { … … 223 223 RTThreadSleep(5000); // Sleep for 5 seconds 224 224 225 rc = collector->preCollect(hints );225 rc = collector->preCollect(hints, 0); 226 226 if (RT_FAILURE(rc)) 227 227 { … … 255 255 256 256 RTPrintf("tstCollector: TESTING - CPU load, looping for 5 sec\n"); 257 rc = collector->preCollect(hints );257 rc = collector->preCollect(hints, 0); 258 258 if (RT_FAILURE(rc)) 259 259 { … … 276 276 while(RTTimeMilliTS() - start < 5000) 277 277 ; // Loop for 5 seconds 278 rc = collector->preCollect(hints );278 rc = collector->preCollect(hints, 0); 279 279 if (RT_FAILURE(rc)) 280 280 {
Note:
See TracChangeset
for help on using the changeset viewer.

