diff options
author | Jason Evans <je@facebook.com> | 2010-08-13 22:42:29 (GMT) |
---|---|---|
committer | Jason Evans <je@facebook.com> | 2010-08-14 00:36:00 (GMT) |
commit | b267d0f86aff15a0edb2929f09060c118ed98ec4 (patch) | |
tree | 04753d90582013a2afd1da1918a9439e6b7358c5 /jemalloc/src | |
parent | dcd15098a8adfa6e44d7d1d041df968fb5fe9d82 (diff) | |
download | jemalloc-b267d0f86aff15a0edb2929f09060c118ed98ec4.zip jemalloc-b267d0f86aff15a0edb2929f09060c118ed98ec4.tar.gz jemalloc-b267d0f86aff15a0edb2929f09060c118ed98ec4.tar.bz2 |
Add the thread.arena mallctl.
Make it possible for each thread to manage which arena it is associated
with.
Implement the 'tests' and 'check' build targets.
Diffstat (limited to 'jemalloc/src')
-rw-r--r-- | jemalloc/src/ctl.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/jemalloc/src/ctl.c b/jemalloc/src/ctl.c index ffb732d..128883f 100644 --- a/jemalloc/src/ctl.c +++ b/jemalloc/src/ctl.c @@ -41,6 +41,9 @@ CTL_PROTO(epoch) #ifdef JEMALLOC_TCACHE CTL_PROTO(tcache_flush) #endif +#ifndef NO_TLS +CTL_PROTO(thread_arena) +#endif CTL_PROTO(config_debug) CTL_PROTO(config_dss) CTL_PROTO(config_dynamic_page_shift) @@ -210,6 +213,12 @@ static const ctl_node_t tcache_node[] = { }; #endif +#ifndef NO_TLS +static const ctl_node_t thread_node[] = { + {NAME("arena"), CTL(thread_arena)} +}; +#endif + static const ctl_node_t config_node[] = { {NAME("debug"), CTL(config_debug)}, {NAME("dss"), CTL(config_dss)}, @@ -448,6 +457,9 @@ static const ctl_node_t root_node[] = { #ifdef JEMALLOC_TCACHE {NAME("tcache"), CHILD(tcache)}, #endif +#ifndef NO_TLS + {NAME("thread"), CHILD(thread)}, +#endif {NAME("config"), CHILD(config)}, {NAME("opt"), CHILD(opt)}, {NAME("arenas"), CHILD(arenas)}, @@ -1042,6 +1054,46 @@ RETURN: } #endif +#ifndef NO_TLS +static int +thread_arena_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen) +{ + int ret; + unsigned newind, oldind; + + newind = oldind = choose_arena()->ind; + WRITE(oldind, unsigned); + READ(newind, unsigned); + if (newind != oldind) { + arena_t *arena; + + if (newind >= narenas) { + /* New arena index is out of range. */ + ret = EFAULT; + goto RETURN; + } + + /* Initialize arena if necessary. */ + malloc_mutex_lock(&arenas_lock); + if ((arena = arenas[newind]) == NULL) + arena = arenas_extend(newind); + malloc_mutex_unlock(&arenas_lock); + if (arena == NULL) { + ret = EAGAIN; + goto RETURN; + } + + /* Set new arena association. */ + arenas_map = arena; + } + + ret = 0; +RETURN: + return (ret); +} +#endif + /******************************************************************************/ #ifdef JEMALLOC_DEBUG |