diff options
Diffstat (limited to 'libglusterfs/src/glusterfs')
| -rw-r--r-- | libglusterfs/src/glusterfs/common-utils.h | 5 | ||||
| -rw-r--r-- | libglusterfs/src/glusterfs/glusterfs.h | 5 | ||||
| -rw-r--r-- | libglusterfs/src/glusterfs/mem-pool.h | 22 |
3 files changed, 25 insertions, 7 deletions
diff --git a/libglusterfs/src/glusterfs/common-utils.h b/libglusterfs/src/glusterfs/common-utils.h index 075a355f786..55d8f8cc931 100644 --- a/libglusterfs/src/glusterfs/common-utils.h +++ b/libglusterfs/src/glusterfs/common-utils.h @@ -151,11 +151,6 @@ trap(void); #define GF_THREAD_NAME_PREFIX "glfs_" #define GF_THREAD_NAME_PREFIX_LEN 5 -#include <stdbool.h> -#define gf_boolean_t bool -#define _gf_false false -#define _gf_true true - /* * we could have initialized these as +ve values and treated * them as negative while comparing etc.. (which would have diff --git a/libglusterfs/src/glusterfs/glusterfs.h b/libglusterfs/src/glusterfs/glusterfs.h index 9f14f2f5440..325241818c0 100644 --- a/libglusterfs/src/glusterfs/glusterfs.h +++ b/libglusterfs/src/glusterfs/glusterfs.h @@ -14,6 +14,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include <stdbool.h> #include <netinet/in.h> #include <sys/socket.h> #include <sys/types.h> @@ -369,6 +370,10 @@ enum gf_internal_fop_indicator { #define GF_CS_OBJECT_STATUS "trusted.glusterfs.cs.status" #define GF_CS_OBJECT_REPAIR "trusted.glusterfs.cs.repair" +#define gf_boolean_t bool +#define _gf_false false +#define _gf_true true + typedef enum { GF_CS_LOCAL = 1, GF_CS_REMOTE = 2, diff --git a/libglusterfs/src/glusterfs/mem-pool.h b/libglusterfs/src/glusterfs/mem-pool.h index 1c7e868ab75..90905fb6ba4 100644 --- a/libglusterfs/src/glusterfs/mem-pool.h +++ b/libglusterfs/src/glusterfs/mem-pool.h @@ -38,6 +38,10 @@ #define GF_MEM_TRAILER_MAGIC 0xBAADF00D #define GF_MEM_INVALID_MAGIC 0xDEADC0DE +#define POOL_SMALLEST 7 /* i.e. 128 */ +#define POOL_LARGEST 20 /* i.e. 1048576 */ +#define NPOOLS (POOL_LARGEST - POOL_SMALLEST + 1) + struct mem_acct_rec { const char *typestr; uint64_t size; @@ -207,7 +211,10 @@ struct mem_pool { unsigned long count; /* requested pool size (unused) */ char *name; gf_atomic_t active; /* current allocations */ - +#ifdef DEBUG + gf_atomic_t hit; /* number of allocations served from pt_pool */ + gf_atomic_t miss; /* number of std allocs due to miss */ +#endif struct list_head owner; /* glusterfs_ctx_t->mempool_list */ glusterfs_ctx_t *ctx; /* take ctx->lock when updating owner */ @@ -224,7 +231,7 @@ typedef struct pooled_obj_hdr { struct mem_pool *pool; } pooled_obj_hdr_t; -#define AVAILABLE_SIZE(p2) ((1 << (p2)) - sizeof(pooled_obj_hdr_t)) +#define AVAILABLE_SIZE(p2) (1 << (p2)) typedef struct per_thread_pool { /* the pool that was used to request this allocation */ @@ -301,4 +308,15 @@ mem_pool_destroy(struct mem_pool *pool); void gf_mem_acct_enable_set(void *ctx); +/* hit will be set to : + * _gf_true if the memory is served from mem pool + * _gf_false if the requested size was not present in mem pool and hence + * std alloc'd. + */ +void * +mem_pool_get(unsigned long sizeof_type, gf_boolean_t *hit); + +void * +mem_pool_get0(unsigned long sizeof_type, gf_boolean_t *hit); + #endif /* _MEM_POOL_H */ |
