Changeset 41972 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Jun 29, 2012 1:35:30 PM (13 years ago)
- Location:
- trunk/src/VBox/Additions/common
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxControl/Makefile.kmk
r41477 r41972 37 37 $(if $(VBOX_WITH_GUEST_PROPS),VBOX_WITH_GUEST_PROPS,) \ 38 38 $(if $(VBOX_WITH_SHARED_FOLDERS),VBOX_WITH_SHARED_FOLDERS,) 39 VBoxControl_DEFS.win += \ 40 $(if $(VBOX_WITH_DPC_LATENCY_CHECKER),VBOX_WITH_DPC_LATENCY_CHECKER,) 39 41 VBoxControl_SOURCES = \ 40 42 VBoxControl.cpp -
trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp
r41443 r41972 1487 1487 } 1488 1488 1489 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER 1490 #include "..\VBoxGuestLib\VBGLR3Internal.h" 1491 1492 static RTEXITCODE handleDpc(int argc, char *argv[]) 1493 { 1494 #ifndef VBOX_CONTROL_TEST 1495 int rc = VINF_SUCCESS; 1496 int i; 1497 for (i = 0; i < 30; i++) 1498 { 1499 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_DPC, NULL, 0); 1500 if (RT_FAILURE(rc)) 1501 { 1502 break; 1503 } 1504 RTPrintf("%d\n", i); 1505 } 1506 #else 1507 int rc = VERR_NOT_IMPLEMENTED; 1508 #endif 1509 if (RT_SUCCESS(rc)) 1510 { 1511 RTPrintf("Samples collection completed.\n"); 1512 return RTEXITCODE_SUCCESS; 1513 } 1514 else 1515 { 1516 VBoxControlError("Error. rc=%Rrc\n", rc); 1517 return RTEXITCODE_FAILURE; 1518 } 1519 } 1520 #endif /* VBOX_WITH_DPC_LATENCY_CHECKER */ 1521 1489 1522 /** command handler type */ 1490 1523 typedef DECLCALLBACK(RTEXITCODE) FNVBOXCTRLCMDHANDLER(int argc, char *argv[]); … … 1523 1556 { "getversion", handleVersion }, 1524 1557 { "version", handleVersion }, 1558 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER 1559 { "dpc", handleDpc }, 1560 #endif /* VBOX_WITH_DPC_LATENCY_CHECKER */ 1525 1561 { "help", handleHelp } 1526 1562 }; -
trunk/src/VBox/Additions/common/VBoxGuest/Makefile.kmk
r41725 r41972 45 45 endif 46 46 #VBoxGuest_DEFS.win += LOG_ENABLED LOG_TO_BACKDOOR 47 VBoxGuest_DEFS.win += \ 48 $(if $(VBOX_WITH_DPC_LATENCY_CHECKER),VBOX_WITH_DPC_LATENCY_CHECKER,) 47 49 VBoxGuest_DEPS.solaris += $(VBOX_SVN_REV_KMK) 48 50 VBoxGuest_DEPS.linux += $(VBOX_SVN_REV_HEADER) -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp
r41647 r41972 22 22 23 23 #include <iprt/asm.h> 24 #include <iprt/asm-amd64-x86.h> 24 25 25 26 #include <VBox/log.h> … … 1397 1398 #endif /* DEBUG */ 1398 1399 1400 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER 1401 #pragma pack(1) 1402 typedef struct DPCSAMPLE 1403 { 1404 LARGE_INTEGER PerfDelta; 1405 LARGE_INTEGER PerfCounter; 1406 LARGE_INTEGER PerfFrequency; 1407 uint64_t u64TSC; 1408 } DPCSAMPLE; 1409 1410 typedef struct DPCDATA 1411 { 1412 KDPC Dpc; 1413 KTIMER Timer; 1414 KSPIN_LOCK SpinLock; 1415 1416 ULONG ulTimerRes; 1417 1418 LARGE_INTEGER DueTime; 1419 1420 BOOLEAN fFinished; 1421 1422 LARGE_INTEGER PerfCounterPrev; 1423 1424 int iSampleCount; 1425 DPCSAMPLE aSamples[8192]; 1426 } DPCDATA; 1427 #pragma pack(1) 1428 1429 #define VBOXGUEST_DPC_TAG 'DPCS' 1430 1431 static VOID DPCDeferredRoutine(struct _KDPC *Dpc, 1432 PVOID DeferredContext, 1433 PVOID SystemArgument1, 1434 PVOID SystemArgument2) 1435 { 1436 DPCDATA *pData = (DPCDATA *)DeferredContext; 1437 1438 KeAcquireSpinLockAtDpcLevel(&pData->SpinLock); 1439 1440 if (pData->iSampleCount >= RT_ELEMENTS(pData->aSamples)) 1441 { 1442 pData->fFinished = 1; 1443 KeReleaseSpinLockFromDpcLevel(&pData->SpinLock); 1444 return; 1445 } 1446 1447 DPCSAMPLE *pSample = &pData->aSamples[pData->iSampleCount++]; 1448 1449 pSample->u64TSC = ASMReadTSC(); 1450 pSample->PerfCounter = KeQueryPerformanceCounter(&pSample->PerfFrequency); 1451 pSample->PerfDelta.QuadPart = pSample->PerfCounter.QuadPart - pData->PerfCounterPrev.QuadPart; 1452 1453 pData->PerfCounterPrev.QuadPart = pSample->PerfCounter.QuadPart; 1454 1455 KeSetTimer(&pData->Timer, pData->DueTime, &pData->Dpc); 1456 1457 KeReleaseSpinLockFromDpcLevel(&pData->SpinLock); 1458 } 1459 1460 int VBoxGuestCommonIOCtl_DPC(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, 1461 void *pvData, size_t cbData, size_t *pcbDataReturned) 1462 { 1463 int rc = VINF_SUCCESS; 1464 1465 /* Allocate a non paged memory for samples and related data. */ 1466 DPCDATA *pData = (DPCDATA *)ExAllocatePoolWithTag(NonPagedPool, sizeof(DPCDATA), VBOXGUEST_DPC_TAG); 1467 1468 if (!pData) 1469 { 1470 RTLogBackdoorPrintf("VBoxGuest: DPC: DPCDATA allocation failed.\n"); 1471 return VERR_NO_MEMORY; 1472 } 1473 1474 KeInitializeDpc(&pData->Dpc, DPCDeferredRoutine, pData); 1475 KeInitializeTimer(&pData->Timer); 1476 KeInitializeSpinLock(&pData->SpinLock); 1477 1478 pData->fFinished = 0; 1479 pData->iSampleCount = 0; 1480 pData->PerfCounterPrev.QuadPart = 0; 1481 1482 pData->ulTimerRes = ExSetTimerResolution(1000 * 10, 1); 1483 pData->DueTime.QuadPart = -(int64_t)pData->ulTimerRes / 10; 1484 1485 /* Start the DPC measurements. */ 1486 KeSetTimer(&pData->Timer, pData->DueTime, &pData->Dpc); 1487 1488 while (!pData->fFinished) 1489 { 1490 LARGE_INTEGER Interval; 1491 Interval.QuadPart = -100 * 1000 * 10; 1492 KeDelayExecutionThread(KernelMode, TRUE, &Interval); 1493 } 1494 1495 ExSetTimerResolution(0, 0); 1496 1497 /* Log everything to the host. */ 1498 RTLogBackdoorPrintf("DPC: ulTimerRes = %d\n", pData->ulTimerRes); 1499 int i; 1500 for (i = 0; i < pData->iSampleCount; i++) 1501 { 1502 DPCSAMPLE *pSample = &pData->aSamples[i]; 1503 1504 RTLogBackdoorPrintf("[%d] pd %lld pc %lld pf %lld t %lld\n", 1505 i, 1506 pSample->PerfDelta.QuadPart, 1507 pSample->PerfCounter.QuadPart, 1508 pSample->PerfFrequency.QuadPart, 1509 pSample->u64TSC); 1510 } 1511 1512 ExFreePoolWithTag(pData, VBOXGUEST_DPC_TAG); 1513 return rc; 1514 } 1515 #endif /* VBOX_WITH_DPC_LATENCY_CHECKER */ -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r41722 r41972 71 71 static int VBoxGuestCommonIOCtl_SetMouseStatus(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fFeatures); 72 72 73 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER 74 int VBoxGuestCommonIOCtl_DPC(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, 75 void *pvData, size_t cbData, size_t *pcbDataReturned); 76 #endif /* VBOX_WITH_DPC_LATENCY_CHECKER */ 73 77 74 78 /******************************************************************************* … … 2485 2489 rc = VBoxGuestCommonIOCtl_VMMRequest(pDevExt, pSession, (VMMDevRequestHeader *)pvData, cbData, pcbDataReturned); 2486 2490 } 2491 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER 2492 else if (VBOXGUEST_IOCTL_STRIP_SIZE(iFunction) == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_DPC)) 2493 { 2494 rc = VBoxGuestCommonIOCtl_DPC(pDevExt, pSession, pvData, cbData, pcbDataReturned); 2495 } 2496 #endif /* VBOX_WITH_DPC_LATENCY_CHECKER */ 2487 2497 #ifdef VBOX_WITH_HGCM 2488 2498 /*
Note:
See TracChangeset
for help on using the changeset viewer.