VirtualBox

Changeset 80649 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 7, 2019 12:59:36 PM (5 years ago)
Author:
vboxsync
Message:

IOM: I/O port statistics. bugref:9218

Location:
trunk/src/VBox/VMM/VMMR3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/IOM.cpp

    r80641 r80649  
    137137static DECLCALLBACK(int) iomR3RelocateIOPortCallback(PAVLROIOPORTNODECORE pNode, void *pvUser);
    138138static DECLCALLBACK(int) iomR3RelocateMMIOCallback(PAVLROGCPHYSNODECORE pNode, void *pvUser);
     139#endif
     140#ifdef VBOX_WITH_STATISTICS
     141static void iomR3IoPortRegStats(PVM pVM, PIOMIOPORTENTRYR3 pRegEntry);
     142static void iomR3IoPortDeregStats(PVM pVM, PIOMIOPORTENTRYR3 pRegEntry, unsigned uPort);
    139143#endif
    140144static DECLCALLBACK(void) iomR3IOPortInfo(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
     
    244248    LogFlow(("IOMR3Init: returns %Rrc\n", rc));
    245249    return rc;
     250}
     251
     252
     253/**
     254 * Called when a VM initialization stage is completed.
     255 *
     256 * @returns VBox status code.
     257 * @param   pVM             The cross context VM structure.
     258 * @param   enmWhat         The initialization state that was completed.
     259 */
     260VMMR3_INT_DECL(int) IOMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat)
     261{
     262#ifdef VBOX_WITH_STATISTICS
     263    if (enmWhat == VMINITCOMPLETED_RING3)
     264    {
     265        for (uint32_t i = 0; i < pVM->iom.s.cIoPortRegs; i++)
     266        {
     267            PIOMIOPORTENTRYR3 pRegEntry = &pVM->iom.s.paIoPortRegs[i];
     268            if (   pRegEntry->fMapped
     269                && pRegEntry->idxStats != UINT16_MAX)
     270                iomR3IoPortRegStats(pVM, pRegEntry);
     271        }
     272    }
     273#else
     274    RT_NOREF(pVM, enmWhat);
     275#endif
     276    return VINF_SUCCESS;
    246277}
    247278
     
    590621        pRegEntry->fMapped = true;
    591622
     623#ifdef VBOX_WITH_STATISTICS
     624        /* Don't register stats here when we're creating the VM as the
     625           statistics table may still be reallocated. */
     626        if (pVM->enmVMState >= VMSTATE_CREATED)
     627            iomR3IoPortRegStats(pVM, pRegEntry);
     628#endif
     629
    592630#ifdef VBOX_STRICT
    593631        /*
     
    677715                Assert(pEntry->uFirstPort == uPort);
    678716                Assert(pEntry->uLastPort == uLastPort);
     717#ifdef VBOX_WITH_STATISTICS
     718                iomR3IoPortDeregStats(pVM, pRegEntry, uPort);
     719#endif
    679720                if (i + 1 < cEntries)
    680721                    memmove(pEntry, pEntry + 1, sizeof(*pEntry) * (cEntries - i - 1));
     
    724765}
    725766
    726 
     767#ifdef VBOX_WITH_STATISTICS
     768
     769/**
     770 * Register statistics for an I/O port entry.
     771 */
     772static void iomR3IoPortRegStats(PVM pVM, PIOMIOPORTENTRYR3 pRegEntry)
     773{
     774    PIOMIOPORTSTATSENTRY pStats   = &pVM->iom.s.paIoPortStats[pRegEntry->idxStats];
     775    const char * const   pszDesc  = pRegEntry->pszDesc;
     776    unsigned             uPort    = pRegEntry->uPort;
     777    unsigned const       uEndPort = uPort + (unsigned)pRegEntry->cPorts;
     778    do
     779    {
     780        char   szName[80];
     781        size_t cchBaseNm = RTStrPrintf(szName, sizeof(szName), "/IOM/NewStylePorts/%04x-", uPort);
     782        int    rc;
     783
     784# define SET_NM_SUFFIX(a_sz) memcpy(&szName[cchBaseNm], a_sz, sizeof(a_sz));
     785
     786        /* register the statistics counters. */
     787        SET_NM_SUFFIX("In-R3");
     788        rc = STAMR3Register(pVM, &pStats->InR3,      STAMTYPE_COUNTER, STAMVISIBILITY_USED, szName, STAMUNIT_OCCURENCES, pszDesc); AssertRC(rc);
     789        SET_NM_SUFFIX("Out-R3");
     790        rc = STAMR3Register(pVM, &pStats->OutR3,     STAMTYPE_COUNTER, STAMVISIBILITY_USED, szName, STAMUNIT_OCCURENCES, pszDesc); AssertRC(rc);
     791        SET_NM_SUFFIX("In-RZ");
     792        rc = STAMR3Register(pVM, &pStats->InRZ,      STAMTYPE_COUNTER, STAMVISIBILITY_USED, szName, STAMUNIT_OCCURENCES, pszDesc); AssertRC(rc);
     793        SET_NM_SUFFIX("Out-RZ");
     794        rc = STAMR3Register(pVM, &pStats->OutRZ,     STAMTYPE_COUNTER, STAMVISIBILITY_USED, szName, STAMUNIT_OCCURENCES, pszDesc); AssertRC(rc);
     795        SET_NM_SUFFIX("In-RZtoR3");
     796        rc = STAMR3Register(pVM, &pStats->InRZToR3,  STAMTYPE_COUNTER, STAMVISIBILITY_USED, szName, STAMUNIT_OCCURENCES, pszDesc); AssertRC(rc);
     797        SET_NM_SUFFIX("Out-RZtoR3");
     798        rc = STAMR3Register(pVM, &pStats->OutRZToR3, STAMTYPE_COUNTER, STAMVISIBILITY_USED, szName, STAMUNIT_OCCURENCES, pszDesc); AssertRC(rc);
     799
     800        /* Profiling */
     801        SET_NM_SUFFIX("In-R3/Prof");
     802        rc = STAMR3Register(pVM, &pStats->ProfInR3,  STAMTYPE_PROFILE, STAMVISIBILITY_USED, szName, STAMUNIT_TICKS_PER_CALL, pszDesc); AssertRC(rc);
     803        SET_NM_SUFFIX("Out-R3/Prof");
     804        rc = STAMR3Register(pVM, &pStats->ProfOutR3, STAMTYPE_PROFILE, STAMVISIBILITY_USED, szName, STAMUNIT_TICKS_PER_CALL, pszDesc); AssertRC(rc);
     805        SET_NM_SUFFIX("In-RZ/Prof");
     806        rc = STAMR3Register(pVM, &pStats->ProfInRZ,  STAMTYPE_PROFILE, STAMVISIBILITY_USED, szName, STAMUNIT_TICKS_PER_CALL, pszDesc); AssertRC(rc);
     807        SET_NM_SUFFIX("Out-RZ/Prof");
     808        rc = STAMR3Register(pVM, &pStats->ProfOutRZ, STAMTYPE_PROFILE, STAMVISIBILITY_USED, szName, STAMUNIT_TICKS_PER_CALL, pszDesc); AssertRC(rc);
     809
     810        pStats++;
     811        uPort++;
     812    } while (uPort < uEndPort);
     813}
     814
     815
     816/**
     817 * Deregister statistics for an I/O port entry.
     818 */
     819static void iomR3IoPortDeregStats(PVM pVM, PIOMIOPORTENTRYR3 pRegEntry, unsigned uPort)
     820{
     821    PIOMIOPORTSTATSENTRY pStats   = &pVM->iom.s.paIoPortStats[pRegEntry->idxStats];
     822    unsigned const       uEndPort = uPort + (unsigned)pRegEntry->cPorts;
     823    do
     824    {
     825        char szPrefix[80];
     826        RTStrPrintf(szPrefix, sizeof(szPrefix), "/IOM/NewStylePorts/%04x-", uPort);
     827        STAMR3DeregisterByPrefix(pVM->pUVM, szPrefix);
     828
     829        pStats++;
     830        uPort++;
     831    } while (uPort < uEndPort);
     832}
     833
     834#endif /* VBOX_WITH_STATISTICS */
    727835#ifdef VBOX_WITH_STATISTICS
    728836
  • trunk/src/VBox/VMM/VMMR3/VM.cpp

    r80334 r80649  
    10421042    if (RT_SUCCESS(rc))
    10431043        rc = EMR3InitCompleted(pVM, enmWhat);
     1044    if (RT_SUCCESS(rc))
     1045        rc = IOMR3InitCompleted(pVM, enmWhat);
    10441046    if (enmWhat == VMINITCOMPLETED_RING3)
    10451047    {
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