mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 21:23:06 +00:00
Implement the prof.gdump mallctl.
This feature makes it possible to toggle the gdump feature on/off during program execution, whereas the the opt.prof_dump mallctl value can only be set during program startup. This resolves #72.
This commit is contained in:
34
src/prof.c
34
src/prof.c
@@ -44,6 +44,13 @@ static malloc_mutex_t prof_active_mtx;
|
||||
static bool prof_thread_active_init;
|
||||
static malloc_mutex_t prof_thread_active_init_mtx;
|
||||
|
||||
/*
|
||||
* Initialized as opt_prof_gdump, and accessed via
|
||||
* prof_gdump_[gs]et{_unlocked,}().
|
||||
*/
|
||||
bool prof_gdump_val;
|
||||
static malloc_mutex_t prof_gdump_mtx;
|
||||
|
||||
uint64_t prof_interval = 0;
|
||||
|
||||
size_t lg_prof_sample;
|
||||
@@ -1961,6 +1968,29 @@ prof_thread_active_init_set(bool active_init)
|
||||
return (active_init_old);
|
||||
}
|
||||
|
||||
bool
|
||||
prof_gdump_get(void)
|
||||
{
|
||||
bool prof_gdump_current;
|
||||
|
||||
malloc_mutex_lock(&prof_gdump_mtx);
|
||||
prof_gdump_current = prof_gdump_val;
|
||||
malloc_mutex_unlock(&prof_gdump_mtx);
|
||||
return (prof_gdump_current);
|
||||
}
|
||||
|
||||
bool
|
||||
prof_gdump_set(bool gdump)
|
||||
{
|
||||
bool prof_gdump_old;
|
||||
|
||||
malloc_mutex_lock(&prof_gdump_mtx);
|
||||
prof_gdump_old = prof_gdump_val;
|
||||
prof_gdump_val = gdump;
|
||||
malloc_mutex_unlock(&prof_gdump_mtx);
|
||||
return (prof_gdump_old);
|
||||
}
|
||||
|
||||
void
|
||||
prof_boot0(void)
|
||||
{
|
||||
@@ -2013,6 +2043,10 @@ prof_boot2(void)
|
||||
if (malloc_mutex_init(&prof_active_mtx))
|
||||
return (true);
|
||||
|
||||
prof_gdump_val = opt_prof_gdump;
|
||||
if (malloc_mutex_init(&prof_gdump_mtx))
|
||||
return (true);
|
||||
|
||||
prof_thread_active_init = opt_prof_thread_active_init;
|
||||
if (malloc_mutex_init(&prof_thread_active_init_mtx))
|
||||
return (true);
|
||||
|
||||
Reference in New Issue
Block a user