VirtualBox

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


Ignore:
Timestamp:
Oct 10, 2007 6:02:16 PM (17 years ago)
Author:
vboxsync
Message:

Added a request for resetting GVMM stats. not hooked up to STAM yet.

Location:
trunk/src/VBox/VMM/VMMR0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/GVMMR0.cpp

    r5232 r5233  
    14671467}
    14681468
     1469
     1470/**
     1471 * Resets the specified GVMM statistics.
     1472 *
     1473 * @returns VBox status code.
     1474 *
     1475 * @param   pStats      Which statistics to reset, that is, non-zero fields indicates which to reset.
     1476 * @param   pSession    The current session.
     1477 * @param   pVM         The VM to reset statistics for. Optional.
     1478 */
     1479GVMMR0DECL(int) GVMMR0ResetStatistics(PCGVMMSTATS pStats, PSUPDRVSESSION pSession, PVM pVM)
     1480{
     1481    LogFlow(("GVMMR0ResetStatistics: pStats=%p pSession=%p pVM=%p\n", pStats, pSession, pVM));
     1482
     1483    /*
     1484     * Validate input.
     1485     */
     1486    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
     1487    AssertPtrReturn(pStats, VERR_INVALID_POINTER);
     1488
     1489    /*
     1490     * Take the lock and get the VM statistics.
     1491     */
     1492    PGVMM pGVMM;
     1493    if (pVM)
     1494    {
     1495        PGVM pGVM;
     1496        int rc = gvmmR0ByVM(pVM, &pGVM, &pGVMM, true /*fTakeUsedLock*/);
     1497        if (RT_FAILURE(rc))
     1498            return rc;
     1499#       define MAYBE_RESET_FIELD(field) \
     1500            do { if (pStats->SchedVM. field ) { pGVM->gvmm.s.StatsSched. field = 0; } } while (0)
     1501        MAYBE_RESET_FIELD(cHaltCalls);
     1502        MAYBE_RESET_FIELD(cHaltBlocking);
     1503        MAYBE_RESET_FIELD(cHaltTimeouts);
     1504        MAYBE_RESET_FIELD(cHaltNotBlocking);
     1505        MAYBE_RESET_FIELD(cHaltWakeUps);
     1506        MAYBE_RESET_FIELD(cWakeUpCalls);
     1507        MAYBE_RESET_FIELD(cWakeUpNotHalted);
     1508        MAYBE_RESET_FIELD(cWakeUpWakeUps);
     1509        MAYBE_RESET_FIELD(cPollCalls);
     1510        MAYBE_RESET_FIELD(cPollHalts);
     1511        MAYBE_RESET_FIELD(cPollWakeUps);
     1512#       undef MAYBE_RESET_FIELD
     1513    }
     1514    else
     1515    {
     1516        GVMM_GET_VALID_INSTANCE(pGVMM, VERR_INTERNAL_ERROR);
     1517
     1518        int rc = RTSemFastMutexRequest(pGVMM->UsedLock);
     1519        AssertRCReturn(rc, rc);
     1520    }
     1521
     1522    /*
     1523     * Enumerate the VMs and add the ones visibile to the statistics.
     1524     */
     1525    if (ASMMemIsAll8(&pStats->SchedSum, sizeof(pStats->SchedSum), 0))
     1526    {
     1527        for (unsigned i = pGVMM->iUsedHead;
     1528             i != NIL_GVM_HANDLE && i < RT_ELEMENTS(pGVMM->aHandles);
     1529             i = pGVMM->aHandles[i].iNext)
     1530        {
     1531            PGVM pGVM = pGVMM->aHandles[i].pGVM;
     1532            void *pvObj = pGVMM->aHandles[i].pvObj;
     1533            if (    VALID_PTR(pvObj)
     1534                &&  VALID_PTR(pGVM)
     1535                &&  pGVM->u32Magic == GVM_MAGIC
     1536                &&  RT_SUCCESS(SUPR0ObjVerifyAccess(pvObj, pSession, NULL)))
     1537            {
     1538#               define MAYBE_RESET_FIELD(field) \
     1539                    do { if (pStats->SchedSum. field ) { pGVM->gvmm.s.StatsSched. field = 0; } } while (0)
     1540                MAYBE_RESET_FIELD(cHaltCalls);
     1541                MAYBE_RESET_FIELD(cHaltBlocking);
     1542                MAYBE_RESET_FIELD(cHaltTimeouts);
     1543                MAYBE_RESET_FIELD(cHaltNotBlocking);
     1544                MAYBE_RESET_FIELD(cHaltWakeUps);
     1545                MAYBE_RESET_FIELD(cWakeUpCalls);
     1546                MAYBE_RESET_FIELD(cWakeUpNotHalted);
     1547                MAYBE_RESET_FIELD(cWakeUpWakeUps);
     1548                MAYBE_RESET_FIELD(cPollCalls);
     1549                MAYBE_RESET_FIELD(cPollHalts);
     1550                MAYBE_RESET_FIELD(cPollWakeUps);
     1551#               undef MAYBE_RESET_FIELD
     1552            }
     1553        }
     1554    }
     1555
     1556    RTSemFastMutexRelease(pGVMM->UsedLock);
     1557
     1558    return VINF_SUCCESS;
     1559}
     1560
     1561
     1562/**
     1563 * VMMR0 request wrapper for GVMMR0ResetStatistics.
     1564 *
     1565 * @returns see GVMMR0ResetStatistics.
     1566 * @param   pVM             Pointer to the shared VM structure. Optional.
     1567 * @param   pReq            The request packet.
     1568 */
     1569GVMMR0DECL(int) GVMMR0ResetStatisticsReq(PVM pVM, PGVMMRESETSTATISTICSSREQ pReq)
     1570{
     1571    /*
     1572     * Validate input and pass it on.
     1573     */
     1574    AssertPtrReturn(pReq, VERR_INVALID_POINTER);
     1575    AssertMsgReturn(pReq->Hdr.cbReq == sizeof(*pReq), ("%#x != %#x\n", pReq->Hdr.cbReq, sizeof(*pReq)), VERR_INVALID_PARAMETER);
     1576
     1577    return GVMMR0ResetStatistics(&pReq->Stats, pReq->pSession, pVM);
     1578}
     1579
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r5211 r5233  
    714714            return GVMMR0QueryStatisticsReq(pVM, (PGVMMQUERYSTATISTICSSREQ)pReqHdr);
    715715
     716        case VMMR0_DO_GVMM_RESET_STATISTICS:
     717            if (u64Arg)
     718                return VERR_INVALID_PARAMETER;
     719            return GVMMR0QueryStatisticsReq(pVM, (PGVMMQUERYSTATISTICSSREQ)pReqHdr);
     720
    716721        /*
    717722         * Initialize the R0 part of a VM instance.
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