From dd93062413c3bf52f11b646cacb1fb4a681011ff Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 25 Apr 2021 14:32:05 +0800 Subject: [PATCH 1/2] Remove the initialization of mem_table_changed from _dmalloc_chunk_startup since the same thing is already done in _dmalloc_chunk_log_changed Signed-off-by: Xiang Xiao Change-Id: I548bfc4b1d92474c58ae8d6e49394f6d4fce8842 --- chunk.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/chunk.c b/chunk.c index 9f3d52f8..ee269fa6 100644 --- a/chunk.c +++ b/chunk.c @@ -1774,9 +1774,6 @@ int _dmalloc_chunk_startup(void) _dmalloc_table_init(&mem_table_alloc, mem_table_alloc_entries, sizeof(mem_table_alloc_entries) / sizeof(*mem_table_alloc_entries)); - _dmalloc_table_init(&mem_table_changed, mem_table_changed_entries, - sizeof(mem_table_changed_entries) / - sizeof(*mem_table_changed_entries)); return 1; } From f7c14c9cc1600c28d38f8b68fa5daacdf59316db Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Mon, 26 Apr 2021 00:03:24 +0800 Subject: [PATCH 2/2] Don't initialize mem_table_alloc if MEMORY_TABLE_TOP_LOG equal 0 and change MEM_ALLOC_ENTRIES 2 times MEMORY_TABLE_TOP_LOG Signed-off-by: Xiang Xiao Change-Id: I6d7a30ce40f67e9573a69e27886a8ac14e83ee9d --- chunk.c | 6 +++++- chunk_loc.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/chunk.c b/chunk.c index ee269fa6..fb3f1fa9 100644 --- a/chunk.c +++ b/chunk.c @@ -128,10 +128,12 @@ static char fence_top[FENCE_TOP_SIZE]; static int bit_sizes[BASIC_BLOCK]; /* number bits for div-blocks*/ /* memory tables */ +#if MEMORY_TABLE_TOP_LOG static mem_table_t mem_table_alloc; static mem_entry_t mem_table_alloc_entries[MEM_ALLOC_ENTRIES]; +#endif static mem_table_t mem_table_changed; -static mem_entry_t mem_table_changed_entries[MEM_ALLOC_ENTRIES]; +static mem_entry_t mem_table_changed_entries[MEM_CHANGED_ENTRIES]; /* memory stats */ static unsigned long alloc_current = 0; /* current memory usage */ @@ -1771,9 +1773,11 @@ int _dmalloc_chunk_startup(void) skip_free_list->sa_flags = ALLOC_FLAG_ADMIN; skip_address_list->sa_flags = ALLOC_FLAG_ADMIN; +#if MEMORY_TABLE_TOP_LOG _dmalloc_table_init(&mem_table_alloc, mem_table_alloc_entries, sizeof(mem_table_alloc_entries) / sizeof(*mem_table_alloc_entries)); +#endif return 1; } diff --git a/chunk_loc.h b/chunk_loc.h index f9f43a71..aa5dcfd1 100644 --- a/chunk_loc.h +++ b/chunk_loc.h @@ -55,7 +55,7 @@ #define MAX_SKIP_LEVEL 32 /* memory table settings */ -#define MEM_ALLOC_ENTRIES (MEMORY_TABLE_SIZE * 2) +#define MEM_ALLOC_ENTRIES (MEMORY_TABLE_TOP_LOG * 2) #define MEM_CHANGED_ENTRIES (MEMORY_TABLE_SIZE * 2) /* NOTE: FENCE_BOTTOM_SIZE and FENCE_TOP_SIZE defined in settings.h */