VirtualBox

Changeset 64835 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Dec 12, 2016 4:48:05 PM (8 years ago)
Author:
vboxsync
Message:

Devices/Storage/DrvVD: Add some general statistics applying to all devices

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DrvVD.cpp

    r64727 r64835  
    414414    /** @name Statistics.
    415415     * @{ */
    416     /** how many attempts were made to query a direct buffer pointer from the
     416    /** How many attempts were made to query a direct buffer pointer from the
    417417     * device/driver above. */
    418418    STAMCOUNTER              StatQueryBufAttempts;
    419419    /** How many attempts to query a direct buffer pointer succeeded. */
    420420    STAMCOUNTER              StatQueryBufSuccess;
     421    /** Release statistics: number of bytes written. */
     422    STAMCOUNTER              StatBytesWritten;
     423    /** Release statistics: number of bytes read. */
     424    STAMCOUNTER              StatBytesRead;
     425    /** Release statistics: Number of requests submitted. */
     426    STAMCOUNTER              StatReqsSubmitted;
     427    /** Release statistics: Number of requests failed. */
     428    STAMCOUNTER              StatReqsFailed;
     429    /** Release statistics: Number of requests succeeded. */
     430    STAMCOUNTER              StatReqsSucceeded;
     431    /** Release statistics: Number of flush requests. */
     432    STAMCOUNTER              StatReqsFlush;
     433    /** Release statistics: Number of write requests. */
     434    STAMCOUNTER              StatReqsWrite;
     435    /** Release statistics: Number of read requests. */
     436    STAMCOUNTER              StatReqsRead;
     437    /** Release statistics: Number of discard requests. */
     438    STAMCOUNTER              StatReqsDiscard;
     439    /** Release statistics: Number of I/O requests processed per second. */
     440    STAMCOUNTER              StatReqsPerSec;
    421441    /** @} */
    422442} VBOXDISK;
     
    18911911        return rc;
    18921912
     1913    STAM_REL_COUNTER_INC(&pThis->StatReqsSubmitted);
     1914    STAM_REL_COUNTER_INC(&pThis->StatReqsRead);
     1915
    18931916    if (!pThis->fBootAccelActive)
    18941917        rc = VDRead(pThis->pDisk, off, pvBuf, cbRead);
     
    19261949
    19271950    if (RT_SUCCESS(rc))
     1951    {
     1952        STAM_REL_COUNTER_INC(&pThis->StatReqsSucceeded);
    19281953        Log2(("%s: off=%#llx pvBuf=%p cbRead=%d\n%.*Rhxd\n", __FUNCTION__,
    19291954              off, pvBuf, cbRead, cbRead, pvBuf));
     1955    }
     1956    else
     1957        STAM_REL_COUNTER_INC(&pThis->StatReqsFailed);
     1958
    19301959    LogFlowFunc(("returns %Rrc\n", rc));
    19311960    return rc;
     
    20292058    }
    20302059
     2060    STAM_REL_COUNTER_INC(&pThis->StatReqsSubmitted);
     2061    STAM_REL_COUNTER_INC(&pThis->StatReqsWrite);
     2062
    20312063    rc = VDWrite(pThis->pDisk, off, pvBuf, cbWrite);
    20322064#ifdef VBOX_PERIODIC_FLUSH
     
    20412073    }
    20422074#endif /* VBOX_PERIODIC_FLUSH */
     2075
     2076    if (RT_SUCCESS(rc))
     2077        STAM_REL_COUNTER_INC(&pThis->StatReqsSucceeded);
     2078    else
     2079        STAM_REL_COUNTER_INC(&pThis->StatReqsFailed);
    20432080
    20442081    LogFlowFunc(("returns %Rrc\n", rc));
     
    20662103#endif /* VBOX_IGNORE_FLUSH */
    20672104
     2105    STAM_REL_COUNTER_INC(&pThis->StatReqsSubmitted);
     2106    STAM_REL_COUNTER_INC(&pThis->StatReqsFlush);
     2107
    20682108    int rc = VDFlush(pThis->pDisk);
     2109    if (RT_SUCCESS(rc))
     2110        STAM_REL_COUNTER_INC(&pThis->StatReqsSucceeded);
     2111    else
     2112        STAM_REL_COUNTER_INC(&pThis->StatReqsFailed);
     2113
    20692114    LogFlowFunc(("returns %Rrc\n", rc));
    20702115    return rc;
     
    24072452    PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
    24082453
     2454    STAM_REL_COUNTER_INC(&pThis->StatReqsSubmitted);
     2455    STAM_REL_COUNTER_INC(&pThis->StatReqsDiscard);
     2456
    24092457    int rc = VDDiscardRanges(pThis->pDisk, paRanges, cRanges);
     2458    if (RT_SUCCESS(rc))
     2459        STAM_REL_COUNTER_INC(&pThis->StatReqsSucceeded);
     2460    else
     2461        STAM_REL_COUNTER_INC(&pThis->StatReqsFailed);
     2462
    24102463    LogFlowFunc(("returns %Rrc\n", rc));
    24112464    return rc;
     
    28322885            }
    28332886        }
     2887
     2888        STAM_REL_COUNTER_INC(&pThis->StatReqsFailed);
     2889    }
     2890    else
     2891    {
     2892        STAM_REL_COUNTER_INC(&pThis->StatReqsSucceeded);
     2893
     2894        switch (pIoReq->enmType)
     2895        {
     2896            case PDMMEDIAEXIOREQTYPE_READ:
     2897                STAM_REL_COUNTER_ADD(&pThis->StatBytesRead, pIoReq->ReadWrite.cbReq);
     2898                break;
     2899            case PDMMEDIAEXIOREQTYPE_WRITE:
     2900                STAM_REL_COUNTER_ADD(&pThis->StatBytesWritten, pIoReq->ReadWrite.cbReq);
     2901                break;
     2902            default:
     2903                break;
     2904        }
    28342905    }
    28352906
     
    35793650        return VERR_PDM_MEDIAEX_IOREQ_INVALID_STATE;
    35803651
     3652    STAM_REL_COUNTER_INC(&pThis->StatReqsSubmitted);
     3653    STAM_REL_COUNTER_INC(&pThis->StatReqsRead);
     3654
    35813655    pIoReq->enmType             = PDMMEDIAEXIOREQTYPE_READ;
    35823656    pIoReq->tsSubmit            = RTTimeMilliTS();
     
    36183692        return VERR_PDM_MEDIAEX_IOREQ_INVALID_STATE;
    36193693
     3694    STAM_REL_COUNTER_INC(&pThis->StatReqsSubmitted);
     3695    STAM_REL_COUNTER_INC(&pThis->StatReqsWrite);
     3696
    36203697    pIoReq->enmType             = PDMMEDIAEXIOREQTYPE_WRITE;
    36213698    pIoReq->tsSubmit            = RTTimeMilliTS();
     
    36573734        return VERR_PDM_MEDIAEX_IOREQ_INVALID_STATE;
    36583735
     3736    STAM_REL_COUNTER_INC(&pThis->StatReqsSubmitted);
     3737    STAM_REL_COUNTER_INC(&pThis->StatReqsFlush);
     3738
    36593739    pIoReq->enmType  = PDMMEDIAEXIOREQTYPE_FLUSH;
    36603740    pIoReq->tsSubmit = RTTimeMilliTS();
     
    36943774    if (RT_UNLIKELY(enmState != VDIOREQSTATE_ALLOCATED))
    36953775        return VERR_PDM_MEDIAEX_IOREQ_INVALID_STATE;
     3776
     3777    STAM_REL_COUNTER_INC(&pThis->StatReqsSubmitted);
     3778    STAM_REL_COUNTER_INC(&pThis->StatReqsDiscard);
    36963779
    36973780    /* Copy the ranges over now, this can be optimized in the future. */
     
    41124195}
    41134196
     4197/**
     4198 * Registers statistics associated with the given media driver.
     4199 *
     4200 * @returns VBox status code.
     4201 * @param   pThis      The media driver instance.
     4202 */
     4203static int drvvdStatsRegister(PVBOXDISK pThis)
     4204{
     4205    PPDMDRVINS pDrvIns = pThis->pDrvIns;
     4206    uint32_t iInstance, iLUN;
     4207    const char *pcszController;
     4208
     4209    int rc = pThis->pDrvMediaPort->pfnQueryDeviceLocation(pThis->pDrvMediaPort, &pcszController,
     4210                                                          &iInstance, &iLUN);
     4211    if (RT_SUCCESS(rc))
     4212    {
     4213        char *pszCtrlUpper = RTStrDup(pcszController);
     4214        if (pszCtrlUpper)
     4215        {
     4216            RTStrToUpper(pszCtrlUpper);
     4217
     4218            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatQueryBufAttempts, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
     4219                                   STAMUNIT_COUNT, "Number of attempts to query a direct buffer.",
     4220                                   "/Devices/%s%u/Port%u/QueryBufAttempts", pszCtrlUpper, iInstance, iLUN);
     4221            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatQueryBufSuccess, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
     4222                                   STAMUNIT_COUNT, "Number of succeeded attempts to query a direct buffer.",
     4223                                   "/Devices/%s%u/Port%u/QueryBufSuccess", pszCtrlUpper, iInstance, iLUN);
     4224
     4225            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatBytesRead, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_BYTES,
     4226                                   "Amount of data read.", "/Devices/%s%u/Port%u/ReadBytes", pszCtrlUpper, iInstance, iLUN);
     4227            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatBytesWritten, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_BYTES,
     4228                                   "Amount of data written.", "/Devices/%s%u/Port%u/WrittenBytes", pszCtrlUpper, iInstance, iLUN);
     4229
     4230            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReqsSubmitted, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT,
     4231                                   "Number of I/O requests submitted.", "/Devices/%s%u/Port%u/ReqsSubmitted", pszCtrlUpper, iInstance, iLUN);
     4232            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReqsFailed, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT,
     4233                                   "Number of I/O requests failed.", "/Devices/%s%u/Port%u/ReqsFailed", pszCtrlUpper, iInstance, iLUN);
     4234            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReqsSucceeded, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT,
     4235                                   "Number of I/O requests succeeded.", "/Devices/%s%u/Port%u/ReqsSucceeded", pszCtrlUpper, iInstance, iLUN);
     4236            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReqsFlush, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT,
     4237                                   "Number of flush I/O requests submitted.", "/Devices/%s%u/Port%u/ReqsFlush", pszCtrlUpper, iInstance, iLUN);
     4238            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReqsWrite, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT,
     4239                                   "Number of write I/O requests submitted.", "/Devices/%s%u/Port%u/ReqsWrite", pszCtrlUpper, iInstance, iLUN);
     4240            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReqsRead, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT,
     4241                                   "Number of read I/O requests submitted.", "/Devices/%s%u/Port%u/ReqsRead", pszCtrlUpper, iInstance, iLUN);
     4242            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReqsDiscard, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT,
     4243                                   "Number of discard I/O requests submitted.", "/Devices/%s%u/Port%u/ReqsDiscard", pszCtrlUpper, iInstance, iLUN);
     4244
     4245            PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReqsPerSec, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES,
     4246                                   "Number of processed I/O requests per second.", "/Devices/%s%u/Port%u/ReqsPerSec",
     4247                                   pszCtrlUpper, iInstance, iLUN);
     4248
     4249            RTStrFree(pszCtrlUpper);
     4250        }
     4251        else
     4252            rc = VERR_NO_STR_MEMORY;
     4253    }
     4254
     4255    return rc;
     4256}
     4257
     4258/**
     4259 * Deregisters statistics associated with the given media driver.
     4260 *
     4261 * @returns nothing.
     4262 * @param   pThis      The media driver instance.
     4263 */
     4264static void drvvdStatsDeregister(PVBOXDISK pThis)
     4265{
     4266    PPDMDRVINS pDrvIns = pThis->pDrvIns;
     4267
     4268    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueryBufAttempts);
     4269    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueryBufSuccess);
     4270
     4271    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatBytesRead);
     4272    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatBytesWritten);
     4273    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReqsSubmitted);
     4274    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReqsFailed);
     4275    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReqsSucceeded);
     4276    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReqsFlush);
     4277    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReqsWrite);
     4278    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReqsRead);
     4279    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReqsDiscard);
     4280    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReqsPerSec);
     4281}
    41144282
    41154283/*********************************************************************************************************************************
     
    44154583            RTSemFastMutexDestroy(pThis->aIoReqAllocBins[i].hMtxLstIoReqAlloc);
    44164584
    4417     PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueryBufAttempts);
    4418     PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatQueryBufSuccess);
     4585    drvvdStatsDeregister(pThis);
    44194586}
    44204587
     
    54085575    } /* !fEmptyDrive */
    54095576
    5410     PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->StatQueryBufAttempts, "QueryBufAttempts",
    5411                               STAMUNIT_COUNT, "Number of attempts to query a direct buffer.");
    5412     PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->StatQueryBufSuccess, "QueryBufSuccess",
    5413                               STAMUNIT_COUNT, "Number of succeeded attempts to query a direct buffer.");
     5577    if (RT_SUCCESS(rc))
     5578        drvvdStatsRegister(pThis);
    54145579
    54155580    if (RT_FAILURE(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