summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli.c13
-rw-r--r--glusterfsd/src/glusterfsd.c19
-rw-r--r--libglusterfs/src/stack.h41
3 files changed, 59 insertions, 14 deletions
diff --git a/cli/src/cli.c b/cli/src/cli.c
index efa41eb8507..ad70696e258 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -208,6 +208,19 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
cli_mt_call_pool_t);
if (!pool)
return -1;
+
+ /* frame_mem_pool size 112 * 16k */
+ pool->frame_mem_pool = mem_pool_new (call_frame_t, 16384);
+
+ if (!pool->frame_mem_pool)
+ return -1;
+
+ /* stack_mem_pool size 256 * 8k */
+ pool->stack_mem_pool = mem_pool_new (call_stack_t, 8192);
+
+ if (!pool->stack_mem_pool)
+ return -1;
+
INIT_LIST_HEAD (&pool->all_frames);
LOCK_INIT (&pool->lock);
ctx->pool = pool;
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index 7fd4478800f..24c45219b01 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -584,11 +584,17 @@ static void
cleanup_and_exit (int signum)
{
glusterfs_ctx_t *ctx = NULL;
+ call_pool_t *tmp_pool = NULL;
ctx = glusterfs_ctx_get ();
gf_log ("glusterfsd", GF_LOG_NORMAL, "shutting down");
+ tmp_pool = ctx->pool;
+ mem_pool_destroy (tmp_pool->frame_mem_pool);
+ mem_pool_destroy (tmp_pool->stack_mem_pool);
+ tmp_pool = NULL;
+
glusterfs_pidfile_cleanup (ctx);
exit (0);
@@ -772,6 +778,19 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
gfd_mt_call_pool_t);
if (!pool)
return -1;
+
+ /* frame_mem_pool size 112 * 16k */
+ pool->frame_mem_pool = mem_pool_new (call_frame_t, 16384);
+
+ if (!pool->frame_mem_pool)
+ return -1;
+
+ /* stack_mem_pool size 256 * 8k */
+ pool->stack_mem_pool = mem_pool_new (call_stack_t, 8192);
+
+ if (!pool->stack_mem_pool)
+ return -1;
+
INIT_LIST_HEAD (&pool->all_frames);
LOCK_INIT (&pool->lock);
ctx->pool = pool;
diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h
index 6015b8158b0..ad8abe1ea1c 100644
--- a/libglusterfs/src/stack.h
+++ b/libglusterfs/src/stack.h
@@ -62,6 +62,8 @@ struct _call_pool_t {
};
int64_t cnt;
gf_lock_t lock;
+ struct mem_pool *frame_mem_pool;
+ struct mem_pool *stack_mem_pool;
};
struct _call_frame_t {
@@ -129,14 +131,22 @@ gf_update_latency (call_frame_t *frame);
static inline void
FRAME_DESTROY (call_frame_t *frame)
{
+ void *local = NULL;
if (frame->next)
frame->next->prev = frame->prev;
if (frame->prev)
frame->prev->next = frame->next;
- if (frame->local)
- GF_FREE (frame->local);
+ if (frame->local) {
+ local = frame->local;
+ frame->local = NULL;
+
+ }
+
LOCK_DESTROY (&frame->lock);
- GF_FREE (frame);
+ mem_put (frame->root->pool->frame_mem_pool, frame);
+
+ if (local)
+ GF_FREE (local);
}
@@ -144,6 +154,7 @@ static inline void
STACK_DESTROY (call_stack_t *stack)
{
glusterfs_ctx_t *ctx = glusterfs_ctx_get ();
+ void *local = NULL;
if (ctx && ctx->measure_latency) {
gettimeofday (&stack->frames.end, NULL);
@@ -157,8 +168,10 @@ STACK_DESTROY (call_stack_t *stack)
}
UNLOCK (&stack->pool->lock);
- if (stack->frames.local)
- GF_FREE (stack->frames.local);
+ if (stack->frames.local) {
+ local = stack->frames.local;
+ stack->frames.local = NULL;
+ }
LOCK_DESTROY (&stack->frames.lock);
@@ -169,7 +182,10 @@ STACK_DESTROY (call_stack_t *stack)
FRAME_DESTROY (stack->frames.next);
}
- GF_FREE (stack);
+ mem_put (stack->pool->stack_mem_pool, stack);
+
+ if (local)
+ GF_FREE (local);
}
@@ -181,9 +197,8 @@ STACK_DESTROY (call_stack_t *stack)
do { \
call_frame_t *_new = NULL; \
xlator_t *old_THIS = NULL; \
- \
- _new = GF_CALLOC (1, sizeof (call_frame_t), \
- gf_common_mt_call_frame_t); \
+ \
+ _new = mem_get (frame->root->pool->frame_mem_pool); \
if (!_new) { \
gf_log ("stack", GF_LOG_ERROR, "alloc failed"); \
break; \
@@ -220,8 +235,7 @@ STACK_DESTROY (call_stack_t *stack)
call_frame_t *_new = NULL; \
xlator_t *old_THIS = NULL; \
\
- _new = GF_CALLOC (1, sizeof (call_frame_t), \
- gf_common_mt_call_frame_t); \
+ _new = mem_get(frame->root->pool->frame_mem_pool); \
if (!_new) { \
gf_log ("stack", GF_LOG_ERROR, "alloc failed"); \
break; \
@@ -316,8 +330,7 @@ copy_frame (call_frame_t *frame)
return NULL;
}
- newstack = (void *) GF_CALLOC (1, sizeof (*newstack),
- gf_common_mt_call_stack_t);
+ newstack = mem_get (frame->root->pool->stack_mem_pool);
if (newstack == NULL) {
return NULL;
}
@@ -360,7 +373,7 @@ create_frame (xlator_t *xl, call_pool_t *pool)
return NULL;
}
- stack = GF_CALLOC (1, sizeof (*stack),gf_common_mt_call_stack_t);
+ stack = mem_get (pool->stack_mem_pool);
if (!stack)
return NULL;