From e6cb6919c0c1c94e387ccec79190647a44eb7180 Mon Sep 17 00:00:00 2001 From: Yinan Zhang Date: Tue, 28 Apr 2020 09:59:37 -0700 Subject: [PATCH] Consolidate prof inline function headers The prof inline functions are no longer involved in a circular dependency, so consolidate the two headers into one. --- .../internal/jemalloc_internal_includes.h | 3 +- include/jemalloc/internal/prof_externs.h | 2 +- .../{prof_inlines_b.h => prof_inlines.h} | 22 +++++++++++++++ include/jemalloc/internal/prof_inlines_a.h | 28 ------------------- 4 files changed, 24 insertions(+), 31 deletions(-) rename include/jemalloc/internal/{prof_inlines_b.h => prof_inlines.h} (90%) delete mode 100644 include/jemalloc/internal/prof_inlines_a.h diff --git a/include/jemalloc/internal/jemalloc_internal_includes.h b/include/jemalloc/internal/jemalloc_internal_includes.h index 72b5a72a..90a12a12 100644 --- a/include/jemalloc/internal/jemalloc_internal_includes.h +++ b/include/jemalloc/internal/jemalloc_internal_includes.h @@ -73,13 +73,12 @@ * Include portions of arena code interleaved with tcache code in order to * resolve circular dependencies. */ -#include "jemalloc/internal/prof_inlines_a.h" #include "jemalloc/internal/arena_inlines_a.h" #include "jemalloc/internal/jemalloc_internal_inlines_b.h" #include "jemalloc/internal/tcache_inlines.h" #include "jemalloc/internal/arena_inlines_b.h" #include "jemalloc/internal/jemalloc_internal_inlines_c.h" -#include "jemalloc/internal/prof_inlines_b.h" +#include "jemalloc/internal/prof_inlines.h" #include "jemalloc/internal/background_thread_inlines.h" #endif /* JEMALLOC_INTERNAL_INCLUDES_H */ diff --git a/include/jemalloc/internal/prof_externs.h b/include/jemalloc/internal/prof_externs.h index 0fbd3eae..cf61fea2 100644 --- a/include/jemalloc/internal/prof_externs.h +++ b/include/jemalloc/internal/prof_externs.h @@ -48,7 +48,7 @@ extern size_t lg_prof_sample; extern bool prof_booted; -/* Functions only accessed in prof_inlines_b.h */ +/* Functions only accessed in prof_inlines.h */ prof_tdata_t *prof_tdata_init(tsd_t *tsd); prof_tdata_t *prof_tdata_reinit(tsd_t *tsd, prof_tdata_t *tdata); diff --git a/include/jemalloc/internal/prof_inlines_b.h b/include/jemalloc/internal/prof_inlines.h similarity index 90% rename from include/jemalloc/internal/prof_inlines_b.h rename to include/jemalloc/internal/prof_inlines.h index 29d4020e..d8f401d1 100644 --- a/include/jemalloc/internal/prof_inlines_b.h +++ b/include/jemalloc/internal/prof_inlines.h @@ -5,6 +5,28 @@ #include "jemalloc/internal/sz.h" #include "jemalloc/internal/thread_event.h" +JEMALLOC_ALWAYS_INLINE void +prof_active_assert() { + cassert(config_prof); + /* + * If opt_prof is off, then prof_active must always be off, regardless + * of whether prof_active_mtx is in effect or not. + */ + assert(opt_prof || !prof_active); +} + +JEMALLOC_ALWAYS_INLINE bool +prof_active_get_unlocked(void) { + prof_active_assert(); + /* + * Even if opt_prof is true, sampling can be temporarily disabled by + * setting prof_active to false. No locking is used when reading + * prof_active in the fast path, so there are no guarantees regarding + * how long it will take for all threads to notice state changes. + */ + return prof_active; +} + JEMALLOC_ALWAYS_INLINE bool prof_gdump_get_unlocked(void) { /* diff --git a/include/jemalloc/internal/prof_inlines_a.h b/include/jemalloc/internal/prof_inlines_a.h deleted file mode 100644 index 4450b1d3..00000000 --- a/include/jemalloc/internal/prof_inlines_a.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef JEMALLOC_INTERNAL_PROF_INLINES_A_H -#define JEMALLOC_INTERNAL_PROF_INLINES_A_H - -#include "jemalloc/internal/mutex.h" - -JEMALLOC_ALWAYS_INLINE void -prof_active_assert() { - cassert(config_prof); - /* - * If opt_prof is off, then prof_active must always be off, regardless - * of whether prof_active_mtx is in effect or not. - */ - assert(opt_prof || !prof_active); -} - -JEMALLOC_ALWAYS_INLINE bool -prof_active_get_unlocked(void) { - prof_active_assert(); - /* - * Even if opt_prof is true, sampling can be temporarily disabled by - * setting prof_active to false. No locking is used when reading - * prof_active in the fast path, so there are no guarantees regarding - * how long it will take for all threads to notice state changes. - */ - return prof_active; -} - -#endif /* JEMALLOC_INTERNAL_PROF_INLINES_A_H */