VirtualBox

Changeset 44031 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Dec 4, 2012 12:19:12 PM (12 years ago)
Author:
vboxsync
Message:

Main/Metrics: Network counter wrap and non-sd disk fixes for Solaris (#6345)

Location:
trunk/src/VBox/Main/src-server
Files:
2 edited

Legend:

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

    r43994 r44031  
    705705void HostNetworkLoadRaw::collect()
    706706{
    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    }
    709716    mRc = mHAL->getRawHostNetworkLoad(mShortName.c_str(), &rx, &tx);
    710717    if (RT_SUCCESS(mRc))
     
    713720        uint64_t txDiff = tx - mTxPrev;
    714721
    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())));
    728724
    729725        mRxPrev = rx;
  • trunk/src/VBox/Main/src-server/solaris/PerformanceSolaris.cpp

    r43978 r44031  
    3636#include <iprt/param.h>
    3737#include <iprt/path.h>
    38 #include <VBox/log.h>
     38#include "Logging.h"
    3939#include "Performance.h"
    4040
     
    8181    RTCString physToInstName(const char *pcszPhysName);
    8282    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);
    8385
    8486    kstat_ctl_t *mKC;
     
    356358}
    357359
     360uint64_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
     373uint64_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 */
    358390int CollectorSolaris::getRawHostNetworkLoad(const char *name, uint64_t *rx, uint64_t *tx)
    359391{
     392    static bool g_fNotReported = true;
    360393    AssertReturn(strlen(name) < KSTAT_STRLEN, VERR_INVALID_PARAMETER);
    361394    LogFlowThisFunc(("m=%s i=%d n=%s\n", "link", -1, name));
     
    384417    }
    385418    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");
    398451    return VINF_SUCCESS;
    399452}
     
    490543    uint64_t cbBlock = stats.f_frsize ? stats.f_frsize : stats.f_bsize;
    491544    *total = (ULONG)(getZfsTotal(cbBlock * stats.f_blocks, stats.f_basetype, path) / _MB);
    492     LogRel(("f_blocks=%llu.\n", stats.f_blocks));
     545    LogFlowThisFunc(("f_blocks=%llu.\n", stats.f_blocks));
    493546    *used  = (ULONG)(cbBlock * (stats.f_blocks - stats.f_bfree) / _MB);
    494547    *available = (ULONG)(cbBlock * stats.f_bavail / _MB);
     
    505558    strcpy(szName, name);
    506559    strcat(szName, ",err");
    507     kstat_t *ksDisk = kstat_lookup(mKC, "sderr", -1, szName);
     560    kstat_t *ksDisk = kstat_lookup(mKC, NULL, -1, szName);
    508561    if (ksDisk != 0)
    509562    {
     
    524577        }
    525578    }
     579    else
     580    {
     581        LogRel(("kstat_lookup(%s) -> %d\n", szName, errno));
     582        rc = VERR_INTERNAL_ERROR;
     583    }
     584
    526585
    527586    return rc;
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