VirtualBox

Changeset 80651 in vbox for trunk/src


Ignore:
Timestamp:
Sep 8, 2019 2:36:45 PM (5 years ago)
Author:
vboxsync
Message:

STAM: STAM_WITH_LOOKUP_TREE isn't optional, so drop the #ifdefs.

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

Legend:

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

    r80650 r80651  
    141141*   Internal Functions                                                                                                           *
    142142*********************************************************************************************************************************/
    143 #ifdef STAM_WITH_LOOKUP_TREE
    144143static void                 stamR3LookupDestroyTree(PSTAMLOOKUP pRoot);
    145 #endif
    146144static int                  stamR3RegisterU(PUVM pUVM, void *pvSample, PFNSTAMR3CALLBACKRESET pfnReset,
    147145                                            PFNSTAMR3CALLBACKPRINT pfnPrint, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
     
    289287    RTListInit(&pUVM->stam.s.List);
    290288
    291 #ifdef STAM_WITH_LOOKUP_TREE
    292289    /*
    293290     * Initialize the root node.
     
    311308
    312309    pUVM->stam.s.pRoot = pRoot;
    313 #endif
    314 
    315310
    316311    /*
     
    349344    RTListForEachSafe(&pUVM->stam.s.List, pCur, pNext, STAMDESC, ListEntry)
    350345    {
    351 #ifdef STAM_WITH_LOOKUP_TREE
    352346        pCur->pLookup->pDesc = NULL;
    353 #endif
    354347        RTMemFree(pCur);
    355348    }
    356349
    357 #ifdef STAM_WITH_LOOKUP_TREE
    358350    stamR3LookupDestroyTree(pUVM->stam.s.pRoot);
    359351    pUVM->stam.s.pRoot = NULL;
    360 #endif
    361352
    362353    Assert(pUVM->stam.s.RWSem != NIL_RTSEMRW);
     
    674665#endif /* VBOX_STRICT */
    675666
    676 
    677 #ifdef STAM_WITH_LOOKUP_TREE
    678667
    679668/**
     
    14511440}
    14521441
    1453 #endif /* STAM_WITH_LOOKUP_TREE */
    1454 
    1455 
    14561442
    14571443/**
     
    14881474     * Look up the tree location, populating the lookup tree as we walk it.
    14891475     */
    1490 #ifdef STAM_WITH_LOOKUP_TREE
    14911476    PSTAMLOOKUP pLookup = pUVM->stam.s.pRoot; Assert(pLookup);
    14921477    uint32_t    offName = 1;
     
    15311516
    15321517    PSTAMDESC pCur = stamR3LookupFindNextWithDesc(pLookup);
    1533 
    1534 #else
    1535     PSTAMDESC pCur;
    1536     RTListForEach(&pUVM->stam.s.List, pCur, STAMDESC, ListEntry)
    1537     {
    1538         int iDiff = strcmp(pCur->pszName, pszName);
    1539         /* passed it */
    1540         if (iDiff > 0)
    1541             break;
    1542         /* found it. */
    1543         if (!iDiff)
    1544         {
    1545             STAM_UNLOCK_WR(pUVM);
    1546             AssertMsgFailed(("Duplicate sample name: %s\n", pszName));
    1547             return VERR_ALREADY_EXISTS;
    1548         }
    1549     }
    1550 #endif
    15511518
    15521519    /*
     
    16451612            RTListAppend(&pUVM->stam.s.List, &pNew->ListEntry);
    16461613
    1647 #ifdef STAM_WITH_LOOKUP_TREE
    16481614        pNew->pLookup       = pLookup;
    16491615        pLookup->pDesc      = pNew;
    16501616        stamR3LookupIncUsage(pLookup);
    1651 #endif
    16521617
    16531618        stamR3ResetOne(pNew, pUVM->pVM);
     
    16711636{
    16721637    RTListNodeRemove(&pCur->ListEntry);
    1673 #ifdef STAM_WITH_LOOKUP_TREE
    16741638    pCur->pLookup->pDesc = NULL; /** @todo free lookup nodes once it's working. */
    16751639    stamR3LookupDecUsage(pCur->pLookup);
    16761640    stamR3LookupMaybeFree(pCur->pLookup);
    1677 #endif
    16781641    RTMemFree(pCur);
    16791642
     
    28512814 * @param   pUVM            Pointer to the user mode VM structure.
    28522815 * @param   pszPat          Pattern.
    2853  * @param   fUpdateRing0    Update the ring-0 .
     2816 * @param   fUpdateRing0    Update the stats residing in ring-0.
    28542817 * @param   pfnCallback     Callback function which shall be called for matching nodes.
    28552818 *                          If it returns anything but VINF_SUCCESS the enumeration is
     
    28602823                       int (*pfnCallback)(PSTAMDESC pDesc, void *pvArg), void *pvArg)
    28612824{
    2862     int         rc                = VINF_SUCCESS;
    2863     uint64_t    bmRefreshedGroups = 0;
    2864     PSTAMDESC   pCur;
     2825    size_t const cchPat            = pszPat ? strlen(pszPat) : 0;
     2826    int          rc                = VINF_SUCCESS;
     2827    uint64_t     bmRefreshedGroups = 0;
     2828    PSTAMDESC    pCur;
    28652829
    28662830    /*
    28672831     * All.
    28682832     */
    2869     if (!pszPat || !*pszPat || !strcmp(pszPat, "*"))
     2833    if (   cchPat < 1
     2834        || (   cchPat == 1
     2835            && *pszPat == '*'))
    28702836    {
    28712837        STAM_LOCK_RD(pUVM);
     
    28842850     * Single expression pattern.
    28852851     */
    2886     else if (!strchr(pszPat, '|'))
    2887     {
    2888         STAM_LOCK_RD(pUVM);
    2889 #ifdef STAM_WITH_LOOKUP_TREE
    2890         size_t const cchPat      = strlen(pszPat);
     2852    else if (memchr(pszPat, '|', cchPat) == NULL)
     2853    {
    28912854        const char  *pszAsterisk = (const char *)memchr(pszPat, '*',  cchPat);
    28922855        const char  *pszQuestion = (const char *)memchr(pszPat, '?',  cchPat);
     2856
     2857        STAM_LOCK_RD(pUVM);
    28932858        if (!pszAsterisk && !pszQuestion)
    28942859        {
     
    29552920                Assert(!pLast);
    29562921        }
    2957 #else
    2958         RTListForEach(&pUVM->stam.s.List, pCur, STAMDESC, ListEntry)
    2959         {
    2960             if (RTStrSimplePatternMatch(pszPat, pCur->pszName))
    2961             {
    2962                 if (fUpdateRing0)
    2963                     stamR3Refresh(pUVM, pCur, &bmRefreshedGroups);
    2964                 rc = pfnCallback(pCur, pvArg);
    2965                 if (rc)
    2966                     break;
    2967             }
    2968         }
    2969 #endif
    29702922        STAM_UNLOCK_RD(pUVM);
    29712923    }
  • trunk/src/VBox/VMM/include/STAMInternal.h

    r76585 r80651  
    3939 * @{
    4040 */
    41 
    42 /** Enables the lookup tree.
    43  * This is an optimization for speeding up registration as well as query. */
    44 #define STAM_WITH_LOOKUP_TREE
    45 
    4641
    4742/** Pointer to sample descriptor. */
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