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