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