- Timestamp:
- Nov 8, 2021 12:22:09 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 148109
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-memalloc-1.c64
r92266 r92267 49 49 50 50 51 /** 52 * For subsequence touch iterations that doesn't allocate any RAM. 53 * 54 * This may cause page pool activitiy if we've got more memory than we have room 55 * for in the pool. This depends on amount of guest RAM and how much could be 56 * backed by large pages. 57 */ 51 58 static uint64_t CheckTouchedMemory(void) 52 59 { … … 56 63 for (iEntry = 0; iEntry < g_cEntries; iEntry++) 57 64 { 58 uint64_t *pu64Cur = (uint64_t *)g_aEntries[iEntry].uBaseAddr;59 uint64_t cbLeft = g_aEntries[iEntry].cbRange;65 uint64_t volatile *pu64Cur = (uint64_t *)g_aEntries[iEntry].uBaseAddr; 66 uint64_t cbLeft = g_aEntries[iEntry].cbRange; 60 67 while (cbLeft >= X86_PAGE_SIZE) 61 68 { 62 if ( pu64Cur[0] == iPage 63 && pu64Cur[1] == iPage) 69 /* Check first. */ 70 if (RT_LIKELY( pu64Cur[0] == iPage 71 && pu64Cur[1] == iPage)) 64 72 { /* likely */ } 65 73 else … … 69 77 } 70 78 79 /* Then write again. */ 80 pu64Cur[0] = iPage; 81 pu64Cur[1] = iPage; 82 83 /* Advance. */ 71 84 iPage++; 72 85 pu64Cur += X86_PAGE_SIZE / sizeof(*pu64Cur); … … 78 91 79 92 80 static uint64_t TouchMemory(void) 93 /** 94 * First touching of memory, assuming content is ZERO. 95 */ 96 static uint64_t FirstTouchMemory(void) 81 97 { 82 98 unsigned iEntry; … … 84 100 for (iEntry = 0; iEntry < g_cEntries; iEntry++) 85 101 { 86 uint64_t *pu64Cur = (uint64_t*)g_aEntries[iEntry].uBaseAddr;87 uint64_t cbLeft = g_aEntries[iEntry].cbRange;102 uint64_t volatile *pu64Cur = (uint64_t volatile *)g_aEntries[iEntry].uBaseAddr; 103 uint64_t cbLeft = g_aEntries[iEntry].cbRange; 88 104 while (cbLeft >= X86_PAGE_SIZE) 89 105 { 106 /* 107 * Write to the page first so we won't waste time mapping the zero 108 * page and get straight to the actual page allocation. 109 */ 90 110 pu64Cur[0] = iPage; 91 if (pu64Cur[1] != 0) 111 112 /* Then check that the 2nd qword is zero before writing it. */ 113 if (RT_LIKELY(pu64Cur[1] == 0)) 114 { /* likely */ } 115 else 92 116 Bs3TestFailedF("%p: %#llx, expected zero\n", pu64Cur, pu64Cur[1]); 93 117 pu64Cur[1] = iPage; 94 118 119 /* Advance. */ 95 120 iPage++; 96 121 pu64Cur += X86_PAGE_SIZE / sizeof(*pu64Cur); … … 174 199 g_cEntries, g_cbInteresting, (unsigned)(g_cbInteresting / _1G), g_uInterestingStart, g_uInterestingEnd); 175 200 201 if (g_uBs3EndOfRamAbove4G < g_uInterestingEnd) 202 Bs3TestFailedF("g_uBs3EndOfRamAbove4G (%#llx) is lower than g_uInterestingEnd (%#llx)!\n", 203 g_uBs3EndOfRamAbove4G, g_uInterestingEnd); 204 205 176 206 /* 177 207 * Map all the memory (Bs3Kit only maps memory below 4G). … … 184 214 else if (RT_SUCCESS(rc = Bs3PagingMapRamAbove4GForLM(&uFailurePoint))) 185 215 { 216 #define PAGES_2_MB(a_cPages) ((a_cPages) / (_1M / X86_PAGE_SIZE)) 217 uint64_t cTotalPages; 218 219 /* 220 * Time touching all the memory. 221 */ 186 222 Bs3TestSub("Allocation speed"); 187 223 { 188 /*189 * Time touching all the memory.190 */191 224 uint64_t const nsStart = Bs3TestNow(); 192 225 uint64_t const uTscStart = ASMReadTSC(); 193 uint64_t const cPages = TouchMemory();226 uint64_t const cPages = FirstTouchMemory(); 194 227 uint64_t const cTicksElapsed = ASMReadTSC() - uTscStart; 195 228 uint64_t const cNsElapsed = Bs3TestNow() - nsStart; 196 229 uint64_t uThruput; 197 #define PAGES_2_MB(a_cPages) ((a_cPages) / (_1M / X86_PAGE_SIZE))198 230 Bs3TestValue("Pages", cPages, VMMDEV_TESTING_UNIT_PAGES); 199 231 Bs3TestValue("MiBs", PAGES_2_MB(cPages), VMMDEV_TESTING_UNIT_MEGABYTES); 200 Bs3TestValue(" Elapsed",cNsElapsed, VMMDEV_TESTING_UNIT_NS);201 Bs3TestValue(" Elapsed in ticks",cTicksElapsed, VMMDEV_TESTING_UNIT_TICKS);232 Bs3TestValue("Alloc elapsed", cNsElapsed, VMMDEV_TESTING_UNIT_NS); 233 Bs3TestValue("Alloc elapsed in ticks", cTicksElapsed, VMMDEV_TESTING_UNIT_TICKS); 202 234 Bs3TestValue("Page alloc time", cNsElapsed / cPages, VMMDEV_TESTING_UNIT_NS_PER_PAGE); 203 235 Bs3TestValue("Page alloc time in ticks", cTicksElapsed / cPages, VMMDEV_TESTING_UNIT_TICKS_PER_PAGE); 204 236 uThruput = cPages * RT_NS_1SEC / cNsElapsed; 205 Bs3TestValue("Thruput", uThruput, VMMDEV_TESTING_UNIT_PAGES_PER_SEC); 206 Bs3TestValue("Thruput in MiBs", PAGES_2_MB(uThruput), VMMDEV_TESTING_UNIT_MEGABYTES_PER_SEC); 207 CheckTouchedMemory(); 237 Bs3TestValue("Alloc thruput", uThruput, VMMDEV_TESTING_UNIT_PAGES_PER_SEC); 238 Bs3TestValue("Alloc thruput in MiBs", PAGES_2_MB(uThruput), VMMDEV_TESTING_UNIT_MEGABYTES_PER_SEC); 239 cTotalPages = cPages; 240 } 241 242 /* 243 * Time accessing all the memory again. This might give a clue as to page pool performance. 244 */ 245 for (unsigned iLoop = 0; iLoop < 2; iLoop++) 246 { 247 Bs3TestSub(iLoop == 0 ? "2nd access" : "3rd access"); 248 { 249 uint64_t const nsStart = Bs3TestNow(); 250 uint64_t const uTscStart = ASMReadTSC(); 251 uint64_t const cErrors = CheckTouchedMemory(); 252 uint64_t const cTicksElapsed = ASMReadTSC() - uTscStart; 253 uint64_t const cNsElapsed = Bs3TestNow() - nsStart; 254 uint64_t uThruput; 255 Bs3TestValue("Access elapsed", cNsElapsed, VMMDEV_TESTING_UNIT_NS); 256 Bs3TestValue("Access elapsed in ticks", cTicksElapsed, VMMDEV_TESTING_UNIT_TICKS); 257 Bs3TestValue("Page access time", cNsElapsed / cTotalPages, VMMDEV_TESTING_UNIT_NS_PER_PAGE); 258 Bs3TestValue("Page access time in ticks", cTicksElapsed / cTotalPages, VMMDEV_TESTING_UNIT_TICKS_PER_PAGE); 259 uThruput = cTotalPages * RT_NS_1SEC / cNsElapsed; 260 Bs3TestValue("Access thruput", uThruput, VMMDEV_TESTING_UNIT_PAGES_PER_SEC); 261 Bs3TestValue("Access thruput in MiBs", PAGES_2_MB(uThruput), VMMDEV_TESTING_UNIT_MEGABYTES_PER_SEC); 262 } 208 263 } 209 264 }
Note:
See TracChangeset
for help on using the changeset viewer.