VirtualBox

Changeset 90265 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 20, 2021 8:12:41 PM (4 years ago)
Author:
vboxsync
Message:

VMMDev: Reduce the HGCM accounting categories to the same three as we use in HGCM for connections and pending calls. bugref:9379

Location:
trunk/src/VBox/Devices/VMMDev
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VMMDev/VMMDev.cpp

    r90264 r90265  
    46574657     * memory as a rough hint of how much we can handle.
    46584658     */
    4659     /** @todo If we reduced the number of categories here, we could alot more to
    4660      *        each... */
    46614659    uint64_t cbDefaultBudget = 0;
    46624660    if (RT_FAILURE(RTSystemQueryTotalRam(&cbDefaultBudget)))
    4663         cbDefaultBudget = 16 * _1G64;
     4661        cbDefaultBudget = 8 * _1G64;
    46644662    LogFunc(("RTSystemQueryTotalRam -> %'RU64 (%RX64)\n", cbDefaultBudget, cbDefaultBudget));
    46654663# if ARCH_BITS == 32
     
    46674665# endif
    46684666    cbDefaultBudget /= 8;                               /* One eighth of physical memory ... */
    4669     cbDefaultBudget /= RT_ELEMENTS(pThisCC->aHgcmAcc);  /* over 8 accounting categories. (8GiB -> 64MiB) */
    4670     cbDefaultBudget  = RT_MIN(cbDefaultBudget, _512M);  /* max 512MiB */
    4671     cbDefaultBudget  = RT_MAX(cbDefaultBudget, _32M);   /* min  32MiB */
     4667    cbDefaultBudget /= RT_ELEMENTS(pThisCC->aHgcmAcc);  /* over 3 accounting categories. (8GiB -> 341MiB) */
     4668    cbDefaultBudget  = RT_MIN(cbDefaultBudget, _1G);    /* max 1024MiB */
     4669    cbDefaultBudget  = RT_MAX(cbDefaultBudget, _32M);   /* min   32MiB */
    46724670    rc = pHlp->pfnCFGMQueryU64Def(pCfg, "HGCMHeapBudgetDefault", &cbDefaultBudget, cbDefaultBudget);
    46734671    if (RT_FAILURE(rc))
     
    46774675    static const struct { const char *pszName; unsigned idx; } s_aCfgHeapBudget[] =
    46784676    {
    4679         { "HGCMHeapBudgetLegacy",       VMMDEV_REQUESTOR_USR_NOT_GIVEN  },
    4680         { "HGCMHeapBudgetVBoxGuest",    VMMDEV_REQUESTOR_USR_DRV        },
    4681         { "HGCMHeapBudgetOtherDrv",     VMMDEV_REQUESTOR_USR_DRV_OTHER  },
    4682         { "HGCMHeapBudgetRoot",         VMMDEV_REQUESTOR_USR_ROOT       },
    4683         { "HGCMHeapBudgetSystem",       VMMDEV_REQUESTOR_USR_SYSTEM     },
    4684         { "HGCMHeapBudgetReserved1",    VMMDEV_REQUESTOR_USR_RESERVED1  },
    4685         { "HGCMHeapBudgetUser",         VMMDEV_REQUESTOR_USR_USER       },
    4686         { "HGCMHeapBudgetGuest",        VMMDEV_REQUESTOR_USR_GUEST      },
     4677        { "HGCMHeapBudgetKernel",       VMMDEV_HGCM_CATEGORY_KERNEL },
     4678        { "HGCMHeapBudgetRoot",         VMMDEV_HGCM_CATEGORY_ROOT   },
     4679        { "HGCMHeapBudgetUser",         VMMDEV_HGCM_CATEGORY_USER   },
    46874680    };
    46884681    AssertCompile(RT_ELEMENTS(s_aCfgHeapBudget) == RT_ELEMENTS(pThisCC->aHgcmAcc));
  • trunk/src/VBox/Devices/VMMDev/VMMDevHGCM.cpp

    r90264 r90265  
    281281                                         uint32_t cbRequest, uint32_t cParms, uint32_t fRequestor)
    282282{
    283     /* For heap accounting. */
    284     uintptr_t const idxHeapAcc = fRequestor != VMMDEV_REQUESTOR_LEGACY
    285                                ? fRequestor & VMMDEV_REQUESTOR_USR_MASK
    286                                : VMMDEV_REQUESTOR_USR_NOT_GIVEN;
     283    /*
     284     * Pick the heap accounting category.
     285     *
     286     * Initial idea was to just use what VMMDEV_REQUESTOR_USR_MASK yields directly,
     287     * but there are so many unused categories then (DRV, RESERVED1, GUEST).  Better
     288     * to have fewer and more heap available in each.
     289     */
     290    uintptr_t idxHeapAcc;
     291    if (fRequestor != VMMDEV_REQUESTOR_LEGACY)
     292        switch (fRequestor & VMMDEV_REQUESTOR_USR_MASK)
     293        {
     294            case VMMDEV_REQUESTOR_USR_NOT_GIVEN:
     295            case VMMDEV_REQUESTOR_USR_DRV:
     296            case VMMDEV_REQUESTOR_USR_DRV_OTHER:
     297                idxHeapAcc = VMMDEV_HGCM_CATEGORY_KERNEL;
     298                break;
     299            case VMMDEV_REQUESTOR_USR_ROOT:
     300            case VMMDEV_REQUESTOR_USR_SYSTEM:
     301                idxHeapAcc = VMMDEV_HGCM_CATEGORY_ROOT;
     302                break;
     303            default:
     304                AssertFailed(); RT_FALL_THRU();
     305            case VMMDEV_REQUESTOR_USR_RESERVED1:
     306            case VMMDEV_REQUESTOR_USR_USER:
     307            case VMMDEV_REQUESTOR_USR_GUEST:
     308                idxHeapAcc = VMMDEV_HGCM_CATEGORY_USER;
     309                break;
     310        }
     311    else
     312        idxHeapAcc = VMMDEV_HGCM_CATEGORY_KERNEL;
     313
    287314#if 1
    288315    /*
  • trunk/src/VBox/Devices/VMMDev/VMMDevState.h

    r90264 r90265  
    355355
    356356
     357/** @name VMMDev/HGCM accounting categories (indexes into VMMDEVR3::aHgcmAcc)
     358 * @{  */
     359/** Legacy, VMMDEV_REQUESTOR_USR_NOT_GIVEN, VMMDEV_REQUESTOR_USR_DRV,
     360 *  VMMDEV_REQUESTOR_USR_DRV_OTHER. */
     361#define VMMDEV_HGCM_CATEGORY_KERNEL   0
     362/** VMMDEV_REQUESTOR_USR_ROOT, VMMDEV_REQUESTOR_USR_SYSTEM   */
     363#define VMMDEV_HGCM_CATEGORY_ROOT     1
     364/** VMMDEV_REQUESTOR_USR_RESERVED1, VMMDEV_REQUESTOR_USR_USER,
     365 *  VMMDEV_REQUESTOR_USR_GUEST */
     366#define VMMDEV_HGCM_CATEGORY_USER     2
     367/** Array size. */
     368#define VMMDEV_HGCM_CATEGORY_MAX      3
     369/** @} */
     370
    357371/**
    358372 * State structure for the VMM device, ring-3 edition.
     
    412426        /** Total number of message. */
    413427        STAMCOUNTER                 cTotalMessages;
    414     } aHgcmAcc[VMMDEV_REQUESTOR_USR_MASK + 1];
     428    } aHgcmAcc[VMMDEV_HGCM_CATEGORY_MAX];
    415429    STAMPROFILE                     StatHgcmCmdArrival;
    416430    STAMPROFILE                     StatHgcmCmdCompletion;
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