VirtualBox

Changeset 82333 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Dec 3, 2019 1:03:18 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
135157
Message:

TM: Added timer statistics. bugref:9218

Location:
trunk/src/VBox/VMM
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/TMAll.cpp

    r81153 r82333  
    12501250{
    12511251    PVMCC pVM = pTimer->CTX_SUFF(pVM);
     1252    STAM_COUNTER_INC(&pTimer->StatSetAbsolute);
    12521253
    12531254    /* Treat virtual sync timers specially. */
     
    15561557{
    15571558    PVMCC pVM = pTimer->CTX_SUFF(pVM);
     1559    STAM_COUNTER_INC(&pTimer->StatSetRelative);
    15581560
    15591561    /* Treat virtual sync timers specially. */
     
    18781880{
    18791881    PVMCC pVM = pTimer->CTX_SUFF(pVM);
     1882    STAM_COUNTER_INC(&pTimer->StatStop);
    18801883
    18811884    /* Treat virtual sync timers specially. */
     
    19851988{
    19861989    PVMCC pVM = pTimer->CTX_SUFF(pVM);
     1990    STAM_COUNTER_INC(&pTimer->StatGet);
    19871991
    19881992    uint64_t u64;
  • trunk/src/VBox/VMM/VMMR3/TM.cpp

    r81153 r82333  
    14861486}
    14871487
     1488#ifdef VBOX_WITH_STATISTICS
     1489/** Names the clock of the timer.   */
     1490static const char *tmR3TimerClockName(PTMTIMERR3 pTimer)
     1491{
     1492    switch (pTimer->enmClock)
     1493    {
     1494        case TMCLOCK_VIRTUAL:       return "virtual";
     1495        case TMCLOCK_VIRTUAL_SYNC:  return "virtual-sync";
     1496        case TMCLOCK_REAL:          return "real";
     1497        case TMCLOCK_TSC:           return "tsc";
     1498        case TMCLOCK_MAX:           break;
     1499    }
     1500    return "corrupt clock value";
     1501}
     1502#endif
     1503
    14881504
    14891505/**
     
    15461562#endif
    15471563    TM_UNLOCK_TIMERS(pVM);
     1564
     1565    /*
     1566     * Register statistics.
     1567     */
     1568#ifdef VBOX_WITH_STATISTICS
     1569
     1570    STAMR3RegisterF(pVM, &pTimer->StatTimer,        STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL,
     1571                    tmR3TimerClockName(pTimer), "/TM/Timers/%s", pszDesc);
     1572    STAMR3RegisterF(pVM, &pTimer->StatCritSectEnter, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL,
     1573                    "", "/TM/Timers/%s/CritSectEnter", pszDesc);
     1574    STAMR3RegisterF(pVM, &pTimer->StatGet,          STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS,
     1575                    "", "/TM/Timers/%s/Get", pszDesc);
     1576    STAMR3RegisterF(pVM, &pTimer->StatSetAbsolute,  STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS,
     1577                    "", "/TM/Timers/%s/SetAbsolute", pszDesc);
     1578    STAMR3RegisterF(pVM, &pTimer->StatSetRelative,  STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS,
     1579                    "", "/TM/Timers/%s/SetRelative", pszDesc);
     1580    STAMR3RegisterF(pVM, &pTimer->StatStop,         STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS,
     1581                    "", "/TM/Timers/%s/Stop", pszDesc);
     1582#endif
    15481583
    15491584    *ppTimer = pTimer;
     
    18721907
    18731908    /*
    1874      * Read to move the timer from the created list and onto the free list.
     1909     * Deregister statistics.
     1910     */
     1911#ifdef VBOX_WITH_STATISTICS
     1912    char szPrefix[128];
     1913    RTStrPrintf(szPrefix, sizeof(szPrefix), "/TM/Timers/%s", pTimer->pszDesc);
     1914    STAMR3DeregisterByPrefix(pVM->pUVM, szPrefix);
     1915#endif
     1916
     1917    /*
     1918     * Ready to move the timer from the created list and onto the free list.
    18751919     */
    18761920    Assert(!pTimer->offNext); Assert(!pTimer->offPrev); Assert(!pTimer->offScheduleNext);
     
    22292273        PPDMCRITSECT    pCritSect = pTimer->pCritSect;
    22302274        if (pCritSect)
     2275        {
     2276            STAM_PROFILE_START(&pTimer->StatCritSectEnter, Locking);
    22312277            PDMCritSectEnter(pCritSect, VERR_IGNORED);
     2278            STAM_PROFILE_STOP(&pTimer->StatCritSectEnter, Locking);
     2279        }
    22322280        Log2(("tmR3TimerQueueRun: %p:{.enmState=%s, .enmClock=%d, .enmType=%d, u64Expire=%llx (now=%llx) .pszDesc=%s}\n",
    22332281              pTimer, tmTimerState(pTimer->enmState), pTimer->enmClock, pTimer->enmType, pTimer->u64Expire, u64Now, pTimer->pszDesc));
     
    22542302            /* fire */
    22552303            TM_SET_STATE(pTimer, TMTIMERSTATE_EXPIRED_DELIVER);
     2304            STAM_PROFILE_START(&pTimer->StatTimer, PrfTimer);
    22562305            switch (pTimer->enmType)
    22572306            {
     
    22652314                    break;
    22662315            }
     2316            STAM_PROFILE_STOP(&pTimer->StatTimer, PrfTimer);
    22672317
    22682318            /* change the state if it wasn't changed already in the handler. */
     
    24162466        PPDMCRITSECT pCritSect = pTimer->pCritSect;
    24172467        if (pCritSect)
     2468        {
     2469            STAM_PROFILE_START(&pTimer->StatCritSectEnter, Locking);
    24182470            PDMCritSectEnter(pCritSect, VERR_IGNORED);
     2471            STAM_PROFILE_STOP(&pTimer->StatCritSectEnter, Locking);
     2472        }
    24192473
    24202474        Log2(("tmR3TimerQueueRun: %p:{.enmState=%s, .enmClock=%d, .enmType=%d, u64Expire=%llx (now=%llx) .pszDesc=%s}\n",
     
    24332487        tmTimerQueueUnlinkActive(pQueue, pTimer);
    24342488        TM_SET_STATE(pTimer, TMTIMERSTATE_EXPIRED_DELIVER);
     2489        STAM_PROFILE_START(&pTimer->StatTimer, PrfTimer);
    24352490        switch (pTimer->enmType)
    24362491        {
     
    24442499                break;
    24452500        }
     2501        STAM_PROFILE_STOP(&pTimer->StatTimer, PrfTimer);
    24462502
    24472503        /* Change the state if it wasn't changed already in the handler.
  • trunk/src/VBox/VMM/include/TMInternal.h

    r80281 r82333  
    205205#if HC_ARCH_BITS == 32
    206206    uint32_t                padding0; /**< pad structure to multiple of 8 bytes. */
     207#endif
     208#ifdef VBOX_WITH_STATISTICS
     209    STAMPROFILE             StatTimer;
     210    STAMPROFILE             StatCritSectEnter;
     211    STAMCOUNTER             StatGet;
     212    STAMCOUNTER             StatSetAbsolute;
     213    STAMCOUNTER             StatSetRelative;
     214    STAMCOUNTER             StatStop;
    207215#endif
    208216} TMTIMER;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette