Ticket #1920: heap_large_alloc.diff

File heap_large_alloc.diff, 1.2 KB (added by mmlr, 13 years ago)

Use the first allocation page as allocation_id

  • src/system/kernel/heap.cpp

     
    5959} heap_page;
    6060
    6161// used for bin == bin_count allocations
    62 #define allocation_id free_count
     62#define allocation_id empty_index
    6363
    6464typedef struct heap_bin_s {
    6565    uint32      element_size;
     
    7171    addr_t      base;
    7272    size_t      size;
    7373    mutex       lock;
    74     vint32      large_alloc_id;
    7574
    7675    uint32      bin_count;
    7776    uint32      page_count;
     
    536535}
    537536
    538537
    539 static inline uint32
    540 heap_next_alloc_id(heap_allocator *heap)
    541 {
    542     return atomic_add(&heap->large_alloc_id, 1) & ((1 << 9) - 1);
    543 }
    544 
    545 
    546538static inline void
    547539heap_link_page(heap_page *page, heap_page **list)
    548540{
     
    672664        return NULL;
    673665    }
    674666
    675     uint32 allocationID = heap_next_alloc_id(heap);
    676667    uint32 pageCount = (size + B_PAGE_SIZE - 1) / B_PAGE_SIZE;
    677668    for (uint32 i = first; i < first + pageCount; i++) {
    678669        heap_page *page = &heap->page_table[i];
     
    683674
    684675        page->next = page->prev = NULL;
    685676        page->free_list = NULL;
    686         page->allocation_id = allocationID;
     677        page->allocation_id = (uint16)first;
    687678    }
    688679
    689680#if KERNEL_HEAP_LEAK_CHECK