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