소스 검색

remove unneeded allocator locks

During the creation of a new raw block, it is unnecessary to lock globally the
tls_allocator, since no other new allocation can happen in parallel. Likewise,
it is unnecessary to lock the raw block while creating, since there cannot be
any free call for this particular raw block.
Ioannis Koutras 11 년 전
부모
커밋
8ac1cf5852
2개의 변경된 파일0개의 추가작업 그리고 8개의 파일을 삭제
  1. 0 4
      src/malloc.c
  2. 0 4
      src/memalign.c

+ 0 - 4
src/malloc.c

@@ -106,16 +106,12 @@ void * malloc(size_t size) {
 
             new_raw_block = create_raw_block(sys_alloc_size, DEFAULT_RB_TYPE);
             if(new_raw_block != NULL) {
-                LOCK_GLOBAL();
-                LOCK_RAW_BLOCK(new_raw_block);
                 SLIST_INSERT_HEAD(&tls_allocator->rb_head, new_raw_block,
                         pointers);
-                UNLOCK_GLOBAL();
 
                 encapsulated_rb = (DEFAULT_RB_T *)
                     ((uintptr_t) new_raw_block + sizeof(raw_block_header_t));
                 ptr = dmmlib_malloc(encapsulated_rb, size);
-                UNLOCK_RAW_BLOCK(new_raw_block);
             }
         }
     } else {

+ 0 - 4
src/memalign.c

@@ -94,15 +94,11 @@ void *memalign(size_t alignment, size_t size) {
             raw_block = create_raw_block((size_t) SYS_ALLOC_SIZE,
                     DEFAULT_RB_TYPE);
             if(raw_block != NULL) {
-                LOCK_GLOBAL();
-                LOCK_RAW_BLOCK(raw_block);
                 SLIST_INSERT_HEAD(&tls_allocator->rb_head, raw_block, pointers);
-                UNLOCK_GLOBAL();
 
                 encapsulated_rb = (DEFAULT_RB_T *)
                     ((uintptr_t) raw_block + sizeof(raw_block_header_t));
                 memptr = freelist_memalign(encapsulated_rb, alignment, size);
-                UNLOCK_RAW_BLOCK(raw_block);
             }
         }
     } else { /* A big block has to be created */