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