VirtualBox

Changeset 5233

Show
Ignore:
Timestamp:
10/10/07 20:02:16 (1 year ago)
Author:
vboxsync
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/VBox/gvmm.h

    r5211 r5233  
    100100/** Pointer to the GVMM statistics. */ 
    101101typedef GVMMSTATS *PGVMMSTATS; 
     102/** Const pointer to the GVMM statistics. */ 
     103typedef const GVMMSTATS *PCGVMMSTATS; 
    102104 
    103105 
     
    120122GVMMR0DECL(int)     GVMMR0SchedPoll(PVM pVM, bool fYield); 
    121123GVMMR0DECL(int)     GVMMR0QueryStatistics(PGVMMSTATS pStats, PSUPDRVSESSION pSession, PVM pVM); 
     124GVMMR0DECL(int)     GVMMR0ResetStatistics(PCGVMMSTATS pStats, PSUPDRVSESSION pSession, PVM pVM); 
    122125 
    123126 
     
    155158    GVMMSTATS       Stats; 
    156159} GVMMQUERYSTATISTICSSREQ; 
    157 /** Pointer to a GMMR0AllocatePagesReq / VMMR0_DO_GMM_ALLOCATE_PAGES request buffer. */ 
     160/** Pointer to a GVMMR0QueryStatisticsReq / VMMR0_DO_GVMM_QUERY_STATISTICS request buffer. */ 
    158161typedef GVMMQUERYSTATISTICSSREQ *PGVMMQUERYSTATISTICSSREQ; 
    159162 
    160163GVMMR0DECL(int)     GVMMR0QueryStatisticsReq(PVM pVM, PGVMMQUERYSTATISTICSSREQ pReq); 
    161164 
     165 
     166/** 
     167 * Request buffer for GVMMR0ResetStatisticsReq / VMMR0_DO_GVMM_RESET_STATISTICS. 
     168 * @see GVMMR0ResetStatistics. 
     169 */ 
     170typedef struct GVMMRESETSTATISTICSSREQ 
     171{ 
     172    /** The header. */ 
     173    SUPVMMR0REQHDR  Hdr; 
     174    /** The support driver session. */ 
     175    PSUPDRVSESSION  pSession; 
     176    /** The statistics to reset. 
     177     * Any non-zero entry will be reset (if permitted). */ 
     178    GVMMSTATS       Stats; 
     179} GVMMRESETSTATISTICSSREQ; 
     180/** Pointer to a GVMMR0ResetStatisticsReq / VMMR0_DO_GVMM_RESET_STATISTICS request buffer. */ 
     181typedef GVMMRESETSTATISTICSSREQ *PGVMMRESETSTATISTICSSREQ; 
     182 
     183GVMMR0DECL(int)     GVMMR0ResetStatisticsReq(PVM pVM, PGVMMRESETSTATISTICSSREQ pReq); 
    162184 
    163185 
  • trunk/include/VBox/vmm.h

    r5211 r5233  
    368368    /** Call GVMMR0QueryStatistics(). */ 
    369369    VMMR0_DO_GVMM_QUERY_STATISTICS, 
     370    /** Call GVMMR0ResetStatistics(). */ 
     371    VMMR0_DO_GVMM_RESET_STATISTICS, 
    370372 
    371373    /** Call VMMR0 Per VM Init. */ 
  • trunk/include/iprt/asm.h

    r4473 r5233  
    15041504/** 
    15051505 * Compiler memory barrier. 
    1506  *  
    1507  * Ensure that the compiler does not use any cached (register/tmp stack) memory  
     1506 * 
     1507 * Ensure that the compiler does not use any cached (register/tmp stack) memory 
    15081508 * values or any outstanding writes when returning from this function. 
    1509  *  
    1510  * This function must be used if non-volatile data is modified by a  
    1511  * device or the VMM. Typical cases are port access, MMIO access,  
     1509 * 
     1510 * This function must be used if non-volatile data is modified by a 
     1511 * device or the VMM. Typical cases are port access, MMIO access, 
    15121512 * trapping instruction, etc. 
    15131513 */ 
     
    15191519DECLINLINE(void) ASMCompilerBarrier(void) 
    15201520{ 
    1521     __asm  
    1522     { 
    1523     } 
    1524 } 
    1525 #endif  
     1521    __asm 
     1522    { 
     1523    } 
     1524} 
     1525#endif 
    15261526 
    15271527 
     
    17821782#else 
    17831783    return (bool)ASMAtomicXchgU8((volatile uint8_t *)pf, (uint8_t)f); 
    1784 #endif  
     1784#endif 
    17851785} 
    17861786 
     
    27702770 
    27712771 
     2772/** 
     2773 * Checks if a memory block is filled with the specified byte. 
     2774 * 
     2775 * This is a sort of inverted memchr. 
     2776 * 
     2777 * @returns Pointer to the byte which doesn't equal u8. 
     2778 * @returns NULL if all equal to u8. 
     2779 * 
     2780 * @param   pv      Pointer to the memory block. 
     2781 * @param   cb      Number of bytes in the block. This MUST be aligned on 32-bit! 
     2782 * @param   u8      The value it's supposed to be filled with. 
     2783 */ 
     2784#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN 
     2785DECLASM(void *) ASMMemIsAll8(void const *pv, size_t cb, uint8_t u8); 
     2786#else 
     2787DECLINLINE(void *) ASMMemIsAll8(void const *pv, size_t cb, uint8_t u8) 
     2788{ 
     2789/** @todo rewrite this in inline assembly. */ 
     2790    uint8_t const *pb = (uint8_t const *)pv; 
     2791    for (; cb; cb--, pb++) 
     2792        if (RT_UNLIKELY(*pb != u8)) 
     2793            return (void *)pb; 
     2794    return NULL; 
     2795} 
     2796#endif 
     2797 
     2798 
    27722799 
    27732800/** 
     
    29122939 * @note    Don't use 64-bit C arithmetic here since some gcc compilers generate references to 
    29132940 *          __udivdi3 and __umoddi3 even if this inline function is not used. 
    2914  *  
     2941 * 
    29152942 * @returns (u64A * u32B) / u32C. 
    29162943 * @param   u64A    The 64-bit value. 
     
    29282955    __asm__ __volatile__("mulq %2\n\t" 
    29292956                         "divq %3\n\t" 
    2930                          : "=a" (u64Result),  
     2957                         : "=a" (u64Result), 
    29312958                           "=d" (u64Spill) 
    29322959                         : "r" ((uint64_t)u32B), 
    29332960                           "r" ((uint64_t)u32C), 
    2934                            "0" (u64A),  
     2961                           "0" (u64A), 
    29352962                           "1" (0)); 
    29362963    return u64Result; 
     
    29722999    u.s.Lo = (uint32_t)((((u64Hi % u32C) << 32) + (u64Lo & 0xffffffff)) / u32C); 
    29733000    return u.u; 
    2974 # endif  
    2975 } 
    2976 #endif  
     3001# endif 
     3002} 
     3003#endif 
    29773004 
    29783005 
  • 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. 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy