- Timestamp:
- Sep 8, 2019 2:36:45 PM (5 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/STAM.cpp
r80650 r80651 141 141 * Internal Functions * 142 142 *********************************************************************************************************************************/ 143 #ifdef STAM_WITH_LOOKUP_TREE144 143 static void stamR3LookupDestroyTree(PSTAMLOOKUP pRoot); 145 #endif146 144 static int stamR3RegisterU(PUVM pUVM, void *pvSample, PFNSTAMR3CALLBACKRESET pfnReset, 147 145 PFNSTAMR3CALLBACKPRINT pfnPrint, STAMTYPE enmType, STAMVISIBILITY enmVisibility, … … 289 287 RTListInit(&pUVM->stam.s.List); 290 288 291 #ifdef STAM_WITH_LOOKUP_TREE292 289 /* 293 290 * Initialize the root node. … … 311 308 312 309 pUVM->stam.s.pRoot = pRoot; 313 #endif314 315 310 316 311 /* … … 349 344 RTListForEachSafe(&pUVM->stam.s.List, pCur, pNext, STAMDESC, ListEntry) 350 345 { 351 #ifdef STAM_WITH_LOOKUP_TREE352 346 pCur->pLookup->pDesc = NULL; 353 #endif354 347 RTMemFree(pCur); 355 348 } 356 349 357 #ifdef STAM_WITH_LOOKUP_TREE358 350 stamR3LookupDestroyTree(pUVM->stam.s.pRoot); 359 351 pUVM->stam.s.pRoot = NULL; 360 #endif361 352 362 353 Assert(pUVM->stam.s.RWSem != NIL_RTSEMRW); … … 674 665 #endif /* VBOX_STRICT */ 675 666 676 677 #ifdef STAM_WITH_LOOKUP_TREE678 667 679 668 /** … … 1451 1440 } 1452 1441 1453 #endif /* STAM_WITH_LOOKUP_TREE */1454 1455 1456 1442 1457 1443 /** … … 1488 1474 * Look up the tree location, populating the lookup tree as we walk it. 1489 1475 */ 1490 #ifdef STAM_WITH_LOOKUP_TREE1491 1476 PSTAMLOOKUP pLookup = pUVM->stam.s.pRoot; Assert(pLookup); 1492 1477 uint32_t offName = 1; … … 1531 1516 1532 1517 PSTAMDESC pCur = stamR3LookupFindNextWithDesc(pLookup); 1533 1534 #else1535 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 #endif1551 1518 1552 1519 /* … … 1645 1612 RTListAppend(&pUVM->stam.s.List, &pNew->ListEntry); 1646 1613 1647 #ifdef STAM_WITH_LOOKUP_TREE1648 1614 pNew->pLookup = pLookup; 1649 1615 pLookup->pDesc = pNew; 1650 1616 stamR3LookupIncUsage(pLookup); 1651 #endif1652 1617 1653 1618 stamR3ResetOne(pNew, pUVM->pVM); … … 1671 1636 { 1672 1637 RTListNodeRemove(&pCur->ListEntry); 1673 #ifdef STAM_WITH_LOOKUP_TREE1674 1638 pCur->pLookup->pDesc = NULL; /** @todo free lookup nodes once it's working. */ 1675 1639 stamR3LookupDecUsage(pCur->pLookup); 1676 1640 stamR3LookupMaybeFree(pCur->pLookup); 1677 #endif1678 1641 RTMemFree(pCur); 1679 1642 … … 2851 2814 * @param pUVM Pointer to the user mode VM structure. 2852 2815 * @param pszPat Pattern. 2853 * @param fUpdateRing0 Update the ring-0.2816 * @param fUpdateRing0 Update the stats residing in ring-0. 2854 2817 * @param pfnCallback Callback function which shall be called for matching nodes. 2855 2818 * If it returns anything but VINF_SUCCESS the enumeration is … … 2860 2823 int (*pfnCallback)(PSTAMDESC pDesc, void *pvArg), void *pvArg) 2861 2824 { 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; 2865 2829 2866 2830 /* 2867 2831 * All. 2868 2832 */ 2869 if (!pszPat || !*pszPat || !strcmp(pszPat, "*")) 2833 if ( cchPat < 1 2834 || ( cchPat == 1 2835 && *pszPat == '*')) 2870 2836 { 2871 2837 STAM_LOCK_RD(pUVM); … … 2884 2850 * Single expression pattern. 2885 2851 */ 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 { 2891 2854 const char *pszAsterisk = (const char *)memchr(pszPat, '*', cchPat); 2892 2855 const char *pszQuestion = (const char *)memchr(pszPat, '?', cchPat); 2856 2857 STAM_LOCK_RD(pUVM); 2893 2858 if (!pszAsterisk && !pszQuestion) 2894 2859 { … … 2955 2920 Assert(!pLast); 2956 2921 } 2957 #else2958 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 #endif2970 2922 STAM_UNLOCK_RD(pUVM); 2971 2923 } -
trunk/src/VBox/VMM/include/STAMInternal.h
r76585 r80651 39 39 * @{ 40 40 */ 41 42 /** Enables the lookup tree.43 * This is an optimization for speeding up registration as well as query. */44 #define STAM_WITH_LOOKUP_TREE45 46 41 47 42 /** Pointer to sample descriptor. */
Note:
See TracChangeset
for help on using the changeset viewer.