Changeset 97928 in vbox for trunk/src/VBox/Additions/common/VBoxGuest
- Timestamp:
- Dec 31, 2022 1:23:33 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibPhysHeap.cpp
r97927 r97928 102 102 */ 103 103 #define VBGL_PH_MAX_FREE_SEARCH 16 104 105 /** Threshold to stop the block search if a free block is at least this much too big. 106 * 107 * May cause more fragmation (depending on usage pattern), but should speed up 108 * allocation and hopefully reduce cache trashing. 109 * 110 * Since we merge adjacent free blocks when we can, free blocks should typically 111 * be a lot larger that what's requested. So, it is probably a good idea to 112 * just chop up a large block rather than keep searching for a perfect-ish 113 * match. 114 * 115 * Undefine this to disable this trick. 116 */ 117 #if defined(DOXYGEN_RUNNING) || 1 118 # define VBGL_PH_STOP_SEARCH_AT_EXCESS _4K 119 #endif 104 120 105 121 /** Threshold at which to split out a tail free block when allocating. … … 490 506 VBGLPHYSHEAPBLOCK *pIter; 491 507 int32_t cLeft; 508 #ifdef VBGL_PH_STOP_SEARCH_AT_EXCESS 509 uint32_t cbAlwaysSplit; 510 #endif 492 511 int rc; 493 512 … … 498 517 AssertStmt(cbSize > 0, cbSize = sizeof(void *)); /* avoid allocating zero bytes */ 499 518 500 501 519 rc = RTSemFastMutexRequest(g_vbgldata.mutexHeap); 502 520 AssertRCReturn(rc, NULL); … … 508 526 * there to be many blocks in the heap. 509 527 */ 510 cLeft = VBGL_PH_MAX_FREE_SEARCH; 511 pBlock = NULL; 528 #ifdef VBGL_PH_STOP_SEARCH_AT_EXCESS 529 cbAlwaysSplit = cbSize + VBGL_PH_STOP_SEARCH_AT_EXCESS; 530 #endif 531 cLeft = VBGL_PH_MAX_FREE_SEARCH; 532 pBlock = NULL; 512 533 if (cbSize <= PAGE_SIZE / 4 * 3) 513 534 { … … 534 555 pFallback = pIter; 535 556 if (PAGE_SIZE - ((uintptr_t)(pIter + 1) & PAGE_OFFSET_MASK) >= cbSize) 557 { 536 558 if (!pBlock || pIter->cbDataSize < pBlock->cbDataSize) 537 559 pBlock = pIter; 560 #ifdef VBGL_PH_STOP_SEARCH_AT_EXCESS 561 else if (pIter->cbDataSize >= cbAlwaysSplit) 562 { 563 pBlock = pIter; 564 break; 565 } 566 #endif 567 } 538 568 } 539 569 … … 563 593 } 564 594 595 #ifdef VBGL_PH_STOP_SEARCH_AT_EXCESS 596 if (pIter->cbDataSize >= cbAlwaysSplit) 597 { 598 /* Really big block - no point continue searching! */ 599 pBlock = pIter; 600 break; 601 } 602 #endif 565 603 /* Looking for a free block with nearest size. */ 566 604 if (!pBlock || pIter->cbDataSize < pBlock->cbDataSize)
Note:
See TracChangeset
for help on using the changeset viewer.