From 160abe2685548c91221a824b8309797a1869f504 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 7 Feb 2010 02:02:13 +0000 Subject: [PATCH] Sync two locking changes from kernel heap. This just moves the page locking into the contiguous page allocation function and unlocks a bin locker a bit earlier. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35424 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/libroot/posix/malloc_debug/heap.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/system/libroot/posix/malloc_debug/heap.cpp b/src/system/libroot/posix/malloc_debug/heap.cpp index 1307d829ec..3f6a4f8c31 100644 --- a/src/system/libroot/posix/malloc_debug/heap.cpp +++ b/src/system/libroot/posix/malloc_debug/heap.cpp @@ -919,6 +919,7 @@ static heap_page * heap_allocate_contiguous_pages(heap_allocator *heap, uint32 pageCount, size_t alignment) { + MutexLocker pageLocker(heap->page_lock); heap_area *area = heap->areas; while (area) { if (area->free_page_count < pageCount) { @@ -1000,7 +1001,6 @@ heap_raw_alloc(heap_allocator *heap, size_t size, size_t alignment) INFO(("heap %p: allocate %lu bytes from raw pages with alignment %lu\n", heap, size, alignment)); - MutexLocker pageLocker(heap->page_lock); uint32 pageCount = (size + heap->page_size - 1) / heap->page_size; heap_page *firstPage = heap_allocate_contiguous_pages(heap, pageCount, alignment); @@ -1079,6 +1079,7 @@ heap_allocate_from_bin(heap_allocator *heap, uint32 binIndex, size_t size) page->next = page->prev = NULL; } + binLocker.Unlock(); heap_add_leak_check_info((addr_t)address, bin->element_size, size); return address; }