Explorar el Código

Fixed coalescing after splitting

Ioannis Koutras hace 12 años
padre
commit
52e3c05928
Se han modificado 2 ficheros con 13 adiciones y 15 borrados
  1. 1 1
      DefineOptions.cmake
  2. 12 14
      src/freelist/split.c

+ 1 - 1
DefineOptions.cmake

@@ -69,7 +69,7 @@ if (LINUXTEST)
   set(MAX_COALESCE_SIZE 60000)
   set(WITH_SPLITTING "fixed")
   set(MIN_SPLITTING_SIZE 300)
-  set(COALESCE_AFTER_SPLIT OFF)
+  set(COALESCE_AFTER_SPLIT ON)
   set(WITH_SHARED_LIB ON)
   set(WITH_STATIC_LIB ON)
   set(WITH_REALLOC ON)

+ 12 - 14
src/freelist/split.c

@@ -20,6 +20,10 @@
 #include "freelist/block_header_funcs.h"
 #include "freelist/linked_lists/add_block.h"
 
+#ifdef COALESCE_AFTER_SPLIT
+#include "freelist/linked_lists/linked_lists.h" // for remove_block()
+#endif /* COALESCE_AFTER_SPLIT */
+
 void split(freelist_rb_t *raw_block, block_header_t *ptr, size_t req_size) {
     size_t new_size;
     size_t min_split_size;
@@ -29,7 +33,7 @@ void split(freelist_rb_t *raw_block, block_header_t *ptr, size_t req_size) {
     block_header_t *next_block;
     size_t current_next_size;
 
-    next_block = get_dlnext(allocator, ptr);
+    next_block = get_dlnext(raw_block, ptr);
 #endif /* COALESCE_AFTER_SPLIT */
 
     /* Check what would be the size of the new block if we split the current
@@ -72,20 +76,14 @@ void split(freelist_rb_t *raw_block, block_header_t *ptr, size_t req_size) {
     max_coal_size = heap->dmm_knobs.max_coalesce_size;
 #endif /* COALESCING_VARIABLE */
 
-    if(next_block != (memory_block_ptr) NULL) {
-        if(is_free(next_block) == true) {
-            current_next_size = new_size + get_size(next_block) +
-                HEADER_SIZE;
-            if(current_next_size <= max_coal_size) {
-                /* it's ok to coalesce the new split block with the next
-                 * free block
-                 */
-                remove_block_from_lists(&next_block, heap);
-                if(allocator->border_ptr == next_block) {
-                    allocator->border_ptr = ptr;
-                }
-                new_size = current_next_size;
+    if(next_block != NULL && is_free(next_block) == true) {
+        current_next_size = new_size + get_size(next_block) + HEADER_SIZE;
+        if(current_next_size <= max_coal_size) {
+            remove_block(next_block, raw_block);
+            if(raw_block->border_ptr == next_block) {
+                raw_block->border_ptr = new_block;
             }
+            new_size = current_next_size;
         }
     }