VirtualBox

Changeset 21363 in vbox for trunk


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
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/pdmdev.h

    r21217 r21363  
    22992299     *                              If 0 then the emulation thread will be notified whenever an item arrives.
    23002300     * @param   pfnCallback         The consumer function.
    2301      * @param   fGCEnabled          Set if the queue should work in GC too.
     2301     * @param   fRZEnabled          Set if the queue should work in RC and R0.
     2302     * @param   pszName             The queue base name. The instance number will be
     2303     *                              appended automatically.
    23022304     * @param   ppQueue             Where to store the queue handle on success.
    23032305     * @thread  The emulation thread.
    23042306     */
    23052307    DECLR3CALLBACKMEMBER(int, pfnPDMQueueCreate,(PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
    2306                                                  PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue));
     2308                                                 PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName, PPDMQUEUE *ppQueue));
    23072309
    23082310    /**
     
    28812883
    28822884/** Current PDMDEVHLP version number. */
    2883 #define PDM_DEVHLP_VERSION  0xf20a0000
     2885#define PDM_DEVHLP_VERSION  0xf20b0000
    28842886
    28852887
     
    35823584 */
    35833585DECLINLINE(int) PDMDevHlpPDMQueueCreate(PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
    3584                                         PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue)
    3585 {
    3586     return pDevIns->pDevHlpR3->pfnPDMQueueCreate(pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, ppQueue);
     3586                                        PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, const char *pszName, PPDMQUEUE *ppQueue)
     3587{
     3588    return pDevIns->pDevHlpR3->pfnPDMQueueCreate(pDevIns, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, pszName, ppQueue);
    35873589}
    35883590
  • trunk/include/VBox/pdmdrv.h

    r21217 r21363  
    482482     *                              If 0 then the emulation thread will be notified whenever an item arrives.
    483483     * @param   pfnCallback         The consumer function.
     484     * @param   pszName             The queue base name. The instance number will be
     485     *                              appended automatically.
    484486     * @param   ppQueue             Where to store the queue handle on success.
    485487     * @thread  The emulation thread.
    486488     */
    487     DECLR3CALLBACKMEMBER(int, pfnPDMQueueCreate,(PPDMDRVINS pDrvIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, PFNPDMQUEUEDRV pfnCallback, PPDMQUEUE *ppQueue));
    488 
    489     /**
    490      * Register a poller function.
    491      * TEMPORARY HACK FOR NETWORKING! DON'T USE!
    492      *
    493      * @returns VBox status code.
    494      * @param   pDrvIns             Driver instance.
    495      * @param   pfnPoller           The callback function.
    496      */
    497     DECLR3CALLBACKMEMBER(int, pfnPDMPollerRegister,(PPDMDRVINS pDrvIns, PFNPDMDRVPOLLER pfnPoller));
     489    DECLR3CALLBACKMEMBER(int, pfnPDMQueueCreate,(PPDMDRVINS pDrvIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
     490                                                 PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue));
    498491
    499492    /**
     
    710703
    711704/** Current DRVHLP version number. */
    712 #define PDM_DRVHLP_VERSION  0x90040000
     705#define PDM_DRVHLP_VERSION  0x90050000
    713706
    714707
     
    826819 */
    827820DECLINLINE(int) PDMDrvHlpPDMQueueCreate(PPDMDRVINS pDrvIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
    828                                         PFNPDMQUEUEDRV pfnCallback, PPDMQUEUE *ppQueue)
    829 {
    830     return pDrvIns->pDrvHlp->pfnPDMQueueCreate(pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback, ppQueue);
     821                                        PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue)
     822{
     823    return pDrvIns->pDrvHlp->pfnPDMQueueCreate(pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback, pszName, ppQueue);
    831824}
    832825
  • trunk/include/VBox/pdmqueue.h

    r21217 r21363  
    112112
    113113VMMR3DECL(int)  PDMR3QueueCreateDevice(PVM pVM, PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
    114                                        PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue);
     114                                       PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, const char *pszName, PPDMQUEUE *ppQueue);
    115115VMMR3DECL(int)  PDMR3QueueCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
    116                                        PFNPDMQUEUEDRV pfnCallback, PPDMQUEUE *ppQueue);
     116                                       PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue);
    117117VMMR3DECL(int)  PDMR3QueueCreateInternal(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
    118                                          PFNPDMQUEUEINT pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue);
     118                                         PFNPDMQUEUEINT pfnCallback, bool fGCEnabled, const char *pszName, PPDMQUEUE *ppQueue);
    119119VMMR3DECL(int)  PDMR3QueueCreateExternal(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
    120                                          PFNPDMQUEUEEXT pfnCallback, void *pvUser, PPDMQUEUE *ppQueue);
     120                                         PFNPDMQUEUEEXT pfnCallback, void *pvUser, const char *pszName, PPDMQUEUE *ppQueue);
    121121VMMR3DECL(int)  PDMR3QueueDestroy(PPDMQUEUE pQueue);
    122122VMMR3DECL(int)  PDMR3QueueDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
  • trunk/src/VBox/Devices/Input/DrvKeyboardQueue.cpp

    r15941 r21363  
    319319    }
    320320
    321     rc = PDMDrvHlpPDMQueueCreate(pDrvIns, sizeof(DRVKBDQUEUEITEM), cItems, cMilliesInterval, drvKbdQueueConsumer, &pDrv->pQueue);
     321    rc = PDMDrvHlpPDMQueueCreate(pDrvIns, sizeof(DRVKBDQUEUEITEM), cItems, cMilliesInterval, drvKbdQueueConsumer, "Keyboard", &pDrv->pQueue);
    322322    if (RT_FAILURE(rc))
    323323    {
  • trunk/src/VBox/Devices/Input/DrvMouseQueue.cpp

    r15941 r21363  
    305305    }
    306306
    307     rc = PDMDrvHlpPDMQueueCreate(pDrvIns, sizeof(DRVMOUSEQUEUEITEM), cItems, cMilliesInterval, drvMouseQueueConsumer, &pDrv->pQueue);
     307    rc = PDMDrvHlpPDMQueueCreate(pDrvIns, sizeof(DRVMOUSEQUEUEITEM), cItems, cMilliesInterval, drvMouseQueueConsumer, "Mouse", &pDrv->pQueue);
    308308    if (RT_FAILURE(rc))
    309309    {
  • trunk/src/VBox/Devices/Network/DevE1000.cpp

    r21188 r21363  
    48094809    /* Create transmit queue */
    48104810    rc = PDMDevHlpPDMQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 1, 0,
    4811                                  e1kTxQueueConsumer, true, &pState->pTxQueueR3);
     4811                                 e1kTxQueueConsumer, true, "E1000-Xmit", &pState->pTxQueueR3);
    48124812    if (RT_FAILURE(rc))
    48134813        return rc;
     
    48174817    /* Create the RX notifier signaller. */
    48184818    rc = PDMDevHlpPDMQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 1, 0,
    4819                                  e1kCanRxQueueConsumer, true, &pState->pCanRxQueueR3);
     4819                                 e1kCanRxQueueConsumer, true, "E1000-Rcv", &pState->pCanRxQueueR3);
    48204820    if (RT_FAILURE(rc))
    48214821        return rc;
  • trunk/src/VBox/Devices/Network/DevPCNet.cpp

    r21188 r21363  
    50845084     */
    50855085    rc = PDMDevHlpPDMQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 1, 0,
    5086                                  pcnetXmitQueueConsumer, true, &pThis->pXmitQueueR3);
     5086                                 pcnetXmitQueueConsumer, true, "PCNet-Xmit", &pThis->pXmitQueueR3);
    50875087    if (RT_FAILURE(rc))
    50885088        return rc;
     
    50945094     */
    50955095    rc = PDMDevHlpPDMQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 1, 0,
    5096                                  pcnetCanRxQueueConsumer, true, &pThis->pCanRxQueueR3);
     5096                                 pcnetCanRxQueueConsumer, true, "PCNet-Rcv", &pThis->pCanRxQueueR3);
    50975097    if (RT_FAILURE(rc))
    50985098        return rc;
  • trunk/src/VBox/Devices/Network/DrvNAT.cpp

    r21112 r21363  
    716716                fUDP = true;
    717717            else
    718                 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_INVALID_PARAMETER, RT_SRC_POS, 
    719                     N_("NAT#%d: Invalid configuration value for \"Protocol\": \"%s\""), 
     718                return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_INVALID_PARAMETER, RT_SRC_POS,
     719                    N_("NAT#%d: Invalid configuration value for \"Protocol\": \"%s\""),
    720720                    iInstance, szProtocol);
    721721        }
     
    742742                                       N_("NAT#%d: configuration error: failed to set up "
    743743                                       "redirection of %d to %d. Probably a conflict with "
    744                                        "existing services or other rules"), iInstance, iHostPort, 
     744                                       "existing services or other rules"), iInstance, iHostPort,
    745745                                       iGuestPort);
    746746    } /* for each redir rule */
     
    822822    bool fPassDomain = true;
    823823    GET_BOOL(rc, pThis, pCfgHandle, "PassDomain", fPassDomain);
    824    
     824
    825825    GET_STRING_ALLOC(rc, pThis, pCfgHandle, "TFTPPrefix", pThis->pszTFTPPrefix);
    826826    GET_STRING_ALLOC(rc, pThis, pCfgHandle, "BootFile", pThis->pszBootFile);
     
    833833     * Query the network port interface.
    834834     */
    835     pThis->pPort = 
    836                 (PPDMINETWORKPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, 
     835    pThis->pPort =
     836                (PPDMINETWORKPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase,
    837837                                                                      PDMINTERFACE_NETWORK_PORT);
    838838    if (!pThis->pPort)
     
    840840                                N_("Configuration error: the above device/driver didn't "
    841841                                "export the network port interface"));
    842     pThis->pConfig = 
    843                 (PPDMINETWORKCONFIG)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, 
     842    pThis->pConfig =
     843                (PPDMINETWORKCONFIG)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase,
    844844                                                                        PDMINTERFACE_NETWORK_CONFIG);
    845845    if (!pThis->pConfig)
     
    858858    if (RT_FAILURE(rc))
    859859        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: Configuration error: "
    860                                    "network '%s' describes not a valid IPv4 network"), 
     860                                   "network '%s' describes not a valid IPv4 network"),
    861861                                   pDrvIns->iInstance, szNetwork);
    862862
    863863    RTStrPrintf(szNetAddr, sizeof(szNetAddr), "%d.%d.%d.%d",
    864                (Network & 0xFF000000) >> 24, (Network & 0xFF0000) >> 16, 
     864               (Network & 0xFF000000) >> 24, (Network & 0xFF0000) >> 16,
    865865               (Network & 0xFF00) >> 8, Network & 0xFF);
    866866
     
    899899        slirp_register_statistics(pThis->pNATState, pDrvIns);
    900900#ifdef VBOX_WITH_STATISTICS
    901         PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatQueuePktSent,    STAMTYPE_COUNTER, 
     901        PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatQueuePktSent,    STAMTYPE_COUNTER,
    902902                              STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "counting packet sent viai "
    903903                              "PDM queue", "/Drivers/NAT%u/QueuePacketSent", pDrvIns->iInstance);
    904         PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatQueuePktDropped, STAMTYPE_COUNTER, 
    905                               STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "counting packet sent via PDM" 
     904        PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatQueuePktDropped, STAMTYPE_COUNTER,
     905                              STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "counting packet sent via PDM"
    906906                              " queue", "/Drivers/NAT%u/QueuePacketDropped", pDrvIns->iInstance);
    907907#endif
     
    925925            }
    926926
    927             rc = PDMDrvHlpPDMQueueCreate(pDrvIns, sizeof(DRVNATQUEUITEM), 50, 0, 
    928                                          drvNATQueueConsumer, &pThis->pSendQueue);
     927            rc = PDMDrvHlpPDMQueueCreate(pDrvIns, sizeof(DRVNATQUEUITEM), 50, 0,
     928                                         drvNATQueueConsumer, "NAT", &pThis->pSendQueue);
    929929            if (RT_FAILURE(rc))
    930930            {
     
    948948#else
    949949            pThis->hWakeupEvent = CreateEvent(NULL, FALSE, FALSE, NULL); /* auto-reset event */
    950             slirp_register_external_event(pThis->pNATState, pThis->hWakeupEvent, 
     950            slirp_register_external_event(pThis->pNATState, pThis->hWakeupEvent,
    951951                                          VBOX_WAKEUP_EVENT_INDEX);
    952952#endif
    953953
    954             rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pThread, pThis, drvNATAsyncIoThread, 
     954            rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pThread, pThis, drvNATAsyncIoThread,
    955955                                          drvNATAsyncIoWakeup, 128 * _1K, RTTHREADTYPE_IO, "NAT");
    956956            AssertReleaseRC(rc);
    957957
    958958#ifdef VBOX_WITH_SLIRP_MT
    959             rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pGuestThread, pThis, drvNATAsyncIoGuest, 
     959            rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pGuestThread, pThis, drvNATAsyncIoGuest,
    960960                                          drvNATAsyncIoGuestWakeup, 128 * _1K, RTTHREADTYPE_IO, "NATGUEST");
    961961            AssertReleaseRC(rc);
  • trunk/src/VBox/Devices/Storage/DevAHCI.cpp

    r21321 r21363  
    62456245     */
    62466246    rc = PDMDevHlpPDMQueueCreate(pDevIns, sizeof(DEVPORTNOTIFIERQUEUEITEM), 30*32 /*Maximum of 30 ports multiplied with 32 tasks each port*/, 0,
    6247                                  ahciNotifyQueueConsumer, true, &pThis->pNotifierQueueR3);
     6247                                 ahciNotifyQueueConsumer, true, "AHCI-Xmit", &pThis->pNotifierQueueR3);
    62486248    if (RT_FAILURE(rc))
    62496249        return rc;
  • trunk/src/VBox/Devices/Storage/DevBusLogic.cpp

    r21321 r21363  
    27552755    /* Intialize task queue. */
    27562756    rc = PDMDevHlpPDMQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 5, 0,
    2757                                  buslogicNotifyQueueConsumer, true, &pThis->pNotifierQueueR3);
     2757                                 buslogicNotifyQueueConsumer, true, "BugLogicTask", &pThis->pNotifierQueueR3);
    27582758    if (RT_FAILURE(rc))
    27592759        return rc;
  • trunk/src/VBox/Devices/Storage/DevLsiLogicSCSI.cpp

    r21321 r21363  
    53005300    /* Intialize task queue. */
    53015301    rc = PDMDevHlpPDMQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 2, 0,
    5302                                  lsilogicNotifyQueueConsumer, true, &pThis->pNotificationQueueR3);
     5302                                 lsilogicNotifyQueueConsumer, true, "LsiLogic-Task", &pThis->pNotificationQueueR3);
    53035303    if (RT_FAILURE(rc))
    53045304        return rc;
  • 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