VirtualBox

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


Ignore:
Timestamp:
Jul 7, 2009 5:10:52 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
49715
Message:

PDMQueue&users-thereof: Named the queues and added statistics.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PDMDevHlp.cpp

    r20927 r21363  
    12171217/** @copydoc PDMDEVHLPR3::pfnPDMQueueCreate */
    12181218static DECLCALLBACK(int) pdmR3DevHlp_PDMQueueCreate(PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
    1219                                                     PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue)
    1220 {
    1221     PDMDEV_ASSERT_DEVINS(pDevIns);
    1222     LogFlow(("pdmR3DevHlp_PDMQueueCreate: caller='%s'/%d: cbItem=%#x cItems=%#x cMilliesInterval=%u pfnCallback=%p fGCEnabled=%RTbool ppQueue=%p\n",
    1223              pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, ppQueue));
     1219                                                    PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, const char *pszName, PPDMQUEUE *ppQueue)
     1220{
     1221    PDMDEV_ASSERT_DEVINS(pDevIns);
     1222    LogFlow(("pdmR3DevHlp_PDMQueueCreate: caller='%s'/%d: cbItem=%#x cItems=%#x cMilliesInterval=%u pfnCallback=%p fGCEnabled=%RTbool pszName=%p:{%s} ppQueue=%p\n",
     1223             pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, pszName, pszName, ppQueue));
    12241224
    12251225    PVM pVM = pDevIns->Internal.s.pVMR3;
    12261226    VM_ASSERT_EMT(pVM);
    1227     int rc = PDMR3QueueCreateDevice(pVM, pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, ppQueue);
     1227
     1228    if (pDevIns->iInstance > 0)
     1229    {
     1230        pszName = MMR3HeapAPrintf(pVM, MM_TAG_PDM_DEVICE_DESC, "%s-%u", pszName, pDevIns->iInstance);
     1231        AssertLogRelReturn(pszName, VERR_NO_MEMORY);
     1232    }
     1233
     1234    int rc = PDMR3QueueCreateDevice(pVM, pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, pszName, ppQueue);
    12281235
    12291236    LogFlow(("pdmR3DevHlp_PDMQueueCreate: caller='%s'/%d: returns %Rrc *ppQueue=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc, *ppQueue));
  • trunk/src/VBox/VMM/PDMDevice.cpp

    r21188 r21363  
    137137    AssertReleaseRCReturn(rc, rc);
    138138
    139     rc = PDMR3QueueCreateInternal(pVM, sizeof(PDMDEVHLPTASK), 8, 0, pdmR3DevHlpQueueConsumer, true, &pVM->pdm.s.pDevHlpQueueR3);
     139    rc = PDMR3QueueCreateInternal(pVM, sizeof(PDMDEVHLPTASK), 8, 0, pdmR3DevHlpQueueConsumer, true, "DevHlp",
     140                                  &pVM->pdm.s.pDevHlpQueueR3);
    140141    AssertRCReturn(rc, rc);
    141142    pVM->pdm.s.pDevHlpQueueR0 = PDMQueueR0Ptr(pVM->pdm.s.pDevHlpQueueR3);
  • trunk/src/VBox/VMM/PDMDriver.cpp

    r21188 r21363  
    815815
    816816/** @copydoc PDMDRVHLP::pfnPDMQueueCreate */
    817 static DECLCALLBACK(int) pdmR3DrvHlp_PDMQueueCreate(PPDMDRVINS pDrvIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, PFNPDMQUEUEDRV pfnCallback, PPDMQUEUE *ppQueue)
    818 {
    819     PDMDRV_ASSERT_DRVINS(pDrvIns);
    820     LogFlow(("pdmR3DrvHlp_PDMQueueCreate: caller='%s'/%d: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p ppQueue=%p\n",
    821              pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, cbItem, cItems, cMilliesInterval, pfnCallback, ppQueue, ppQueue));
    822     VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
    823 
    824     int rc = PDMR3QueueCreateDriver(pDrvIns->Internal.s.pVM, pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback, ppQueue);
     817static DECLCALLBACK(int) pdmR3DrvHlp_PDMQueueCreate(PPDMDRVINS pDrvIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
     818                                                    PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue)
     819{
     820    PDMDRV_ASSERT_DRVINS(pDrvIns);
     821    LogFlow(("pdmR3DrvHlp_PDMQueueCreate: caller='%s'/%d: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p pszName=%p:{%s} ppQueue=%p\n",
     822             pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, cbItem, cItems, cMilliesInterval, pfnCallback, pszName, pszName, ppQueue, ppQueue));
     823    PVM pVM = pDrvIns->Internal.s.pVM;
     824    VM_ASSERT_EMT(pVM);
     825
     826    if (pDrvIns->iInstance > 0)
     827    {
     828        pszName = MMR3HeapAPrintf(pVM, MM_TAG_PDM_DRIVER_DESC, "%s-%u", pszName, pDrvIns->iInstance);
     829        AssertLogRelReturn(pszName, VERR_NO_MEMORY);
     830    }
     831
     832    int rc = PDMR3QueueCreateDriver(pVM, pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback, pszName, ppQueue);
    825833
    826834    LogFlow(("pdmR3DrvHlp_PDMQueueCreate: caller='%s'/%d: returns %Rrc *ppQueue=%p\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc, *ppQueue));
    827835    return rc;
    828 }
    829 
    830 
    831 /** @copydoc PDMDRVHLP::pfnPDMPollerRegister */
    832 static DECLCALLBACK(int) pdmR3DrvHlp_PDMPollerRegister(PPDMDRVINS pDrvIns, PFNPDMDRVPOLLER pfnPoller)
    833 {
    834     PDMDRV_ASSERT_DRVINS(pDrvIns);
    835     AssertLogRelMsgFailedReturn(("pdmR3DrvHlp_PDMPollerRegister: caller='%s'/%d: pfnPoller=%p -> VERR_NOT_SUPPORTED\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pfnPoller),
    836                                 VERR_NOT_SUPPORTED);
    837836}
    838837
     
    10631062    pdmR3DrvHlp_VMSetRuntimeErrorV,
    10641063    pdmR3DrvHlp_PDMQueueCreate,
    1065     pdmR3DrvHlp_PDMPollerRegister,
    10661064    pdmR3DrvHlp_TMGetVirtualFreq,
    10671065    pdmR3DrvHlp_TMGetVirtualTime,
  • trunk/src/VBox/VMM/PDMInternal.h

    r21188 r21363  
    700700    /** LIFO of pending items - GC. */
    701701    RCPTRTYPE(PPDMQUEUEITEMCORE) volatile pPendingRC;
     702
    702703    /** Item size (bytes). */
    703     RTUINT                          cbItem;
     704    uint32_t                        cbItem;
    704705    /** Number of items in the queue. */
    705     RTUINT                          cItems;
     706    uint32_t                        cItems;
    706707    /** Index to the free head (where we insert). */
    707708    uint32_t volatile               iFreeHead;
    708709    /** Index to the free tail (where we remove). */
    709710    uint32_t volatile               iFreeTail;
     711
     712    /** Unqiue queue name. */
     713    R3PTRTYPE(const char *)         pszName;
     714#if HC_ARCH_BITS == 32
     715    RTR3PTR                         Alignment1;
     716#endif
     717    /** Stat: Times PDMQueueAlloc fails. */
     718    STAMCOUNTER                     StatAllocFailures;
     719    /** Stat: PDMQueueInsert calls. */
     720    STAMCOUNTER                     StatInsert;
     721    /** Stat: Queue flushes. */
     722    STAMCOUNTER                     StatFlush;
     723    /** Stat: Queue flushes with pending items left over. */
     724    STAMCOUNTER                     StatFlushLeftovers;
     725#ifdef VBOX_WITH_STATISTICS
     726    /** State: Profiling the flushing. */
     727    STAMPROFILE                     StatFlushPrf;
     728#endif
    710729
    711730    /** Array of pointers to free items. Variable size. */
  • trunk/src/VBox/VMM/PDMQueue.cpp

    r21153 r21363  
    5757 *                              If 0 then the emulation thread will be notified whenever an item arrives.
    5858 * @param   fRZEnabled          Set if the queue will be used from RC/R0 and need to be allocated from the hyper heap.
     59 * @param   pszName             The queue name. Unique. Not copied.
    5960 * @param   ppQueue             Where to store the queue handle.
    6061 */
    61 static int pdmR3QueueCreate(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, bool fRZEnabled, PPDMQUEUE *ppQueue)
     62static int pdmR3QueueCreate(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, bool fRZEnabled,
     63                            const char *pszName, PPDMQUEUE *ppQueue)
    6264{
    6365    /*
     
    9597    pQueue->pVMR0 = fRZEnabled ? pVM->pVMR0 : NIL_RTR0PTR;
    9698    pQueue->pVMRC = fRZEnabled ? pVM->pVMRC : NIL_RTRCPTR;
     99    pQueue->pszName = pszName;
    97100    pQueue->cMilliesInterval = cMilliesInterval;
    98101    //pQueue->pTimer = NULL;
     
    174177    }
    175178
     179    /*
     180     * Register the statistics.
     181     */
     182    STAMR3RegisterF(pVM, &pQueue->cbItem,               STAMTYPE_U32,     STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES,        "Item size.",                       "/PDM/Queue/%s/cbItem",         pQueue->pszName);
     183    STAMR3RegisterF(pVM, &pQueue->cItems,               STAMTYPE_U32,     STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,        "Queue size.",                      "/PDM/Queue/%s/cItems",         pQueue->pszName);
     184    STAMR3RegisterF(pVM, &pQueue->StatAllocFailures,    STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,   "PDMQueueAlloc failures.",          "/PDM/Queue/%s/AllocFailures",  pQueue->pszName);
     185    STAMR3RegisterF(pVM, &pQueue->StatInsert,           STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS,        "Calls to PDMQueueInsert.",         "/PDM/Queue/%s/Insert",         pQueue->pszName);
     186    STAMR3RegisterF(pVM, &pQueue->StatFlush,            STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS,        "Calls to pdmR3QueueFlush.",        "/PDM/Queue/%s/Flush",          pQueue->pszName);
     187    STAMR3RegisterF(pVM, &pQueue->StatFlushLeftovers,   STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,   "Left over items after flush.",     "/PDM/Queue/%s/FlushLeftovers", pQueue->pszName);
     188#ifdef VBOX_WITH_STATISTICS
     189    STAMR3RegisterF(pVM, &pQueue->StatFlushPrf,         STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS,        "Profiling pdmR3QueueFlush.",       "/PDM/Queue/%s/FlushPrf",       pQueue->pszName);
     190#endif
     191
    176192    *ppQueue = pQueue;
    177193    return VINF_SUCCESS;
     
    191207 * @param   pfnCallback         The consumer function.
    192208 * @param   fRZEnabled          Set if the queue must be usable from RC/R0.
     209 * @param   pszName             The queue name. Unique. Not copied.
    193210 * @param   ppQueue             Where to store the queue handle on success.
    194211 * @thread  Emulation thread only.
    195212 */
    196213VMMR3DECL(int) PDMR3QueueCreateDevice(PVM pVM, PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
    197                                       PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, PPDMQUEUE *ppQueue)
    198 {
    199     LogFlow(("PDMR3QueueCreateDevice: pDevIns=%p cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p fRZEnabled=%RTbool\n",
     214                                      PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName, PPDMQUEUE *ppQueue)
     215{
     216    LogFlow(("PDMR3QueueCreateDevice: pDevIns=%p cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p fRZEnabled=%RTbool pszName=%s\n",
    200217             pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fRZEnabled));
    201218
     
    214231     */
    215232    PPDMQUEUE pQueue;
    216     int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, fRZEnabled, &pQueue);
     233    int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, fRZEnabled, pszName, &pQueue);
    217234    if (RT_SUCCESS(rc))
    218235    {
     
    240257 *                              If 0 then the emulation thread will be notified whenever an item arrives.
    241258 * @param   pfnCallback         The consumer function.
     259 * @param   pszName             The queue name. Unique. Not copied.
    242260 * @param   ppQueue             Where to store the queue handle on success.
    243261 * @thread  Emulation thread only.
    244262 */
    245263VMMR3DECL(int) PDMR3QueueCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
    246                                       PFNPDMQUEUEDRV pfnCallback, PPDMQUEUE *ppQueue)
    247 {
    248     LogFlow(("PDMR3QueueCreateDriver: pDrvIns=%p cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p\n",
    249              pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback));
     264                                      PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue)
     265{
     266    LogFlow(("PDMR3QueueCreateDriver: pDrvIns=%p cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p pszName=%s\n",
     267             pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback, pszName));
    250268
    251269    /*
     
    263281     */
    264282    PPDMQUEUE pQueue;
    265     int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, false, &pQueue);
     283    int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, false, pszName, &pQueue);
    266284    if (RT_SUCCESS(rc))
    267285    {
     
    289307 * @param   pfnCallback         The consumer function.
    290308 * @param   fRZEnabled          Set if the queue must be usable from RC/R0.
     309 * @param   pszName             The queue name. Unique. Not copied.
    291310 * @param   ppQueue             Where to store the queue handle on success.
    292311 * @thread  Emulation thread only.
    293312 */
    294313VMMR3DECL(int) PDMR3QueueCreateInternal(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
    295                                         PFNPDMQUEUEINT pfnCallback, bool fRZEnabled, PPDMQUEUE *ppQueue)
    296 {
    297     LogFlow(("PDMR3QueueCreateInternal: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p fRZEnabled=%RTbool\n",
    298              cbItem, cItems, cMilliesInterval, pfnCallback, fRZEnabled));
     314                                        PFNPDMQUEUEINT pfnCallback, bool fRZEnabled, const char *pszName, PPDMQUEUE *ppQueue)
     315{
     316    LogFlow(("PDMR3QueueCreateInternal: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p fRZEnabled=%RTbool pszName=%s\n",
     317             cbItem, cItems, cMilliesInterval, pfnCallback, fRZEnabled, pszName));
    299318
    300319    /*
     
    312331     */
    313332    PPDMQUEUE pQueue;
    314     int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, fRZEnabled, &pQueue);
     333    int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, fRZEnabled, pszName, &pQueue);
    315334    if (RT_SUCCESS(rc))
    316335    {
     
    337356 * @param   pfnCallback         The consumer function.
    338357 * @param   pvUser              The user argument to the consumer function.
     358 * @param   pszName             The queue name. Unique. Not copied.
    339359 * @param   ppQueue             Where to store the queue handle on success.
    340360 * @thread  Emulation thread only.
    341361 */
    342 VMMR3DECL(int) PDMR3QueueCreateExternal(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, PFNPDMQUEUEEXT pfnCallback, void *pvUser, PPDMQUEUE *ppQueue)
    343 {
    344     LogFlow(("PDMR3QueueCreateExternal: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p\n", cbItem, cItems, cMilliesInterval, pfnCallback));
     362VMMR3DECL(int) PDMR3QueueCreateExternal(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, PFNPDMQUEUEEXT pfnCallback, void *pvUser, const char *pszName, PPDMQUEUE *ppQueue)
     363{
     364    LogFlow(("PDMR3QueueCreateExternal: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p pszName=%s\n", cbItem, cItems, cMilliesInterval, pfnCallback, pszName));
    345365
    346366    /*
     
    358378     */
    359379    PPDMQUEUE pQueue;
    360     int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, false, &pQueue);
     380    int rc = pdmR3QueueCreate(pVM, cbItem, cItems, cMilliesInterval, false, pszName, &pQueue);
    361381    if (RT_SUCCESS(rc))
    362382    {
     
    438458    pQueue->pVMR3 = NULL;
    439459    pdmUnlock(pVM);
     460
     461    /*
     462     * Deregister statistics.
     463     */
     464    STAMR3Deregister(pVM, &pQueue->cbItem);
     465    STAMR3Deregister(pVM, &pQueue->cbItem);
     466    STAMR3Deregister(pVM, &pQueue->StatInsert);
     467    STAMR3Deregister(pVM, &pQueue->StatFlush);
     468    STAMR3Deregister(pVM, &pQueue->StatFlushLeftovers);
     469#ifdef VBOX_WITH_STATISTICS
     470    STAMR3Deregister(pVM, &pQueue->StatFlushPrf);
     471#endif
    440472
    441473    /*
     
    664696static bool pdmR3QueueFlush(PPDMQUEUE pQueue)
    665697{
     698    STAM_PROFILE_START(&pQueue->StatFlushPrf,p);
     699
    666700    /*
    667701     * Get the lists.
     
    804838            }
    805839        }
     840
     841        STAM_REL_COUNTER_INC(&pQueue->StatFlushLeftovers);
     842        STAM_PROFILE_STOP(&pQueue->StatFlushPrf,p);
    806843        return false;
    807844    }
    808845
     846    STAM_PROFILE_STOP(&pQueue->StatFlushPrf,p);
    809847    return true;
    810848}
  • trunk/src/VBox/VMM/VMMAll/PDMAllQueue.cpp

    r21128 r21363  
    5858        i = pQueue->iFreeTail;
    5959        if (i == pQueue->iFreeHead)
     60        {
     61            STAM_REL_COUNTER_INC(&pQueue->StatAllocFailures);
    6062            return NULL;
     63        }
    6164        pNew = pQueue->aFreeItems[i].CTX_SUFF(pItem);
    6265        iNext = (i + 1) % (pQueue->cItems + PDMQUEUE_FREE_SLACK);
     
    98101#endif
    99102    }
     103    STAM_REL_COUNTER_INC(&pQueue->StatInsert);
    100104}
    101105
  • trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp

    r20875 r21363  
    396396    GEN_CHECK_OFF(PDMQUEUE, iFreeHead);
    397397    GEN_CHECK_OFF(PDMQUEUE, iFreeTail);
     398    GEN_CHECK_OFF(PDMQUEUE, pszName);
     399    GEN_CHECK_OFF(PDMQUEUE, StatAllocFailures);
     400    GEN_CHECK_OFF(PDMQUEUE, StatInsert);
     401    GEN_CHECK_OFF(PDMQUEUE, StatFlush);
     402    GEN_CHECK_OFF(PDMQUEUE, StatFlushLeftovers);
    398403    GEN_CHECK_OFF(PDMQUEUE, aFreeItems);
    399404    GEN_CHECK_OFF(PDMQUEUE, aFreeItems[1]);
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