summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac10
-rw-r--r--libglusterfs/src/mem-pool.c18
2 files changed, 26 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 28c6b5c2f25..cb6b4616ddb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1211,6 +1211,15 @@ AC_ARG_ENABLE([debug],
AC_HELP_STRING([--enable-debug],
[Enable debug build options.]))
+AC_ARG_ENABLE([mempool],
+ AC_HELP_STRING([--disable-mempool],
+ [Disable the Gluster memory pooler.]))
+
+USE_MEMPOOL="yes"
+if test "x$enable_mempool" = "xno"; then
+ USE_MEMPOOL="no"
+ AC_DEFINE(GF_DISABLE_MEMPOOL, 1, [Disable the Gluster memory pooler.])
+fi
# syslog section
AC_ARG_ENABLE([syslog],
@@ -1530,4 +1539,5 @@ echo "firewalld-config : $BUILD_FIREWALLD"
echo "Experimental xlators : $BUILD_EXPERIMENTAL"
echo "Events : $BUILD_EVENTS"
echo "EC dynamic support : $EC_DYNAMIC_SUPPORT"
+echo "Use memory pools : $USE_MEMPOOL"
echo
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index 88fbdf58319..b11e4c72e12 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -391,6 +391,7 @@ mem_pool_new_fn (unsigned long sizeof_type,
return NULL;
}
+#if !defined(GF_DISABLE_MEMPOOL)
LOCK_INIT (&mem_pool->lock);
INIT_LIST_HEAD (&mem_pool->list);
INIT_LIST_HEAD (&mem_pool->global_list);
@@ -429,6 +430,7 @@ mem_pool_new_fn (unsigned long sizeof_type,
UNLOCK (&ctx->lock);
out:
+#endif /* GF_DISABLE_MEMPOOL */
return mem_pool;
}
@@ -454,6 +456,10 @@ mem_get0 (struct mem_pool *mem_pool)
void *
mem_get (struct mem_pool *mem_pool)
{
+#ifdef GF_DISABLE_MEMPOOL
+ return GF_CALLOC (1, mem_pool->real_sizeof_type,
+ gf_common_mt_mem_pool);
+#else
struct list_head *list = NULL;
void *ptr = NULL;
int *in_use = NULL;
@@ -525,9 +531,11 @@ fwd_addr_out:
UNLOCK (&mem_pool->lock);
return ptr;
+#endif /* GF_DISABLE_MEMPOOL */
}
+#if !defined(GF_DISABLE_MEMPOOL)
static int
__is_member (struct mem_pool *pool, void *ptr)
{
@@ -546,11 +554,16 @@ __is_member (struct mem_pool *pool, void *ptr)
return 1;
}
+#endif
void
mem_put (void *ptr)
{
+#ifdef GF_DISABLE_MEMPOOL
+ GF_FREE (ptr);
+ return;
+#else
struct list_head *list = NULL;
int *in_use = NULL;
void *head = NULL;
@@ -628,6 +641,7 @@ mem_put (void *ptr)
}
}
UNLOCK (&pool->lock);
+#endif /* GF_DISABLE_MEMPOOL */
}
void
@@ -640,12 +654,12 @@ mem_pool_destroy (struct mem_pool *pool)
"max=%d total=%"PRIu64, pool->padded_sizeof_type,
pool->max_alloc, pool->alloc_count);
+#if !defined(GF_DISABLE_MEMPOOL)
list_del (&pool->global_list);
LOCK_DESTROY (&pool->lock);
GF_FREE (pool->name);
GF_FREE (pool->pool);
+#endif
GF_FREE (pool);
-
- return;
}