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