From 041e041e1f23a03d1019330c8401a01285feb44f Mon Sep 17 00:00:00 2001 From: David Goldblatt Date: Tue, 23 May 2017 14:56:24 -0700 Subject: [PATCH] Header refactoring: unify and de-catchall mutex_pool. --- include/jemalloc/internal/extent_externs.h | 1 + include/jemalloc/internal/extent_inlines.h | 2 +- .../internal/jemalloc_internal_includes.h | 2 -- .../{mutex_pool_inlines.h => mutex_pool.h} | 18 +++++++++++------- include/jemalloc/internal/mutex_pool_structs.h | 16 ---------------- src/extent.c | 1 + src/mutex_pool.c | 1 + 7 files changed, 15 insertions(+), 26 deletions(-) rename include/jemalloc/internal/{mutex_pool_inlines.h => mutex_pool.h} (86%) delete mode 100644 include/jemalloc/internal/mutex_pool_structs.h diff --git a/include/jemalloc/internal/extent_externs.h b/include/jemalloc/internal/extent_externs.h index 96a71126..acb3ef49 100644 --- a/include/jemalloc/internal/extent_externs.h +++ b/include/jemalloc/internal/extent_externs.h @@ -2,6 +2,7 @@ #define JEMALLOC_INTERNAL_EXTENT_EXTERNS_H #include "jemalloc/internal/mutex.h" +#include "jemalloc/internal/mutex_pool.h" #include "jemalloc/internal/ph.h" #include "jemalloc/internal/rb.h" #include "jemalloc/internal/rtree.h" diff --git a/include/jemalloc/internal/extent_inlines.h b/include/jemalloc/internal/extent_inlines.h index a99a6351..94c41923 100644 --- a/include/jemalloc/internal/extent_inlines.h +++ b/include/jemalloc/internal/extent_inlines.h @@ -2,7 +2,7 @@ #define JEMALLOC_INTERNAL_EXTENT_INLINES_H #include "jemalloc/internal/mutex.h" -#include "jemalloc/internal/mutex_pool_inlines.h" +#include "jemalloc/internal/mutex_pool.h" #include "jemalloc/internal/pages.h" #include "jemalloc/internal/prng.h" #include "jemalloc/internal/ql.h" diff --git a/include/jemalloc/internal/jemalloc_internal_includes.h b/include/jemalloc/internal/jemalloc_internal_includes.h index 837e9e41..437eaa40 100644 --- a/include/jemalloc/internal/jemalloc_internal_includes.h +++ b/include/jemalloc/internal/jemalloc_internal_includes.h @@ -50,7 +50,6 @@ /* STRUCTS */ /******************************************************************************/ -#include "jemalloc/internal/mutex_pool_structs.h" #include "jemalloc/internal/arena_structs_a.h" #include "jemalloc/internal/extent_structs.h" #include "jemalloc/internal/base_structs.h" @@ -76,7 +75,6 @@ /* INLINES */ /******************************************************************************/ -#include "jemalloc/internal/mutex_pool_inlines.h" #include "jemalloc/internal/jemalloc_internal_inlines_a.h" #include "jemalloc/internal/base_inlines.h" /* diff --git a/include/jemalloc/internal/mutex_pool_inlines.h b/include/jemalloc/internal/mutex_pool.h similarity index 86% rename from include/jemalloc/internal/mutex_pool_inlines.h rename to include/jemalloc/internal/mutex_pool.h index 19b5ab4c..726cece9 100644 --- a/include/jemalloc/internal/mutex_pool_inlines.h +++ b/include/jemalloc/internal/mutex_pool.h @@ -1,17 +1,21 @@ -#ifndef JEMALLOC_INTERNAL_MUTEX_POOL_INLINES_H -#define JEMALLOC_INTERNAL_MUTEX_POOL_INLINES_H +#ifndef JEMALLOC_INTERNAL_MUTEX_POOL_H +#define JEMALLOC_INTERNAL_MUTEX_POOL_H #include "jemalloc/internal/hash.h" #include "jemalloc/internal/mutex.h" -#include "jemalloc/internal/mutex_pool_structs.h" #include "jemalloc/internal/witness.h" -/* - * This file really combines "inlines" and "externs", but only transitionally. - */ +/* We do mod reductions by this value, so it should be kept a power of 2. */ +#define MUTEX_POOL_SIZE 256 + +typedef struct mutex_pool_s mutex_pool_t; +struct mutex_pool_s { + malloc_mutex_t mutexes[MUTEX_POOL_SIZE]; +}; bool mutex_pool_init(mutex_pool_t *pool, const char *name, witness_rank_t rank); +/* Internal helper - not meant to be called outside this module. */ static inline malloc_mutex_t * mutex_pool_mutex(mutex_pool_t *pool, uintptr_t key) { size_t hash_result[2]; @@ -87,4 +91,4 @@ mutex_pool_assert_owner(tsdn_t *tsdn, mutex_pool_t *pool, uintptr_t key) { malloc_mutex_assert_owner(tsdn, mutex_pool_mutex(pool, key)); } -#endif /* JEMALLOC_INTERNAL_MUTEX_POOL_INLINES_H */ +#endif /* JEMALLOC_INTERNAL_MUTEX_POOL_H */ diff --git a/include/jemalloc/internal/mutex_pool_structs.h b/include/jemalloc/internal/mutex_pool_structs.h deleted file mode 100644 index b32fb5ac..00000000 --- a/include/jemalloc/internal/mutex_pool_structs.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef JEMALLOC_INTERNAL_MUTEX_POOL_STRUCTS_H -#define JEMALLOC_INTERNAL_MUTEX_POOL_STRUCTS_H - -#include "jemalloc/internal/mutex.h" - -/* This file really combines "structs" and "types", but only transitionally. */ - -/* We do mod reductions by this value, so it should be kept a power of 2. */ -#define MUTEX_POOL_SIZE 256 - -typedef struct mutex_pool_s mutex_pool_t; -struct mutex_pool_s { - malloc_mutex_t mutexes[MUTEX_POOL_SIZE]; -}; - -#endif /* JEMALLOC_INTERNAL_MUTEX_POOL_STRUCTS_H */ diff --git a/src/extent.c b/src/extent.c index 6589de55..c3d9baae 100644 --- a/src/extent.c +++ b/src/extent.c @@ -8,6 +8,7 @@ #include "jemalloc/internal/ph.h" #include "jemalloc/internal/rtree.h" #include "jemalloc/internal/mutex.h" +#include "jemalloc/internal/mutex_pool.h" /******************************************************************************/ /* Data. */ diff --git a/src/mutex_pool.c b/src/mutex_pool.c index 95a45736..f24d10e4 100644 --- a/src/mutex_pool.c +++ b/src/mutex_pool.c @@ -4,6 +4,7 @@ #include "jemalloc/internal/jemalloc_internal_includes.h" #include "jemalloc/internal/mutex.h" +#include "jemalloc/internal/mutex_pool.h" bool mutex_pool_init(mutex_pool_t *pool, const char *name, witness_rank_t rank) {