aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLatchesar Ionkov <lionkov@lanl.gov>2018-05-01 12:31:09 -0600
committerQi Wang <interwq@gmail.com>2018-05-01 13:14:36 -0700
commita32b7bd5676e669821d15d319f686c3add451f4b (patch)
tree70d40641d70cc6165dd524964c5bf16c7b4de1e0 /src
parent6df90600a7e4df51b06efe2d47df211cba5935a7 (diff)
downloadplatform_external_jemalloc_new-a32b7bd5676e669821d15d319f686c3add451f4b.tar.gz
platform_external_jemalloc_new-a32b7bd5676e669821d15d319f686c3add451f4b.tar.bz2
platform_external_jemalloc_new-a32b7bd5676e669821d15d319f686c3add451f4b.zip
Mallctl: Add arenas.lookup
Implement a new mallctl operation that allows looking up the arena a region of memory belongs to.
Diffstat (limited to 'src')
-rw-r--r--src/ctl.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/ctl.c b/src/ctl.c
index 86c2837a..1e713a3d 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -139,6 +139,7 @@ CTL_PROTO(arenas_nbins)
CTL_PROTO(arenas_nhbins)
CTL_PROTO(arenas_nlextents)
CTL_PROTO(arenas_create)
+CTL_PROTO(arenas_lookup)
CTL_PROTO(prof_thread_active_init)
CTL_PROTO(prof_active)
CTL_PROTO(prof_dump)
@@ -373,7 +374,8 @@ static const ctl_named_node_t arenas_node[] = {
{NAME("bin"), CHILD(indexed, arenas_bin)},
{NAME("nlextents"), CTL(arenas_nlextents)},
{NAME("lextent"), CHILD(indexed, arenas_lextent)},
- {NAME("create"), CTL(arenas_create)}
+ {NAME("create"), CTL(arenas_create)},
+ {NAME("lookup"), CTL(arenas_lookup)}
};
static const ctl_named_node_t prof_node[] = {
@@ -2471,6 +2473,36 @@ label_return:
return ret;
}
+static int
+arenas_lookup_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
+ size_t *oldlenp, void *newp, size_t newlen) {
+ int ret;
+ unsigned arena_ind;
+ void *ptr;
+ extent_t *extent;
+ arena_t *arena;
+
+ ptr = NULL;
+ ret = EINVAL;
+ malloc_mutex_lock(tsd_tsdn(tsd), &ctl_mtx);
+ WRITE(ptr, void *);
+ extent = iealloc(tsd_tsdn(tsd), ptr);
+ if (extent == NULL)
+ goto label_return;
+
+ arena = extent_arena_get(extent);
+ if (arena == NULL)
+ goto label_return;
+
+ arena_ind = arena_ind_get(arena);
+ READ(arena_ind, unsigned);
+
+ ret = 0;
+label_return:
+ malloc_mutex_unlock(tsd_tsdn(tsd), &ctl_mtx);
+ return ret;
+}
+
/******************************************************************************/
static int