Changeset 44031 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Dec 4, 2012 12:19:12 PM (12 years ago)
- Location:
- trunk/src/VBox/Main/src-server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/Performance.cpp
r43994 r44031 705 705 void HostNetworkLoadRaw::collect() 706 706 { 707 uint64_t rx, tx; 708 707 uint64_t rx = mRxPrev; 708 uint64_t tx = mTxPrev; 709 710 if (RT_UNLIKELY(mSpeed * getPeriod() == 0)) 711 { 712 LogFlowThisFunc(("Check cable for %s! speed=%llu period=%d.\n", mShortName.c_str(), mSpeed, getPeriod())); 713 /* We do not collect host network metrics for unplugged interfaces! */ 714 return; 715 } 709 716 mRc = mHAL->getRawHostNetworkLoad(mShortName.c_str(), &rx, &tx); 710 717 if (RT_SUCCESS(mRc)) … … 713 720 uint64_t txDiff = tx - mTxPrev; 714 721 715 if (RT_UNLIKELY(mSpeed * getPeriod() == 0)) 716 { 717 LogFlowThisFunc(("Check cable for %s! speed=%llu period=%d.\n", mShortName.c_str(), mSpeed, getPeriod())); 718 /* We do not collect host network metrics for unplugged interfaces! 719 mRx->put(0); 720 mTx->put(0); 721 */ 722 } 723 else 724 { 725 mRx->put((ULONG)(PM_NETWORK_LOAD_MULTIPLIER * rxDiff / (mSpeed * getPeriod()))); 726 mTx->put((ULONG)(PM_NETWORK_LOAD_MULTIPLIER * txDiff / (mSpeed * getPeriod()))); 727 } 722 mRx->put((ULONG)(PM_NETWORK_LOAD_MULTIPLIER * rxDiff / (mSpeed * getPeriod()))); 723 mTx->put((ULONG)(PM_NETWORK_LOAD_MULTIPLIER * txDiff / (mSpeed * getPeriod()))); 728 724 729 725 mRxPrev = rx; -
trunk/src/VBox/Main/src-server/solaris/PerformanceSolaris.cpp
r43978 r44031 36 36 #include <iprt/param.h> 37 37 #include <iprt/path.h> 38 #include <VBox/log.h>38 #include "Logging.h" 39 39 #include "Performance.h" 40 40 … … 81 81 RTCString physToInstName(const char *pcszPhysName); 82 82 RTCString pathToInstName(const char *pcszDevPathName); 83 uint64_t wrapCorrection(uint32_t cur, uint64_t prev, const char *name); 84 uint64_t wrapDetection(uint64_t cur, uint64_t prev, const char *name); 83 85 84 86 kstat_ctl_t *mKC; … … 356 358 } 357 359 360 uint64_t CollectorSolaris::wrapCorrection(uint32_t cur, uint64_t prev, const char *name) 361 { 362 uint64_t corrected = (prev & 0xffffffff00000000) + cur; 363 if (cur < (prev & 0xffffffff)) 364 { 365 /* wrap has occurred */ 366 corrected += 0x100000000; 367 LogFlowThisFunc(("Corrected wrap on %s (%u < %u), returned %llu.\n", 368 name, cur, (uint32_t)prev, corrected)); 369 } 370 return corrected; 371 } 372 373 uint64_t CollectorSolaris::wrapDetection(uint64_t cur, uint64_t prev, const char *name) 374 { 375 static bool fNotSeen = true; 376 377 if (fNotSeen && cur < prev) 378 { 379 fNotSeen = false; 380 LogRel(("Detected wrap on %s (%llu < %llu).\n", name, cur, prev)); 381 } 382 return cur; 383 } 384 385 /* 386 * WARNING! This function expects the previous values of rx and tx counter to 387 * be passed in as well as returnes new values in the same parameters. This is 388 * needed to provide a workaround for 32-bit counter wrapping. 389 */ 358 390 int CollectorSolaris::getRawHostNetworkLoad(const char *name, uint64_t *rx, uint64_t *tx) 359 391 { 392 static bool g_fNotReported = true; 360 393 AssertReturn(strlen(name) < KSTAT_STRLEN, VERR_INVALID_PARAMETER); 361 394 LogFlowThisFunc(("m=%s i=%d n=%s\n", "link", -1, name)); … … 384 417 } 385 418 kstat_named_t *kn; 386 if ((kn = (kstat_named_t *)kstat_data_lookup(ksAdapter, (char *)"rbytes")) == 0) 387 { 388 LogRel(("kstat_data_lookup(rbytes) -> %d, name=%s\n", errno, name)); 389 return VERR_INTERNAL_ERROR; 390 } 391 *rx = kn->value.ul; 392 if ((kn = (kstat_named_t *)kstat_data_lookup(ksAdapter, (char *)"obytes")) == 0) 393 { 394 LogRel(("kstat_data_lookup(obytes) -> %d\n", errno)); 395 return VERR_INTERNAL_ERROR; 396 } 397 *tx = kn->value.ul; 419 if ((kn = (kstat_named_t *)kstat_data_lookup(ksAdapter, (char *)"rbytes64")) == 0) 420 { 421 if (g_fNotReported) 422 { 423 g_fNotReported = false; 424 LogRel(("Failed to locate rbytes64, falling back to 32-bit counters...\n")); 425 } 426 if ((kn = (kstat_named_t *)kstat_data_lookup(ksAdapter, (char *)"rbytes")) == 0) 427 { 428 LogRel(("kstat_data_lookup(rbytes) -> %d, name=%s\n", errno, name)); 429 return VERR_INTERNAL_ERROR; 430 } 431 *rx = wrapCorrection(kn->value.ul, *rx, "rbytes"); 432 } 433 else 434 *rx = wrapDetection(kn->value.ull, *rx, "rbytes64"); 435 if ((kn = (kstat_named_t *)kstat_data_lookup(ksAdapter, (char *)"obytes64")) == 0) 436 { 437 if (g_fNotReported) 438 { 439 g_fNotReported = false; 440 LogRel(("Failed to locate obytes64, falling back to 32-bit counters...\n")); 441 } 442 if ((kn = (kstat_named_t *)kstat_data_lookup(ksAdapter, (char *)"obytes")) == 0) 443 { 444 LogRel(("kstat_data_lookup(obytes) -> %d\n", errno)); 445 return VERR_INTERNAL_ERROR; 446 } 447 *tx = wrapCorrection(kn->value.ul, *tx, "obytes"); 448 } 449 else 450 *tx = wrapDetection(kn->value.ull, *tx, "obytes64"); 398 451 return VINF_SUCCESS; 399 452 } … … 490 543 uint64_t cbBlock = stats.f_frsize ? stats.f_frsize : stats.f_bsize; 491 544 *total = (ULONG)(getZfsTotal(cbBlock * stats.f_blocks, stats.f_basetype, path) / _MB); 492 Log Rel(("f_blocks=%llu.\n", stats.f_blocks));545 LogFlowThisFunc(("f_blocks=%llu.\n", stats.f_blocks)); 493 546 *used = (ULONG)(cbBlock * (stats.f_blocks - stats.f_bfree) / _MB); 494 547 *available = (ULONG)(cbBlock * stats.f_bavail / _MB); … … 505 558 strcpy(szName, name); 506 559 strcat(szName, ",err"); 507 kstat_t *ksDisk = kstat_lookup(mKC, "sderr", -1, szName);560 kstat_t *ksDisk = kstat_lookup(mKC, NULL, -1, szName); 508 561 if (ksDisk != 0) 509 562 { … … 524 577 } 525 578 } 579 else 580 { 581 LogRel(("kstat_lookup(%s) -> %d\n", szName, errno)); 582 rc = VERR_INTERNAL_ERROR; 583 } 584 526 585 527 586 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.