Loading...
--- libmalloc/libmalloc-374.60.3/src/magazine_small.c
+++ libmalloc/libmalloc-317.100.9/src/magazine_small.c
@@ -933,32 +933,22 @@
// Appropriate a Depot'd region that can satisfy requested msize.
region_trailer_t *node;
region_t sparse_region;
- msize_t try_msize = msize;
while (1) {
- sparse_region = small_find_msize_region(rack, depot_ptr, DEPOT_MAGAZINE_INDEX, try_msize);
+ sparse_region = small_find_msize_region(rack, depot_ptr, DEPOT_MAGAZINE_INDEX, msize);
if (NULL == sparse_region) { // Depot empty?
SZONE_MAGAZINE_PTR_UNLOCK(depot_ptr);
return 0;
}
node = REGION_TRAILER_FOR_SMALL_REGION(sparse_region);
- if (0 == node->pinned_to_depot) {
- // Found one!
+ if (0 >= node->pinned_to_depot) {
break;
}
- // Try the next msize up - maybe the head of its free list will be in
- // a region we can use. Once we get the region we'll still allocate the
- // original msize.
- try_msize++;
-
- if (try_msize > NUM_SMALL_SLOTS) {
- // Tried all the msizes but couldn't get a usable region. Let's
- // give up for now and we'll allocate a new region from the kernel.
- SZONE_MAGAZINE_PTR_UNLOCK(depot_ptr);
- return 0;
- }
+ SZONE_MAGAZINE_PTR_UNLOCK(depot_ptr);
+ yield();
+ SZONE_MAGAZINE_PTR_LOCK(depot_ptr);
}
// disconnect node from Depot
@@ -969,7 +959,7 @@
// Transfer ownership of the region
MAGAZINE_INDEX_FOR_SMALL_REGION(sparse_region) = mag_index;
- MALLOC_ASSERT(node->pinned_to_depot == 0);
+ node->pinned_to_depot = 0;
// Iterate the region putting its free entries on its new (locked) magazine's free list
size_t bytes_inplay = small_free_reattach_region(rack, small_mag_ptr, sparse_region);
@@ -1041,11 +1031,6 @@
continue;
}
- if (REGION_TRAILER_FOR_SMALL_REGION(small)->pinned_to_depot > 0) {
- SZONE_MAGAZINE_PTR_UNLOCK(mag_ptr);
- continue;
- }
-
if (small == mag_ptr->mag_last_region && (mag_ptr->mag_bytes_free_at_end || mag_ptr->mag_bytes_free_at_start)) {
small_finalize_region(rack, mag_ptr);
}
@@ -1060,7 +1045,7 @@
SZONE_MAGAZINE_PTR_LOCK(small_depot_ptr);
MAGAZINE_INDEX_FOR_SMALL_REGION(small) = DEPOT_MAGAZINE_INDEX;
- MALLOC_ASSERT(REGION_TRAILER_FOR_SMALL_REGION(small)->pinned_to_depot == 0);
+ REGION_TRAILER_FOR_SMALL_REGION(small)->pinned_to_depot = 0;
size_t bytes_inplay = small_free_reattach_region(rack, small_depot_ptr, small);