Changeset 44992 in vbox for trunk/src/VBox
- Timestamp:
- Mar 11, 2013 3:41:01 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 84215
- Location:
- trunk/src/VBox/Additions/common
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp
r44328 r44992 37 37 # include <VBox/HostServices/GuestPropertySvc.h> 38 38 #endif 39 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER 40 # include <VBox/VBoxGuest.h> 41 # include "../VBoxGuestLib/VBGLR3Internal.h" /* HACK ALERT! Using vbglR3DoIOCtl directly!! */ 42 #endif 43 39 44 40 45 /******************************************************************************* … … 101 106 RTPrintf("\n"); 102 107 103 /* Exclude the Windows bits from the test version. Anyone who needs to test 104 *them can fix this. */108 /* Exclude the Windows bits from the test version. Anyone who needs to 109 test them can fix this. */ 105 110 #if defined(RT_OS_WINDOWS) && !defined(VBOX_CONTROL_TEST) 106 111 if (eWhich == GET_VIDEO_ACCEL || eWhich == USAGE_ALL) … … 1478 1483 #endif 1479 1484 1485 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER 1486 /** 1487 * @callback_method_impl{FNVBOXCTRLCMDHANDLER, Command: help} 1488 */ 1489 static RTEXITCODE handleDpc(int argc, char *argv[]) 1490 { 1491 # ifndef VBOX_CONTROL_TEST 1492 int rc; 1493 for (int i = 0; i < 30; i++) 1494 { 1495 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_DPC_LATENCY_CHECKER, NULL, 0); 1496 if (RT_FAILURE(rc)) 1497 break; 1498 RTPrintf("%d\n", i); 1499 } 1500 # else 1501 int rc = VERR_NOT_IMPLEMENTED; 1502 # endif 1503 if (RT_FAILURE(rc)) 1504 return VBoxControlError("Error. rc=%Rrc\n", rc); 1505 RTPrintf("Samples collection completed.\n"); 1506 return RTEXITCODE_SUCCESS; 1507 } 1508 #endif /* VBOX_WITH_DPC_LATENCY_CHECKER */ 1509 1510 1480 1511 /** 1481 1512 * @callback_method_impl{FNVBOXCTRLCMDHANDLER, Command: takesnapshot} … … 1535 1566 } 1536 1567 1537 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER1538 #include "..\VBoxGuestLib\VBGLR3Internal.h"1539 1540 static RTEXITCODE handleDpc(int argc, char *argv[])1541 {1542 #ifndef VBOX_CONTROL_TEST1543 int rc = VINF_SUCCESS;1544 int i;1545 for (i = 0; i < 30; i++)1546 {1547 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_DPC, NULL, 0);1548 if (RT_FAILURE(rc))1549 {1550 break;1551 }1552 RTPrintf("%d\n", i);1553 }1554 #else1555 int rc = VERR_NOT_IMPLEMENTED;1556 #endif1557 if (RT_SUCCESS(rc))1558 {1559 RTPrintf("Samples collection completed.\n");1560 return RTEXITCODE_SUCCESS;1561 }1562 else1563 {1564 VBoxControlError("Error. rc=%Rrc\n", rc);1565 return RTEXITCODE_FAILURE;1566 }1567 }1568 #endif /* VBOX_WITH_DPC_LATENCY_CHECKER */1569 1568 1570 1569 /** command handler type */ … … 1595 1594 #if !defined(VBOX_CONTROL_TEST) 1596 1595 { "writecoredump", handleWriteCoreDump }, 1596 #endif 1597 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER 1598 { "dpc", handleDpc }, 1597 1599 #endif 1598 1600 { "takesnapshot", handleTakeSnapshot }, … … 1604 1606 { "getversion", handleVersion }, 1605 1607 { "version", handleVersion }, 1606 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER1607 { "dpc", handleDpc },1608 #endif /* VBOX_WITH_DPC_LATENCY_CHECKER */1609 1608 { "help", handleHelp } 1610 1609 }; -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp
r44991 r44992 1401 1401 */ 1402 1402 1403 # pragma pack(1) /** @todo r=bird: Not needed for DPCSAMPLE, screwes up member alignment in DPCDATA! */ 1403 /** 1404 * One DPC latency sample. 1405 */ 1404 1406 typedef struct DPCSAMPLE 1405 1407 { … … 1409 1411 uint64_t u64TSC; 1410 1412 } DPCSAMPLE; 1411 1413 AssertCompileSize(DPCSAMPLE, 4*8); 1414 1415 /** 1416 * The DPC latency measurement workset. 1417 */ 1412 1418 typedef struct DPCDATA 1413 1419 { … … 1418 1424 ULONG ulTimerRes; 1419 1425 1420 BOOLEAN fFinished; 1421 1426 bool volatile fFinished; 1427 1428 /** The timer interval (relative). */ 1422 1429 LARGE_INTEGER DueTime; 1423 1430 1424 1431 LARGE_INTEGER PerfCounterPrev; 1432 1433 /** Align the sample array on a 64 byte boundrary just for the off chance 1434 * that we'll get cache line aligned memory backing this structure. */ 1435 uint32_t auPadding[ARCH_BITS == 32 ? 5 : 7]; 1425 1436 1426 1437 int cSamples; 1427 1438 DPCSAMPLE aSamples[8192]; 1428 1439 } DPCDATA; 1429 # pragma pack(1) 1440 1441 AssertCompileMemberAlignment(DPCDATA, aSamples, 64); 1430 1442 1431 1443 # define VBOXGUEST_DPC_TAG 'DPCS' 1432 1444 1433 static VOID DPCDeferredRoutine(struct _KDPC *Dpc, 1434 PVOID DeferredContext, 1435 PVOID SystemArgument1, 1436 PVOID SystemArgument2) 1437 { 1438 DPCDATA *pData = (DPCDATA *)DeferredContext; 1445 1446 /** 1447 * DPC callback routine for the DPC latency measurement code. 1448 * 1449 * @param pDpc The DPC, not used. 1450 * @param pvDeferredContext Pointer to the DPCDATA. 1451 * @param SystemArgument1 System use, ignored. 1452 * @param SystemArgument2 System use, ignored. 1453 */ 1454 static VOID vbgdNtDpcLatencyCallback(PKDPC pDpc, PVOID pvDeferredContext, PVOID SystemArgument1, PVOID SystemArgument2) 1455 { 1456 DPCDATA *pData = (DPCDATA *)pvDeferredContext; 1439 1457 1440 1458 KeAcquireSpinLockAtDpcLevel(&pData->SpinLock); 1441 1459 1442 1460 if (pData->cSamples >= RT_ELEMENTS(pData->aSamples)) 1443 { 1444 pData->fFinished = 1; 1445 KeReleaseSpinLockFromDpcLevel(&pData->SpinLock); 1446 return; 1447 } 1448 1449 DPCSAMPLE *pSample = &pData->aSamples[pData->cSamples++]; 1450 1451 pSample->u64TSC = ASMReadTSC(); 1452 pSample->PerfCounter = KeQueryPerformanceCounter(&pSample->PerfFrequency); 1453 pSample->PerfDelta.QuadPart = pSample->PerfCounter.QuadPart - pData->PerfCounterPrev.QuadPart; 1454 1455 pData->PerfCounterPrev.QuadPart = pSample->PerfCounter.QuadPart; 1456 1457 KeSetTimer(&pData->Timer, pData->DueTime, &pData->Dpc); 1461 pData->fFinished = true; 1462 else 1463 { 1464 DPCSAMPLE *pSample = &pData->aSamples[pData->cSamples++]; 1465 1466 pSample->u64TSC = ASMReadTSC(); 1467 pSample->PerfCounter = KeQueryPerformanceCounter(&pSample->PerfFrequency); 1468 pSample->PerfDelta.QuadPart = pSample->PerfCounter.QuadPart - pData->PerfCounterPrev.QuadPart; 1469 1470 pData->PerfCounterPrev.QuadPart = pSample->PerfCounter.QuadPart; 1471 1472 KeSetTimer(&pData->Timer, pData->DueTime, &pData->Dpc); 1473 } 1458 1474 1459 1475 KeReleaseSpinLockFromDpcLevel(&pData->SpinLock); 1460 1476 } 1461 1477 1462 int VBoxGuestCommonIOCtl_DPC(PVBOXGUESTDEVEXTWIN pDevExt, PVBOXGUESTSESSION pSession, 1463 void *pvData, size_t cbData, size_t *pcbDataReturned) 1464 { 1465 /* Allocate a non paged memory for samples and related data. */ 1478 1479 /** 1480 * Handles the DPC latency checker request. 1481 * 1482 * @returns VBox status code. 1483 */ 1484 int VbgdNtIOCtl_DpcLatencyChecker(void) 1485 { 1486 /* 1487 * Allocate a block of non paged memory for samples and related data. 1488 */ 1466 1489 DPCDATA *pData = (DPCDATA *)ExAllocatePoolWithTag(NonPagedPool, sizeof(DPCDATA), VBOXGUEST_DPC_TAG); 1467 1468 1490 if (!pData) 1469 1491 { … … 1472 1494 } 1473 1495 1474 KeInitializeDpc(&pData->Dpc, DPCDeferredRoutine, pData); 1496 /* 1497 * Initialize the data. 1498 */ 1499 KeInitializeDpc(&pData->Dpc, vbgdNtDpcLatencyCallback, pData); 1475 1500 KeInitializeTimer(&pData->Timer); 1476 1501 KeInitializeSpinLock(&pData->SpinLock); 1477 1502 1478 pData->fFinished = 0;1503 pData->fFinished = false; 1479 1504 pData->cSamples = 0; 1480 1505 pData->PerfCounterPrev.QuadPart = 0; … … 1483 1508 pData->DueTime.QuadPart = -(int64_t)pData->ulTimerRes / 10; 1484 1509 1485 /* Start the DPC measurements. */ 1510 /* 1511 * Start the DPC measurements and wait for a full set. 1512 */ 1486 1513 KeSetTimer(&pData->Timer, pData->DueTime, &pData->Dpc); 1487 1514 … … 1495 1522 ExSetTimerResolution(0, 0); 1496 1523 1497 /* Log everything to the host. */ 1524 /* 1525 * Log everything to the host. 1526 */ 1498 1527 RTLogBackdoorPrintf("DPC: ulTimerRes = %d\n", pData->ulTimerRes); 1499 1528 for (int i = 0; i < pData->cSamples; i++) -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r44988 r44992 2475 2475 { \ 2476 2476 LogFunc((mnemonic ": cbData=%#zx (%zu) expected is %#zx (%zu)\n", \ 2477 cbData, cbData, (size_t)(cb), (size_t)(cb))); \2477 cbData, cbData, (size_t)(cb), (size_t)(cb))); \ 2478 2478 return VERR_BUFFER_OVERFLOW; \ 2479 2479 } \ … … 2495 2495 rc = VBoxGuestCommonIOCtl_VMMRequest(pDevExt, pSession, (VMMDevRequestHeader *)pvData, cbData, pcbDataReturned); 2496 2496 } 2497 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER2498 /** @todo r=bird: This request doesn't vary in size?? AFAIK it doesn't have2499 * any data associated with it... grumble. */2500 else if (VBOXGUEST_IOCTL_STRIP_SIZE(iFunction) == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_DPC))2501 {2502 rc = VBoxGuestCommonIOCtl_DPC(pDevExt, pSession, pvData, cbData, pcbDataReturned);2503 }2504 #endif /* VBOX_WITH_DPC_LATENCY_CHECKER */2505 2497 #ifdef VBOX_WITH_HGCM 2506 2498 /* … … 2639 2631 *(uint32_t *)pvData); 2640 2632 break; 2633 2634 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER 2635 case VBOXGUEST_IOCTL_DPC_LATENCY_CHECKER: 2636 CHECKRET_SIZE("DPC_LATENCY_CHECKER", 0); 2637 rc = VbgdNtIOCtl_DpcLatencyChecker(); 2638 break; 2639 #endif 2641 2640 2642 2641 default: -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h
r44988 r44992 266 266 267 267 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER 268 int VBoxGuestCommonIOCtl_DPC(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, 269 void *pvData, size_t cbData, size_t *pcbDataReturned); 268 int VbgdNtIOCtl_DpcLatencyChecker(void); 270 269 #endif 271 270
Note:
See TracChangeset
for help on using the changeset viewer.