VirtualBox

Changeset 83603 in vbox for trunk/src


Ignore:
Timestamp:
Apr 7, 2020 9:43:23 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137006
Message:

Virtio_1_0: Added some descriptor chain stats to see that we don't leak any. bugref:9440

Location:
trunk/src/VBox/Devices
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DevVirtioNet_1_0.cpp

    r83593 r83603  
    14501450        AssertMsgReturnStmt(rc == VINF_SUCCESS && pDescChain->cbPhysReturn,
    14511451                            ("Not enough Rx buffers in queue to accomodate ethernet packet\n"),
    1452                             virtioCoreR3DescChainRelease(pDescChain),
     1452                            virtioCoreR3DescChainRelease(&pThis->Virtio, pDescChain),
    14531453                            VERR_INTERNAL_ERROR);
    14541454
     
    14581458        AssertMsgReturnStmt(pDescChain->pSgPhysReturn->paSegs[0].cbSeg >= sizeof(VIRTIONET_PKT_HDR_T),
    14591459                            ("Desc chain's first seg has insufficient space for pkt header!\n"),
    1460                             virtioCoreR3DescChainRelease(pDescChain),
     1460                            virtioCoreR3DescChainRelease(&pThis->Virtio, pDescChain),
    14611461                            VERR_INTERNAL_ERROR);
    14621462
     
    15071507        }
    15081508
    1509         virtioCoreR3DescChainRelease(pDescChain);
     1509        virtioCoreR3DescChainRelease(&pThis->Virtio, pDescChain);
    15101510    }
    15111511
     
    20792079        {
    20802080            LogFunc(("%s failed to find expected data on %s, rc = %Rrc\n", INSTANCE(pThis), VIRTQNAME(idxQueue), rc));
    2081             virtioCoreR3DescChainRelease(pDescChain);
     2081            virtioCoreR3DescChainRelease(pVirtio, pDescChain);
    20822082            break;
    20832083        }
     
    21512151                Log4Func(("Failed to allocate S/G buffer: size=%u rc=%Rrc\n", uSize, rc));
    21522152                /* Stop trying to fetch TX descriptors until we get more bandwidth. */
    2153                 virtioCoreR3DescChainRelease(pDescChain);
     2153                virtioCoreR3DescChainRelease(pVirtio, pDescChain);
    21542154                break;
    21552155            }
     
    21642164        }
    21652165
    2166         virtioCoreR3DescChainRelease(pDescChain);
     2166        virtioCoreR3DescChainRelease(pVirtio, pDescChain);
    21672167        pDescChain = NULL;
    21682168    }
     
    22882288                 }
    22892289                 virtioNetR3Ctrl(pDevIns, pThis, pThisCC, pDescChain);
    2290                  virtioCoreR3DescChainRelease(pDescChain);
     2290                 virtioCoreR3DescChainRelease(&pThis->Virtio, pDescChain);
    22912291             }
    22922292             else if (IS_TX_QUEUE(idxQueue))
  • trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp

    r83594 r83603  
    368368    /** The ring-3 device instance so we can easily get our bearings. */
    369369    PPDMDEVINSR3                    pDevIns;
    370     PPDMDEVINSRC                    pDevInsRC;
    371     PPDMDEVINSR0                    pDevInsR0;
    372370
    373371    /** Pointer to attached driver's base interface. */
     
    742740    virtioCoreR3QueuePut(pDevIns, &pThis->Virtio, EVENTQ_IDX, &ReqSgBuf, pDescChain, true /*fFence*/);
    743741    virtioCoreQueueSync(pDevIns, &pThis->Virtio, EVENTQ_IDX);
    744     virtioCoreR3DescChainRelease(pDescChain);
     742    virtioCoreR3DescChainRelease(&pThis->Virtio, pDescChain);
    745743
    746744    return VINF_SUCCESS;
     
    750748static void virtioScsiR3FreeReq(PVIRTIOSCSITARGET pTarget, PVIRTIOSCSIREQ pReq)
    751749{
     750    PVIRTIOSCSI pThis = PDMDEVINS_2_DATA(pTarget->pDevIns, PVIRTIOSCSI);
    752751    RTMemFree(pReq->pbSense);
    753752    pReq->pbSense = NULL;
    754     virtioCoreR3DescChainRelease(pReq->pDescChain);
     753    virtioCoreR3DescChainRelease(&pThis->Virtio, pReq->pDescChain);
    755754    pReq->pDescChain = NULL;
    756755    pTarget->pDrvMediaEx->pfnIoReqFree(pTarget->pDrvMediaEx, pReq->hIoReq);
     
    15601559                      LogRel(("Error submitting req packet, resetting %Rrc", rc));
    15611560
    1562                   virtioCoreR3DescChainRelease(pDescChain);
     1561                  virtioCoreR3DescChainRelease(&pThis->Virtio, pDescChain);
    15631562             }
    15641563             pWorkerR3->cRedoDescs = 0;
     
    15831582             }
    15841583
    1585              virtioCoreR3DescChainRelease(pDescChain);
     1584             virtioCoreR3DescChainRelease(&pThis->Virtio, pDescChain);
    15861585        }
    15871586    }
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp

    r83587 r83603  
    693693        pDescChain->pSgPhysReturn = &pDescChain->SgBufIn;
    694694        pDescChain->cbPhysReturn  = cbIn;
     695        STAM_REL_COUNTER_ADD(&pVirtio->StatDescChainsSegsIn, cSegsIn);
    695696    }
    696697
     
    700701        pDescChain->pSgPhysSend   = &pDescChain->SgBufOut;
    701702        pDescChain->cbPhysSend    = cbOut;
    702     }
    703 
     703        STAM_REL_COUNTER_ADD(&pVirtio->StatDescChainsSegsOut, cSegsOut);
     704    }
     705
     706    STAM_REL_COUNTER_INC(&pVirtio->StatDescChainsAllocated);
    704707    Log6Func(("%s -- segs OUT: %u (%u bytes)   IN: %u (%u bytes) --\n", pVirtq->szVirtqName, cSegsOut, cbOut, cSegsIn, cbIn));
    705708
     
    731734 * @returns New reference count.
    732735 * @retval  0 if freed or invalid parameter.
     736 * @param   pVirtio         Pointer to the shared virtio state.
    733737 * @param   pDescChain      The descriptor chain to reference.  NULL is quietly
    734738 *                          ignored (returns 0).
    735739 */
    736 uint32_t virtioCoreR3DescChainRelease(PVIRTIO_DESC_CHAIN_T pDescChain)
     740uint32_t virtioCoreR3DescChainRelease(PVIRTIOCORE pVirtio, PVIRTIO_DESC_CHAIN_T pDescChain)
    737741{
    738742    if (!pDescChain)
     
    746750        pDescChain->u32Magic = ~VIRTIO_DESC_CHAIN_MAGIC;
    747751        RTMemFree(pDescChain);
     752        STAM_REL_COUNTER_INC(&pVirtio->StatDescChainsFreed);
    748753    }
    749754    return cRefs;
     
    21032108    AssertLogRelRCReturn(rc, PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio: cannot register PCI Capabilities address space")));
    21042109
    2105     return rc;
     2110    /*
     2111     * Statistics.
     2112     */
     2113    PDMDevHlpSTAMRegisterF(pDevIns, &pVirtio->StatDescChainsAllocated,  STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     2114                           "Total number of allocated descriptor chains",   "DescChainsAllocated");
     2115    PDMDevHlpSTAMRegisterF(pDevIns, &pVirtio->StatDescChainsFreed,      STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     2116                           "Total number of freed descriptor chains",       "DescChainsFreed");
     2117    PDMDevHlpSTAMRegisterF(pDevIns, &pVirtio->StatDescChainsSegsIn,     STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     2118                           "Total number of inbound segments",              "DescChainsSegsIn");
     2119    PDMDevHlpSTAMRegisterF(pDevIns, &pVirtio->StatDescChainsSegsOut,    STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     2120                           "Total number of outbound segments",             "DescChainsSegsOut");
     2121
     2122    return VINF_SUCCESS;
    21062123}
    21072124
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.h

    r83587 r83603  
    288288    /** The MMIO handle for the PCI capability region (\#2). */
    289289    IOMMMIOHANDLE               hMmioPciCap;
     290
     291    /** @name Statistics
     292     * @{ */
     293    STAMCOUNTER                 StatDescChainsAllocated;
     294    STAMCOUNTER                 StatDescChainsFreed;
     295    STAMCOUNTER                 StatDescChainsSegsIn;
     296    STAMCOUNTER                 StatDescChainsSegsOut;
     297    /** @} */
    290298} VIRTIOCORE;
    291299
     
    397405                             uint16_t uHeadIdx, PPVIRTIO_DESC_CHAIN_T ppDescChain);
    398406uint32_t virtioCoreR3DescChainRetain(PVIRTIO_DESC_CHAIN_T pDescChain);
    399 uint32_t virtioCoreR3DescChainRelease(PVIRTIO_DESC_CHAIN_T pDescChain);
     407uint32_t virtioCoreR3DescChainRelease(PVIRTIOCORE pVirtio, PVIRTIO_DESC_CHAIN_T pDescChain);
    400408
    401409int  virtioCoreR3QueuePeek(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue,
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