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