Changeset 39014 in vbox
- Timestamp:
- Oct 18, 2011 10:18:06 AM (13 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/PDMAsyncCompletion.cpp
r36001 r39014 5 5 6 6 /* 7 * Copyright (C) 2006-20 08Oracle Corporation7 * Copyright (C) 2006-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 42 42 #include "PDMAsyncCompletionInternal.h" 43 43 44 45 /******************************************************************************* 46 * Structures and Typedefs * 47 *******************************************************************************/ 44 48 /** 45 49 * Async I/O type. … … 142 146 typedef PPDMACBWMGR *PPPDMACBWMGR; 143 147 148 149 /******************************************************************************* 150 * Internal Functions * 151 *******************************************************************************/ 144 152 static void pdmR3AsyncCompletionPutTask(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, PPDMASYNCCOMPLETIONTASK pTask); 153 145 154 146 155 /** … … 151 160 * @param ppTemplate Where to store the template handle. 152 161 */ 153 static int pdmR3AsyncCompletionTemplateCreate(PVM pVM, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PDMASYNCCOMPLETIONTEMPLATETYPE enmType) 162 static int pdmR3AsyncCompletionTemplateCreate(PVM pVM, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, 163 PDMASYNCCOMPLETIONTEMPLATETYPE enmType) 154 164 { 155 165 PUVM pUVM = pVM->pUVM; 156 166 157 if (ppTemplate == NULL) 158 { 159 AssertMsgFailed(("ppTemplate is NULL\n")); 160 return VERR_INVALID_PARAMETER; 161 } 167 AssertPtrReturn(ppTemplate, VERR_INVALID_POINTER); 162 168 163 169 PPDMASYNCCOMPLETIONTEMPLATE pTemplate; … … 208 214 */ 209 215 VM_ASSERT_EMT(pVM); 210 if (!pfnCompleted) 211 { 212 AssertMsgFailed(("No completion callback!\n")); 213 return VERR_INVALID_PARAMETER; 214 } 215 216 if (!ppTemplate) 217 { 218 AssertMsgFailed(("Template pointer is NULL!\n")); 219 return VERR_INVALID_PARAMETER; 220 } 216 AssertPtrReturn(pfnCompleted, VERR_INVALID_POINTER); 217 AssertPtrReturn(ppTemplate, VERR_INVALID_POINTER); 221 218 222 219 /* … … 259 256 * Validate input. 260 257 */ 261 if (!pfnCompleted) 262 { 263 AssertMsgFailed(("No completion callback!\n")); 264 return VERR_INVALID_PARAMETER; 265 } 266 267 if (!ppTemplate) 268 { 269 AssertMsgFailed(("Template pointer is NULL!\n")); 270 return VERR_INVALID_PARAMETER; 271 } 258 AssertPtrReturn(pfnCompleted, VERR_INVALID_POINTER); 259 AssertPtrReturn(ppTemplate, VERR_INVALID_POINTER); 272 260 273 261 /* … … 311 299 */ 312 300 VM_ASSERT_EMT(pVM); 313 if (!pfnCompleted) 314 { 315 AssertMsgFailed(("No completion callback!\n")); 316 return VERR_INVALID_PARAMETER; 317 } 318 319 if (!ppTemplate) 320 { 321 AssertMsgFailed(("Template pointer is NULL!\n")); 322 return VERR_INVALID_PARAMETER; 323 } 301 AssertPtrReturn(pfnCompleted, VERR_INVALID_POINTER); 302 AssertPtrReturn(ppTemplate, VERR_INVALID_POINTER); 324 303 325 304 /* … … 362 341 */ 363 342 VM_ASSERT_EMT(pVM); 364 if (!pfnCompleted) 365 { 366 AssertMsgFailed(("No completion callback!\n")); 367 return VERR_INVALID_PARAMETER; 368 } 369 370 if (!ppTemplate) 371 { 372 AssertMsgFailed(("Template pointer is NULL!\n")); 373 return VERR_INVALID_PARAMETER; 374 } 343 AssertPtrReturn(pfnCompleted, VERR_INVALID_POINTER); 344 AssertPtrReturn(ppTemplate, VERR_INVALID_POINTER); 375 345 376 346 /* … … 599 569 PPDMACBWMGR pBwMgr = NULL; 600 570 601 if (VALID_PTR(pcszId)) 602 { 603 int rc; 604 rc = RTCritSectEnter(&pEpClass->CritSect); 605 AssertRC(rc); 571 if (RT_VALID_PTR(pcszId)) 572 { 573 int rc = RTCritSectEnter(&pEpClass->CritSect); AssertRC(rc); 606 574 607 575 pBwMgr = pEpClass->pBwMgrsHead; … … 610 578 pBwMgr = pBwMgr->pNext; 611 579 612 rc = RTCritSectLeave(&pEpClass->CritSect); 613 AssertRC(rc); 580 rc = RTCritSectLeave(&pEpClass->CritSect); AssertRC(rc); 614 581 } 615 582 … … 620 587 { 621 588 PPDMASYNCCOMPLETIONEPCLASS pEpClass = pBwMgr->pEpClass; 622 int rc; 623 624 rc = RTCritSectEnter(&pEpClass->CritSect); 625 AssertRC(rc); 589 int rc = RTCritSectEnter(&pEpClass->CritSect); AssertRC(rc); 626 590 627 591 pBwMgr->pNext = pEpClass->pBwMgrsHead; 628 592 pEpClass->pBwMgrsHead = pBwMgr; 629 593 630 rc = RTCritSectLeave(&pEpClass->CritSect); 631 AssertRC(rc); 594 rc = RTCritSectLeave(&pEpClass->CritSect); AssertRC(rc); 632 595 } 633 596 634 597 static void pdmacBwMgrUnlink(PPDMACBWMGR pBwMgr) 635 598 { 636 int rc;637 599 PPDMASYNCCOMPLETIONEPCLASS pEpClass = pBwMgr->pEpClass; 638 639 rc = RTCritSectEnter(&pEpClass->CritSect); 640 AssertRC(rc); 600 int rc = RTCritSectEnter(&pEpClass->CritSect); AssertRC(rc); 641 601 642 602 if (pBwMgr == pEpClass->pBwMgrsHead) … … 653 613 } 654 614 655 rc = RTCritSectLeave(&pEpClass->CritSect); 656 AssertRC(rc); 615 rc = RTCritSectLeave(&pEpClass->CritSect); AssertRC(rc); 657 616 } 658 617 … … 660 619 uint32_t cbTransferPerSecStart, uint32_t cbTransferPerSecStep) 661 620 { 662 int rc = VINF_SUCCESS;663 PPDMACBWMGR pBwMgr;664 665 621 LogFlowFunc(("pEpClass=%#p pcszBwMgr=%#p{%s} cbTransferPerSecMax=%u cbTransferPerSecStart=%u cbTransferPerSecStep=%u\n", 666 622 pEpClass, pcszBwMgr, cbTransferPerSecMax, cbTransferPerSecStart, cbTransferPerSecStep)); … … 670 626 AssertReturn(*pcszBwMgr != '\0', VERR_INVALID_PARAMETER); 671 627 672 pBwMgr = pdmacBwMgrFindById(pEpClass, pcszBwMgr); 628 int rc; 629 PPDMACBWMGR pBwMgr = pdmacBwMgrFindById(pEpClass, pcszBwMgr); 673 630 if (!pBwMgr) 674 631 { … … 722 679 bool pdmacEpIsTransferAllowed(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, uint32_t cbTransfer, RTMSINTERVAL *pmsWhenNext) 723 680 { 724 bool fAllowed = true;681 bool fAllowed = true; 725 682 PPDMACBWMGR pBwMgr = ASMAtomicReadPtrT(&pEndpoint->pBwMgr, PPDMACBWMGR); 726 683 … … 765 722 766 723 LogFlowFunc(("fAllowed=%RTbool\n", fAllowed)); 767 768 724 return fAllowed; 769 725 } … … 780 736 { 781 737 case PDMASYNCCOMPLETIONTEMPLATETYPE_DEV: 782 {783 738 pTemplate->u.Dev.pfnCompleted(pTemplate->u.Dev.pDevIns, pTask->pvUser, rc); 784 739 break; 785 } 740 786 741 case PDMASYNCCOMPLETIONTEMPLATETYPE_DRV: 787 {788 742 pTemplate->u.Drv.pfnCompleted(pTemplate->u.Drv.pDrvIns, pTemplate->u.Drv.pvTemplateUser, pTask->pvUser, rc); 789 743 break; 790 } 744 791 745 case PDMASYNCCOMPLETIONTEMPLATETYPE_USB: 792 {793 746 pTemplate->u.Usb.pfnCompleted(pTemplate->u.Usb.pUsbIns, pTask->pvUser, rc); 794 747 break; 795 } 748 796 749 case PDMASYNCCOMPLETIONTEMPLATETYPE_INTERNAL: 797 {798 750 pTemplate->u.Int.pfnCompleted(pTemplate->pVM, pTask->pvUser, pTemplate->u.Int.pvUser, rc); 799 751 break; 800 } 752 801 753 default: 802 754 AssertMsgFailed(("Unknown template type!\n")); … … 817 769 int pdmR3AsyncCompletionEpClassInit(PVM pVM, PCPDMASYNCCOMPLETIONEPCLASSOPS pEpClassOps, PCFGMNODE pCfgHandle) 818 770 { 819 int rc = VINF_SUCCESS;820 821 771 /* Validate input. */ 822 if ( !pEpClassOps 823 || (pEpClassOps->u32Version != PDMAC_EPCLASS_OPS_VERSION) 824 || (pEpClassOps->u32VersionEnd != PDMAC_EPCLASS_OPS_VERSION)) 825 AssertMsgFailedReturn(("Invalid endpoint class data\n"), VERR_VERSION_MISMATCH); 772 AssertPtrReturn(pEpClassOps, VERR_INVALID_POINTER); 773 AssertReturn(pEpClassOps->u32Version == PDMAC_EPCLASS_OPS_VERSION, VERR_VERSION_MISMATCH); 774 AssertReturn(pEpClassOps->u32VersionEnd == PDMAC_EPCLASS_OPS_VERSION, VERR_VERSION_MISMATCH); 826 775 827 776 LogFlowFunc((": pVM=%p pEpClassOps=%p{%s}\n", pVM, pEpClassOps, pEpClassOps->pcszName)); … … 830 779 PPDMASYNCCOMPLETIONEPCLASS pEndpointClass = NULL; 831 780 832 rc = MMR3HeapAllocZEx(pVM, MM_TAG_PDM_ASYNC_COMPLETION,833 pEpClassOps->cbEndpointClassGlobal,834 (void **)&pEndpointClass);781 int rc = MMR3HeapAllocZEx(pVM, MM_TAG_PDM_ASYNC_COMPLETION, 782 pEpClassOps->cbEndpointClassGlobal, 783 (void **)&pEndpointClass); 835 784 if (RT_SUCCESS(rc)) 836 785 { … … 922 871 static void pdmR3AsyncCompletionEpClassTerminate(PPDMASYNCCOMPLETIONEPCLASS pEndpointClass) 923 872 { 924 int rc = VINF_SUCCESS;925 873 PVM pVM = pEndpointClass->pVM; 926 874 … … 957 905 int pdmR3AsyncCompletionInit(PVM pVM) 958 906 { 959 int rc = VINF_SUCCESS;960 PUVM pUVM = pVM->pUVM;961 962 907 LogFlowFunc((": pVM=%p\n", pVM)); 963 908 … … 967 912 PCFGMNODE pCfgAsyncCompletion = CFGMR3GetChild(CFGMR3GetChild(pCfgRoot, "PDM"), "AsyncCompletion"); 968 913 969 rc = pdmR3AsyncCompletionEpClassInit(pVM, &g_PDMAsyncCompletionEndpointClassFile, pCfgAsyncCompletion); 970 914 int rc = pdmR3AsyncCompletionEpClassInit(pVM, &g_PDMAsyncCompletionEndpointClassFile, pCfgAsyncCompletion); 971 915 LogFlowFunc((": pVM=%p rc=%Rrc\n", pVM, rc)); 972 973 916 return rc; 974 917 } … … 1007 950 if (pUVM->pdm.s.apAsyncCompletionEndpointClass[i]) 1008 951 { 1009 PPDMASYNCCOMPLETIONEPCLASS pEpClass = pUVM->pdm.s.apAsyncCompletionEndpointClass[i]; 952 PPDMASYNCCOMPLETIONEPCLASS pEpClass = pUVM->pdm.s.apAsyncCompletionEndpointClass[i]; 953 PPDMACBWMGR pBwMgr = pEpClass->pBwMgrsHead; 1010 954 PPDMASYNCCOMPLETIONENDPOINT pEp; 1011 PPDMACBWMGR pBwMgr = pEpClass->pBwMgrsHead;1012 955 1013 956 if (pBwMgr) … … 1061 1004 { 1062 1005 PPDMASYNCCOMPLETIONEPCLASS pEndpointClass = pEndpoint->pEpClass; 1063 PPDMASYNCCOMPLETIONTASK pTask = NULL; 1064 1065 pTask = (PPDMASYNCCOMPLETIONTASK)RTMemCacheAlloc(pEndpointClass->hMemCacheTasks); 1066 1006 PPDMASYNCCOMPLETIONTASK pTask = (PPDMASYNCCOMPLETIONTASK)RTMemCacheAlloc(pEndpointClass->hMemCacheTasks); 1067 1007 if (RT_LIKELY(pTask)) 1068 1008 { … … 1092 1032 { 1093 1033 PPDMASYNCCOMPLETIONEPCLASS pEndpointClass = pEndpoint->pEpClass; 1094 uint64_t tsRun = RTTimeNanoTS() - pTask->tsNsStart; 1095 1096 if (RT_UNLIKELY(tsRun >= (uint64_t)10*1000*1000*1000)) 1097 { 1098 LogRel(("AsyncCompletion: Task %#p completed after %llu seconds\n", pTask, tsRun / ((uint64_t)1000*1000*1000))); 1099 } 1034 uint64_t cNsRun = RTTimeNanoTS() - pTask->tsNsStart; 1035 1036 if (RT_UNLIKELY(cNsRun >= RT_NS_10SEC)) 1037 LogRel(("AsyncCompletion: Task %#p completed after %llu seconds\n", pTask, cNsRun / RT_NS_1SEC)); 1100 1038 1101 1039 #ifdef VBOX_WITH_STATISTICS 1102 uint64_t iStatIdx; 1103 1104 if (tsRun < 1000) 1105 { 1106 /* Update nanoseconds statistics */ 1107 iStatIdx = tsRun / 100; 1108 STAM_COUNTER_INC(&pEndpoint->StatTaskRunTimesNs[iStatIdx]); 1109 } 1040 PSTAMCOUNTER pStatCounter; 1041 if (cNsRun < RT_NS_1US) 1042 pStatCounter = &pEndpoint->StatTaskRunTimesNs[cNsRun / (RT_NS_1US / 10)]; 1043 else if (cNsRun < RT_NS_1MS) 1044 pStatCounter = &pEndpoint->StatTaskRunTimesUs[cNsRun / (RT_NS_1MS / 10)]; 1045 else if (cNsRun < RT_NS_1SEC) 1046 pStatCounter = &pEndpoint->StatTaskRunTimesMs[cNsRun / (RT_NS_1SEC / 10)]; 1047 else if (cNsRun < RT_NS_1SEC_64*100) 1048 pStatCounter = &pEndpoint->StatTaskRunTimesSec[cNsRun / (RT_NS_1SEC_64*100 / 10)]; 1110 1049 else 1111 { 1112 tsRun /= 1000; 1113 1114 if (tsRun < 1000) 1115 { 1116 /* Update microsecnds statistics */ 1117 iStatIdx = tsRun / 100; 1118 STAM_COUNTER_INC(&pEndpoint->StatTaskRunTimesMicroSec[iStatIdx]); 1119 } 1120 else 1121 { 1122 tsRun /= 1000; 1123 1124 if (tsRun < 1000) 1125 { 1126 /* Update milliseconds statistics */ 1127 iStatIdx = tsRun / 100; 1128 STAM_COUNTER_INC(&pEndpoint->StatTaskRunTimesMs[iStatIdx]); 1129 } 1130 else 1131 { 1132 tsRun /= 1000; 1133 1134 if (tsRun < 1000) 1135 { 1136 /* Update seconds statistics */ 1137 iStatIdx = tsRun / 10; 1138 STAM_COUNTER_INC(&pEndpoint->StatTaskRunTimesSec[iStatIdx]); 1139 } 1140 else 1141 STAM_COUNTER_INC(&pEndpoint->StatTaskRunOver100Sec); 1142 } 1143 } 1144 } 1050 pStatCounter = &pEndpoint->StatTaskRunOver100Sec; 1051 STAM_COUNTER_INC(pStatCounter); 1145 1052 1146 1053 STAM_COUNTER_INC(&pEndpoint->StatIoOpsCompleted); … … 1148 1055 uint64_t tsMsCur = RTTimeMilliTS(); 1149 1056 uint64_t tsInterval = tsMsCur - pEndpoint->tsIntervalStartMs; 1150 1151 1057 if (tsInterval >= 1000) 1152 1058 { … … 1155 1061 pEndpoint->cIoOpsCompleted = 0; 1156 1062 } 1157 #endif 1063 #endif /* VBOX_WITH_STATISTICS */ 1158 1064 1159 1065 RTMemCacheFree(pEndpointClass->hMemCacheTasks, pTask); … … 1180 1086 PPDMASYNCCOMPLETIONTEMPLATE pTemplate) 1181 1087 { 1182 int rc = VINF_SUCCESS;1183 1184 1088 LogFlowFunc((": ppEndpoint=%p pszFilename=%p{%s} fFlags=%u pTemplate=%p\n", 1185 1089 ppEndpoint, pszFilename, pszFilename, fFlags, pTemplate)); 1186 1090 1187 1091 /* Sanity checks. */ 1188 Assert Return(VALID_PTR(ppEndpoint), VERR_INVALID_POINTER);1189 Assert Return(VALID_PTR(pszFilename), VERR_INVALID_POINTER);1190 Assert Return(VALID_PTR(pTemplate), VERR_INVALID_POINTER);1092 AssertPtrReturn(ppEndpoint, VERR_INVALID_POINTER); 1093 AssertPtrReturn(pszFilename, VERR_INVALID_POINTER); 1094 AssertPtrReturn(pTemplate, VERR_INVALID_POINTER); 1191 1095 1192 1096 /* Check that the flags are valid. */ … … 1203 1107 /* Search for a already opened endpoint for this file. */ 1204 1108 pEndpoint = pdmR3AsyncCompletionFindEndpointWithUri(pEndpointClass, pszFilename); 1205 1206 if(!pEndpoint) 1207 { 1208 rc = MMR3HeapAllocZEx(pVM, MM_TAG_PDM_ASYNC_COMPLETION, 1109 if (pEndpoint) 1110 { 1111 /* Endpoint found. */ 1112 pEndpoint->cUsers++; 1113 1114 *ppEndpoint = pEndpoint; 1115 return VINF_SUCCESS; 1116 } 1117 1118 /* Create an endpoint. */ 1119 int rc = MMR3HeapAllocZEx(pVM, MM_TAG_PDM_ASYNC_COMPLETION, 1209 1120 pEndpointClass->pEndpointOps->cbEndpoint, 1210 1121 (void **)&pEndpoint); 1211 if (RT_SUCCESS(rc)) 1122 if (RT_SUCCESS(rc)) 1123 { 1124 1125 /* Initialize common parts. */ 1126 pEndpoint->pNext = NULL; 1127 pEndpoint->pPrev = NULL; 1128 pEndpoint->pEpClass = pEndpointClass; 1129 pEndpoint->pTemplate = pTemplate; 1130 pEndpoint->pszUri = RTStrDup(pszFilename); 1131 pEndpoint->cUsers = 1; 1132 pEndpoint->pBwMgr = NULL; 1133 1134 if ( pEndpoint->pszUri 1135 && RT_SUCCESS(rc)) 1212 1136 { 1213 1214 /* Initialize common parts. */ 1215 pEndpoint->pNext = NULL; 1216 pEndpoint->pPrev = NULL; 1217 pEndpoint->pEpClass = pEndpointClass; 1218 pEndpoint->pTemplate = pTemplate; 1219 pEndpoint->pszUri = RTStrDup(pszFilename); 1220 pEndpoint->cUsers = 1; 1221 pEndpoint->pBwMgr = NULL; 1222 1223 if ( pEndpoint->pszUri 1224 && RT_SUCCESS(rc)) 1137 /* Call the initializer for the endpoint. */ 1138 rc = pEndpointClass->pEndpointOps->pfnEpInitialize(pEndpoint, pszFilename, fFlags); 1139 if (RT_SUCCESS(rc)) 1225 1140 { 1226 /* Call the initializer for the endpoint. */ 1227 rc = pEndpointClass->pEndpointOps->pfnEpInitialize(pEndpoint, pszFilename, fFlags); 1141 /* Link it into the list of endpoints. */ 1142 rc = RTCritSectEnter(&pEndpointClass->CritSect); 1143 AssertMsg(RT_SUCCESS(rc), ("Failed to enter critical section rc=%Rrc\n", rc)); 1144 1145 pEndpoint->pNext = pEndpointClass->pEndpointsHead; 1146 if (pEndpointClass->pEndpointsHead) 1147 pEndpointClass->pEndpointsHead->pPrev = pEndpoint; 1148 1149 pEndpointClass->pEndpointsHead = pEndpoint; 1150 pEndpointClass->cEndpoints++; 1151 1152 rc = RTCritSectLeave(&pEndpointClass->CritSect); 1153 AssertMsg(RT_SUCCESS(rc), ("Failed to enter critical section rc=%Rrc\n", rc)); 1154 1155 /* Reference the template. */ 1156 ASMAtomicIncU32(&pTemplate->cUsed); 1157 1158 #ifdef VBOX_WITH_STATISTICS 1159 /* Init the statistics part */ 1160 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesNs); i++) 1161 { 1162 rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesNs[i], STAMTYPE_COUNTER, 1163 STAMVISIBILITY_USED, 1164 STAMUNIT_OCCURENCES, 1165 "Nanosecond resolution runtime statistics", 1166 "/PDM/AsyncCompletion/File/%s/TaskRun1Ns-%u-%u", 1167 RTPathFilename(pEndpoint->pszUri), 1168 i*100, i*100+100-1); 1169 if (RT_FAILURE(rc)) 1170 break; 1171 } 1172 1228 1173 if (RT_SUCCESS(rc)) 1229 1174 { 1230 /* Link it into the list of endpoints. */ 1231 rc = RTCritSectEnter(&pEndpointClass->CritSect); 1232 AssertMsg(RT_SUCCESS(rc), ("Failed to enter critical section rc=%Rrc\n", rc)); 1233 1234 pEndpoint->pNext = pEndpointClass->pEndpointsHead; 1235 if (pEndpointClass->pEndpointsHead) 1236 pEndpointClass->pEndpointsHead->pPrev = pEndpoint; 1237 1238 pEndpointClass->pEndpointsHead = pEndpoint; 1239 pEndpointClass->cEndpoints++; 1240 1241 rc = RTCritSectLeave(&pEndpointClass->CritSect); 1242 AssertMsg(RT_SUCCESS(rc), ("Failed to enter critical section rc=%Rrc\n", rc)); 1243 1244 /* Reference the template. */ 1245 ASMAtomicIncU32(&pTemplate->cUsed); 1246 1247 #ifdef VBOX_WITH_STATISTICS 1248 /* Init the statistics part */ 1249 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesNs); i++) 1175 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesUs); i++) 1250 1176 { 1251 rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimes Ns[i], STAMTYPE_COUNTER,1177 rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesUs[i], STAMTYPE_COUNTER, 1252 1178 STAMVISIBILITY_USED, 1253 1179 STAMUNIT_OCCURENCES, 1254 " Nanosecond resolution runtime statistics",1255 "/PDM/AsyncCompletion/File/%s/TaskRun 1Ns-%u-%u",1180 "Microsecond resolution runtime statistics", 1181 "/PDM/AsyncCompletion/File/%s/TaskRun2MicroSec-%u-%u", 1256 1182 RTPathFilename(pEndpoint->pszUri), 1257 1183 i*100, i*100+100-1); … … 1259 1185 break; 1260 1186 } 1261 1262 if (RT_SUCCESS(rc)) 1263 { 1264 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMicroSec); i++) 1265 { 1266 rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesMicroSec[i], STAMTYPE_COUNTER, 1267 STAMVISIBILITY_USED, 1268 STAMUNIT_OCCURENCES, 1269 "Microsecond resolution runtime statistics", 1270 "/PDM/AsyncCompletion/File/%s/TaskRun2MicroSec-%u-%u", 1271 RTPathFilename(pEndpoint->pszUri), 1272 i*100, i*100+100-1); 1273 if (RT_FAILURE(rc)) 1274 break; 1275 } 1276 } 1277 1278 if (RT_SUCCESS(rc)) 1187 } 1188 1189 if (RT_SUCCESS(rc)) 1190 { 1191 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMs); i++) 1279 1192 { 1280 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMs); i++) 1281 { 1282 rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesMs[i], STAMTYPE_COUNTER, 1283 STAMVISIBILITY_USED, 1284 STAMUNIT_OCCURENCES, 1285 "Milliseconds resolution runtime statistics", 1286 "/PDM/AsyncCompletion/File/%s/TaskRun3Ms-%u-%u", 1287 RTPathFilename(pEndpoint->pszUri), 1288 i*100, i*100+100-1); 1289 if (RT_FAILURE(rc)) 1290 break; 1291 } 1193 rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesMs[i], STAMTYPE_COUNTER, 1194 STAMVISIBILITY_USED, 1195 STAMUNIT_OCCURENCES, 1196 "Milliseconds resolution runtime statistics", 1197 "/PDM/AsyncCompletion/File/%s/TaskRun3Ms-%u-%u", 1198 RTPathFilename(pEndpoint->pszUri), 1199 i*100, i*100+100-1); 1200 if (RT_FAILURE(rc)) 1201 break; 1292 1202 } 1293 1294 if (RT_SUCCESS(rc)) 1203 } 1204 1205 if (RT_SUCCESS(rc)) 1206 { 1207 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMs); i++) 1295 1208 { 1296 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMs); i++) 1297 { 1298 rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesSec[i], STAMTYPE_COUNTER, 1299 STAMVISIBILITY_USED, 1300 STAMUNIT_OCCURENCES, 1301 "Second resolution runtime statistics", 1302 "/PDM/AsyncCompletion/File/%s/TaskRun4Sec-%u-%u", 1303 RTPathFilename(pEndpoint->pszUri), 1304 i*10, i*10+10-1); 1305 if (RT_FAILURE(rc)) 1306 break; 1307 } 1308 } 1309 1310 if (RT_SUCCESS(rc)) 1311 { 1312 rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunOver100Sec, STAMTYPE_COUNTER, 1209 rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesSec[i], STAMTYPE_COUNTER, 1313 1210 STAMVISIBILITY_USED, 1314 1211 STAMUNIT_OCCURENCES, 1315 "Tasks which ran more than 100sec", 1316 "/PDM/AsyncCompletion/File/%s/TaskRunSecGreater100Sec", 1317 RTPathFilename(pEndpoint->pszUri)); 1212 "Second resolution runtime statistics", 1213 "/PDM/AsyncCompletion/File/%s/TaskRun4Sec-%u-%u", 1214 RTPathFilename(pEndpoint->pszUri), 1215 i*10, i*10+10-1); 1216 if (RT_FAILURE(rc)) 1217 break; 1318 1218 } 1319 1320 if (RT_SUCCESS(rc)) 1321 { 1322 rc = STAMR3RegisterF(pVM, &pEndpoint->StatIoOpsPerSec, STAMTYPE_COUNTER, 1323 STAMVISIBILITY_ALWAYS, 1324 STAMUNIT_OCCURENCES, 1325 "Processed I/O operations per second", 1326 "/PDM/AsyncCompletion/File/%s/IoOpsPerSec", 1327 RTPathFilename(pEndpoint->pszUri)); 1328 } 1329 1330 if (RT_SUCCESS(rc)) 1331 { 1332 rc = STAMR3RegisterF(pVM, &pEndpoint->StatIoOpsStarted, STAMTYPE_COUNTER, 1333 STAMVISIBILITY_ALWAYS, 1334 STAMUNIT_OCCURENCES, 1335 "Started I/O operations for this endpoint", 1336 "/PDM/AsyncCompletion/File/%s/IoOpsStarted", 1337 RTPathFilename(pEndpoint->pszUri)); 1338 } 1339 1340 if (RT_SUCCESS(rc)) 1341 { 1342 rc = STAMR3RegisterF(pVM, &pEndpoint->StatIoOpsCompleted, STAMTYPE_COUNTER, 1343 STAMVISIBILITY_ALWAYS, 1344 STAMUNIT_OCCURENCES, 1345 "Completed I/O operations for this endpoint", 1346 "/PDM/AsyncCompletion/File/%s/IoOpsCompleted", 1347 RTPathFilename(pEndpoint->pszUri)); 1348 } 1349 1350 pEndpoint->tsIntervalStartMs = RTTimeMilliTS(); 1219 } 1220 1221 if (RT_SUCCESS(rc)) 1222 { 1223 rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunOver100Sec, STAMTYPE_COUNTER, 1224 STAMVISIBILITY_USED, 1225 STAMUNIT_OCCURENCES, 1226 "Tasks which ran more than 100sec", 1227 "/PDM/AsyncCompletion/File/%s/TaskRunSecGreater100Sec", 1228 RTPathFilename(pEndpoint->pszUri)); 1229 } 1230 1231 if (RT_SUCCESS(rc)) 1232 { 1233 rc = STAMR3RegisterF(pVM, &pEndpoint->StatIoOpsPerSec, STAMTYPE_COUNTER, 1234 STAMVISIBILITY_ALWAYS, 1235 STAMUNIT_OCCURENCES, 1236 "Processed I/O operations per second", 1237 "/PDM/AsyncCompletion/File/%s/IoOpsPerSec", 1238 RTPathFilename(pEndpoint->pszUri)); 1239 } 1240 1241 if (RT_SUCCESS(rc)) 1242 { 1243 rc = STAMR3RegisterF(pVM, &pEndpoint->StatIoOpsStarted, STAMTYPE_COUNTER, 1244 STAMVISIBILITY_ALWAYS, 1245 STAMUNIT_OCCURENCES, 1246 "Started I/O operations for this endpoint", 1247 "/PDM/AsyncCompletion/File/%s/IoOpsStarted", 1248 RTPathFilename(pEndpoint->pszUri)); 1249 } 1250 1251 if (RT_SUCCESS(rc)) 1252 { 1253 rc = STAMR3RegisterF(pVM, &pEndpoint->StatIoOpsCompleted, STAMTYPE_COUNTER, 1254 STAMVISIBILITY_ALWAYS, 1255 STAMUNIT_OCCURENCES, 1256 "Completed I/O operations for this endpoint", 1257 "/PDM/AsyncCompletion/File/%s/IoOpsCompleted", 1258 RTPathFilename(pEndpoint->pszUri)); 1259 } 1260 /** @todo why bother maintaing rc when it's just ignored / 1261 logged and not returned? */ 1262 1263 pEndpoint->tsIntervalStartMs = RTTimeMilliTS(); 1351 1264 #endif 1352 1265 1353 *ppEndpoint = pEndpoint; 1354 1355 LogFlowFunc((": Created endpoint for %s: rc=%Rrc\n", pszFilename, rc)); 1356 return VINF_SUCCESS; 1357 } 1358 RTStrFree(pEndpoint->pszUri); 1266 *ppEndpoint = pEndpoint; 1267 1268 LogFlowFunc((": Created endpoint for %s: rc=%Rrc\n", pszFilename, rc)); 1269 return VINF_SUCCESS; 1359 1270 } 1360 MMR3HeapFree(pEndpoint);1271 RTStrFree(pEndpoint->pszUri); 1361 1272 } 1362 } 1363 else 1364 { 1365 /* Endpoint found. */ 1366 pEndpoint->cUsers++; 1367 1368 *ppEndpoint = pEndpoint; 1369 return VINF_SUCCESS; 1273 MMR3HeapFree(pEndpoint); 1370 1274 } 1371 1275 1372 1276 LogFlowFunc((": Creation of endpoint for %s failed: rc=%Rrc\n", pszFilename, rc)); 1373 1374 1277 return rc; 1375 1278 } … … 1418 1321 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesNs); i++) 1419 1322 STAMR3Deregister(pVM, &pEndpoint->StatTaskRunTimesNs[i]); 1420 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimes MicroSec); i++)1421 STAMR3Deregister(pVM, &pEndpoint->StatTaskRunTimes MicroSec[i]);1323 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesUs); i++) 1324 STAMR3Deregister(pVM, &pEndpoint->StatTaskRunTimesUs[i]); 1422 1325 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMs); i++) 1423 1326 STAMR3Deregister(pVM, &pEndpoint->StatTaskRunTimesMs[i]); … … 1441 1344 PPPDMASYNCCOMPLETIONTASK ppTask) 1442 1345 { 1443 int rc = VINF_SUCCESS; 1444 1445 AssertReturn(VALID_PTR(pEndpoint), VERR_INVALID_POINTER); 1446 AssertReturn(VALID_PTR(paSegments), VERR_INVALID_POINTER); 1447 AssertReturn(VALID_PTR(ppTask), VERR_INVALID_POINTER); 1346 AssertPtrReturn(pEndpoint, VERR_INVALID_POINTER); 1347 AssertPtrReturn(paSegments, VERR_INVALID_POINTER); 1348 AssertPtrReturn(ppTask, VERR_INVALID_POINTER); 1448 1349 AssertReturn(cSegments > 0, VERR_INVALID_PARAMETER); 1449 1350 AssertReturn(cbRead > 0, VERR_INVALID_PARAMETER); … … 1456 1357 return VERR_NO_MEMORY; 1457 1358 1458 rc = pEndpoint->pEpClass->pEndpointOps->pfnEpRead(pTask, pEndpoint, off,1459 paSegments, cSegments, cbRead);1359 int rc = pEndpoint->pEpClass->pEndpointOps->pfnEpRead(pTask, pEndpoint, off, 1360 paSegments, cSegments, cbRead); 1460 1361 if (RT_SUCCESS(rc)) 1461 {1462 1362 *ppTask = pTask; 1463 }1464 1363 else 1465 1364 pdmR3AsyncCompletionPutTask(pEndpoint, pTask); … … 1473 1372 PPPDMASYNCCOMPLETIONTASK ppTask) 1474 1373 { 1475 int rc = VINF_SUCCESS; 1476 1477 AssertReturn(VALID_PTR(pEndpoint), VERR_INVALID_POINTER); 1478 AssertReturn(VALID_PTR(paSegments), VERR_INVALID_POINTER); 1479 AssertReturn(VALID_PTR(ppTask), VERR_INVALID_POINTER); 1374 AssertPtrReturn(pEndpoint, VERR_INVALID_POINTER); 1375 AssertPtrReturn(paSegments, VERR_INVALID_POINTER); 1376 AssertPtrReturn(ppTask, VERR_INVALID_POINTER); 1480 1377 AssertReturn(cSegments > 0, VERR_INVALID_PARAMETER); 1481 1378 AssertReturn(cbWrite > 0, VERR_INVALID_PARAMETER); … … 1488 1385 return VERR_NO_MEMORY; 1489 1386 1490 rc = pEndpoint->pEpClass->pEndpointOps->pfnEpWrite(pTask, pEndpoint, off,1491 paSegments, cSegments, cbWrite);1387 int rc = pEndpoint->pEpClass->pEndpointOps->pfnEpWrite(pTask, pEndpoint, off, 1388 paSegments, cSegments, cbWrite); 1492 1389 if (RT_SUCCESS(rc)) 1493 1390 { … … 1504 1401 PPPDMASYNCCOMPLETIONTASK ppTask) 1505 1402 { 1506 int rc = VINF_SUCCESS; 1507 1508 AssertReturn(VALID_PTR(pEndpoint), VERR_INVALID_POINTER); 1509 AssertReturn(VALID_PTR(ppTask), VERR_INVALID_POINTER); 1403 AssertPtrReturn(pEndpoint, VERR_INVALID_POINTER); 1404 AssertPtrReturn(ppTask, VERR_INVALID_POINTER); 1510 1405 1511 1406 PPDMASYNCCOMPLETIONTASK pTask; … … 1515 1410 return VERR_NO_MEMORY; 1516 1411 1517 rc = pEndpoint->pEpClass->pEndpointOps->pfnEpFlush(pTask, pEndpoint);1412 int rc = pEndpoint->pEpClass->pEndpointOps->pfnEpFlush(pTask, pEndpoint); 1518 1413 if (RT_SUCCESS(rc)) 1519 {1520 1414 *ppTask = pTask; 1521 }1522 1415 else 1523 1416 pdmR3AsyncCompletionPutTask(pEndpoint, pTask); … … 1529 1422 uint64_t *pcbSize) 1530 1423 { 1531 Assert Return(VALID_PTR(pEndpoint), VERR_INVALID_POINTER);1532 Assert Return(VALID_PTR(pcbSize), VERR_INVALID_POINTER);1424 AssertPtrReturn(pEndpoint, VERR_INVALID_POINTER); 1425 AssertPtrReturn(pcbSize, VERR_INVALID_POINTER); 1533 1426 1534 1427 if (pEndpoint->pEpClass->pEndpointOps->pfnEpGetSize) 1535 1428 return pEndpoint->pEpClass->pEndpointOps->pfnEpGetSize(pEndpoint, pcbSize); 1536 else 1537 return VERR_NOT_SUPPORTED; 1429 return VERR_NOT_SUPPORTED; 1538 1430 } 1539 1431 … … 1541 1433 uint64_t cbSize) 1542 1434 { 1543 Assert Return(VALID_PTR(pEndpoint), VERR_INVALID_POINTER);1435 AssertPtrReturn(pEndpoint, VERR_INVALID_POINTER); 1544 1436 1545 1437 if (pEndpoint->pEpClass->pEndpointOps->pfnEpSetSize) 1546 1438 return pEndpoint->pEpClass->pEndpointOps->pfnEpSetSize(pEndpoint, cbSize); 1547 else 1548 return VERR_NOT_SUPPORTED; 1439 return VERR_NOT_SUPPORTED; 1549 1440 } 1550 1441 … … 1552 1443 const char *pcszBwMgr) 1553 1444 { 1554 int rc = VINF_SUCCESS; 1555 AssertReturn(VALID_PTR(pEndpoint), VERR_INVALID_POINTER); 1445 AssertPtrReturn(pEndpoint, VERR_INVALID_POINTER); 1556 1446 PPDMACBWMGR pBwMgrOld = NULL; 1557 1447 PPDMACBWMGR pBwMgrNew = NULL; 1558 1448 1449 int rc = VINF_SUCCESS; 1559 1450 if (pcszBwMgr) 1560 1451 { 1561 1452 pBwMgrNew = pdmacBwMgrFindById(pEndpoint->pEpClass, pcszBwMgr); 1562 1563 1453 if (pBwMgrNew) 1564 1454 pdmacBwMgrRef(pBwMgrNew); … … 1570 1460 { 1571 1461 pBwMgrOld = ASMAtomicXchgPtrT(&pEndpoint->pBwMgr, pBwMgrNew, PPDMACBWMGR); 1572 1573 1462 if (pBwMgrOld) 1574 1463 pdmacBwMgrUnref(pBwMgrOld); … … 1585 1474 VMMR3DECL(int) PDMR3AsyncCompletionBwMgrSetMaxForFile(PVM pVM, const char *pcszBwMgr, uint32_t cbMaxNew) 1586 1475 { 1587 int rc = VINF_SUCCESS;1588 1476 AssertPtrReturn(pVM, VERR_INVALID_POINTER); 1589 1477 AssertPtrReturn(pcszBwMgr, VERR_INVALID_POINTER); 1590 PPDMACBWMGR pBwMgr; 1591 1592 PPDMASYNCCOMPLETIONEPCLASS pEpClass = pVM->pUVM->pdm.s.apAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_FILE]; 1593 1594 pBwMgr = pdmacBwMgrFindById(pEpClass, pcszBwMgr); 1478 1479 int rc = VINF_SUCCESS; 1480 PPDMASYNCCOMPLETIONEPCLASS pEpClass = pVM->pUVM->pdm.s.apAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_FILE]; 1481 PPDMACBWMGR pBwMgr = pdmacBwMgrFindById(pEpClass, pcszBwMgr); 1595 1482 if (pBwMgr) 1596 1483 { -
trunk/src/VBox/VMM/include/PDMAsyncCompletionInternal.h
r35346 r39014 211 211 uint32_t u32Alignment; 212 212 STAMCOUNTER StatTaskRunTimesNs[10]; 213 STAMCOUNTER StatTaskRunTimes MicroSec[10];213 STAMCOUNTER StatTaskRunTimesUs[10]; 214 214 STAMCOUNTER StatTaskRunTimesMs[10]; 215 215 STAMCOUNTER StatTaskRunTimesSec[10];
Note:
See TracChangeset
for help on using the changeset viewer.