From d7ddc1cd3af86198ffca2d1958871d4c2c04bd9e Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Thu, 21 Mar 2019 19:51:30 +0200 Subject: [PATCH 208/221] mem-pool: remove dead code. Upstream patch: > Change-Id: I3bbda719027b45e1289db2e6a718627141bcbdc8 > Upstream patch link: https://review.gluster.org/c/glusterfs/+/22394 > BUG: 1193929 > Signed-off-by: Yaniv Kaul Updates: bz#1722801 Change-Id: I3bbda719027b45e1289db2e6a718627141bcbdc8 Signed-off-by: Yaniv Kaul Reviewed-on: https://code.engineering.redhat.com/gerrit/174710 Tested-by: RHGS Build Bot Reviewed-by: Atin Mukherjee --- libglusterfs/src/glusterfs/mem-pool.h | 11 ------ libglusterfs/src/mem-pool.c | 70 ----------------------------------- 2 files changed, 81 deletions(-) diff --git a/libglusterfs/src/glusterfs/mem-pool.h b/libglusterfs/src/glusterfs/mem-pool.h index 90905fb..0250b59 100644 --- a/libglusterfs/src/glusterfs/mem-pool.h +++ b/libglusterfs/src/glusterfs/mem-pool.h @@ -308,15 +308,4 @@ mem_pool_destroy(struct mem_pool *pool); void gf_mem_acct_enable_set(void *ctx); -/* hit will be set to : - * _gf_true if the memory is served from mem pool - * _gf_false if the requested size was not present in mem pool and hence - * std alloc'd. - */ -void * -mem_pool_get(unsigned long sizeof_type, gf_boolean_t *hit); - -void * -mem_pool_get0(unsigned long sizeof_type, gf_boolean_t *hit); - #endif /* _MEM_POOL_H */ diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c index 3934a78..9b4ea52 100644 --- a/libglusterfs/src/mem-pool.c +++ b/libglusterfs/src/mem-pool.c @@ -365,10 +365,6 @@ static size_t pool_list_size; #define N_COLD_LISTS 1024 #define POOL_SWEEP_SECS 30 -static unsigned long sweep_times; -static unsigned long sweep_usecs; -static unsigned long frees_to_system; - typedef struct { struct list_head death_row; pooled_obj_hdr_t *cold_lists[N_COLD_LISTS]; @@ -426,7 +422,6 @@ free_obj_list(pooled_obj_hdr_t *victim) next = victim->next; free(victim); victim = next; - ++frees_to_system; } } @@ -438,9 +433,6 @@ pool_sweeper(void *arg) per_thread_pool_list_t *next_pl; per_thread_pool_t *pt_pool; unsigned int i; - struct timeval begin_time; - struct timeval end_time; - struct timeval elapsed; gf_boolean_t poisoned; /* @@ -457,7 +449,6 @@ pool_sweeper(void *arg) state.n_cold_lists = 0; /* First pass: collect stuff that needs our attention. */ - (void)gettimeofday(&begin_time, NULL); (void)pthread_mutex_lock(&pool_lock); list_for_each_entry_safe(pool_list, next_pl, &pool_threads, thr_list) { @@ -470,10 +461,6 @@ pool_sweeper(void *arg) } } (void)pthread_mutex_unlock(&pool_lock); - (void)gettimeofday(&end_time, NULL); - timersub(&end_time, &begin_time, &elapsed); - sweep_usecs += elapsed.tv_sec * 1000000 + elapsed.tv_usec; - sweep_times += 1; /* Second pass: free dead pools. */ (void)pthread_mutex_lock(&pool_free_lock); @@ -879,63 +866,6 @@ mem_get(struct mem_pool *mem_pool) #endif /* GF_DISABLE_MEMPOOL */ } -void * -mem_pool_get(unsigned long sizeof_type, gf_boolean_t *hit) -{ -#if defined(GF_DISABLE_MEMPOOL) - return GF_MALLOC(sizeof_type, gf_common_mt_mem_pool); -#else - pooled_obj_hdr_t *retval; - unsigned int power; - struct mem_pool_shared *pool = NULL; - - if (!sizeof_type) { - gf_msg_callingfn("mem-pool", GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ARG, - "invalid argument"); - return NULL; - } - - /* We ensure sizeof_type > 1 and the next power of two will be, at least, - * 2^POOL_SMALLEST */ - sizeof_type |= (1 << POOL_SMALLEST) - 1; - power = sizeof(sizeof_type) * 8 - __builtin_clzl(sizeof_type - 1) + 1; - if (power > POOL_LARGEST) { - gf_msg_callingfn("mem-pool", GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ARG, - "invalid argument"); - return NULL; - } - pool = &pools[power - POOL_SMALLEST]; - - retval = mem_get_from_pool(NULL, pool, hit); - - return retval + 1; -#endif /* GF_DISABLE_MEMPOOL */ -} - -void * -mem_pool_get0(unsigned long sizeof_type, gf_boolean_t *hit) -{ - void *ptr = NULL; - unsigned int power; - struct mem_pool_shared *pool = NULL; - - ptr = mem_pool_get(sizeof_type, hit); - if (ptr) { -#if defined(GF_DISABLE_MEMPOOL) - memset(ptr, 0, sizeof_type); -#else - /* We ensure sizeof_type > 1 and the next power of two will be, at - * least, 2^POOL_SMALLEST */ - sizeof_type |= (1 << POOL_SMALLEST) - 1; - power = sizeof(sizeof_type) * 8 - __builtin_clzl(sizeof_type - 1) + 1; - pool = &pools[power - POOL_SMALLEST]; - memset(ptr, 0, AVAILABLE_SIZE(pool->power_of_two)); -#endif - } - - return ptr; -} - void mem_put(void *ptr) { -- 1.8.3.1