[PATCH 09/11] Remove initialization of the non-TLS tsd wrapper from static memory
Mike Hommey
mh+jemalloc at glandium.org
Wed Apr 18 09:29:48 PDT 2012
From: Mike Hommey <mh at glandium.org>
Using static memory when malloc_tsd_malloc fails means all threads share
the same wrapper and thus the same wrapped value. This defeats the purpose
of TSD.
---
include/jemalloc/internal/tsd.h | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/include/jemalloc/internal/tsd.h b/include/jemalloc/internal/tsd.h
index d1dd3d0..db6b1a6 100644
--- a/include/jemalloc/internal/tsd.h
+++ b/include/jemalloc/internal/tsd.h
@@ -192,7 +192,6 @@ a_name##_tsd_set(a_type *val) \
a_cleanup) \
/* Data structure. */ \
typedef struct { \
- bool isstatic; \
bool initialized; \
a_type val; \
} a_name##_tsd_wrapper_t; \
@@ -218,8 +217,7 @@ a_name##_tsd_cleanup_wrapper(void *arg) \
return; \
} \
} \
- if (wrapper->isstatic == false) \
- malloc_tsd_dalloc(wrapper); \
+ malloc_tsd_dalloc(wrapper); \
} \
a_attr bool \
a_name##_tsd_boot(void) \
@@ -242,17 +240,11 @@ a_name##_tsd_get_wrapper(void) \
wrapper = (a_name##_tsd_wrapper_t *) \
malloc_tsd_malloc(sizeof(a_name##_tsd_wrapper_t)); \
if (wrapper == NULL) { \
- static a_name##_tsd_wrapper_t \
- a_name##_tsd_static_data = \
- {true, false, a_initializer}; \
malloc_write("<jemalloc>: Error allocating" \
" TSD for "#a_name"\n"); \
- if (opt_abort) \
- abort(); \
- wrapper = &a_name##_tsd_static_data; \
+ abort(); \
} else { \
static a_type tsd_static_data = a_initializer; \
- wrapper->isstatic = false; \
wrapper->initialized = false; \
wrapper->val = tsd_static_data; \
} \
@@ -260,8 +252,7 @@ a_name##_tsd_get_wrapper(void) \
(void *)wrapper)) { \
malloc_write("<jemalloc>: Error setting" \
" TSD for "#a_name"\n"); \
- if (opt_abort) \
- abort(); \
+ abort(); \
} \
} \
return (wrapper); \
--
1.7.10
More information about the jemalloc-discuss
mailing list