Remove the "opt.valgrind" mallctl.

Remove the "opt.valgrind" mallctl because it is unnecessary -- jemalloc
automatically detects whether it is running inside valgrind.
This commit is contained in:
Jason Evans 2014-04-15 14:33:50 -07:00
parent a2c719b374
commit ecd3e59ca3
7 changed files with 24 additions and 41 deletions

View File

@ -943,19 +943,6 @@ for (i = 0; i < nbins; i++) {
is disabled by default.</para></listitem> is disabled by default.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry id="opt.valgrind">
<term>
<mallctl>opt.valgrind</mallctl>
(<type>bool</type>)
<literal>r-</literal>
[<option>--enable-valgrind</option>]
</term>
<listitem><para><ulink url="http://valgrind.org/">Valgrind</ulink>
support enabled/disabled. This option is vestigal because jemalloc
auto-detects whether it is running inside Valgrind. This option is
disabled by default, unless running inside Valgrind.</para></listitem>
</varlistentry>
<varlistentry id="opt.xmalloc"> <varlistentry id="opt.xmalloc">
<term> <term>
<mallctl>opt.xmalloc</mallctl> <mallctl>opt.xmalloc</mallctl>

View File

@ -377,12 +377,12 @@ static const bool config_ivsalloc =
* usable space. * usable space.
*/ */
#define JEMALLOC_VALGRIND_MALLOC(cond, ptr, usize, zero) do { \ #define JEMALLOC_VALGRIND_MALLOC(cond, ptr, usize, zero) do { \
if (config_valgrind && opt_valgrind && cond) \ if (config_valgrind && in_valgrind && cond) \
VALGRIND_MALLOCLIKE_BLOCK(ptr, usize, p2rz(ptr), zero); \ VALGRIND_MALLOCLIKE_BLOCK(ptr, usize, p2rz(ptr), zero); \
} while (0) } while (0)
#define JEMALLOC_VALGRIND_REALLOC(ptr, usize, old_ptr, old_usize, \ #define JEMALLOC_VALGRIND_REALLOC(ptr, usize, old_ptr, old_usize, \
old_rzsize, zero) do { \ old_rzsize, zero) do { \
if (config_valgrind && opt_valgrind) { \ if (config_valgrind && in_valgrind) { \
size_t rzsize = p2rz(ptr); \ size_t rzsize = p2rz(ptr); \
\ \
if (ptr == old_ptr) { \ if (ptr == old_ptr) { \
@ -418,7 +418,7 @@ static const bool config_ivsalloc =
} \ } \
} while (0) } while (0)
#define JEMALLOC_VALGRIND_FREE(ptr, rzsize) do { \ #define JEMALLOC_VALGRIND_FREE(ptr, rzsize) do { \
if (config_valgrind && opt_valgrind) \ if (config_valgrind && in_valgrind) \
VALGRIND_FREELIKE_BLOCK(ptr, rzsize); \ VALGRIND_FREELIKE_BLOCK(ptr, rzsize); \
} while (0) } while (0)
#else #else
@ -504,11 +504,12 @@ extern bool opt_junk;
extern size_t opt_quarantine; extern size_t opt_quarantine;
extern bool opt_redzone; extern bool opt_redzone;
extern bool opt_utrace; extern bool opt_utrace;
extern bool opt_valgrind;
extern bool opt_xmalloc; extern bool opt_xmalloc;
extern bool opt_zero; extern bool opt_zero;
extern size_t opt_narenas; extern size_t opt_narenas;
extern bool in_valgrind;
/* Number of CPUs. */ /* Number of CPUs. */
extern unsigned ncpus; extern unsigned ncpus;

View File

@ -217,6 +217,7 @@ idalloc
idalloct idalloct
imalloc imalloc
imalloct imalloct
in_valgrind
ipalloc ipalloc
ipalloct ipalloct
iqalloc iqalloc
@ -278,7 +279,6 @@ opt_redzone
opt_stats_print opt_stats_print
opt_tcache opt_tcache
opt_utrace opt_utrace
opt_valgrind
opt_xmalloc opt_xmalloc
opt_zero opt_zero
p2rz p2rz

View File

@ -98,7 +98,6 @@ CTL_PROTO(opt_zero)
CTL_PROTO(opt_quarantine) CTL_PROTO(opt_quarantine)
CTL_PROTO(opt_redzone) CTL_PROTO(opt_redzone)
CTL_PROTO(opt_utrace) CTL_PROTO(opt_utrace)
CTL_PROTO(opt_valgrind)
CTL_PROTO(opt_xmalloc) CTL_PROTO(opt_xmalloc)
CTL_PROTO(opt_tcache) CTL_PROTO(opt_tcache)
CTL_PROTO(opt_lg_tcache_max) CTL_PROTO(opt_lg_tcache_max)
@ -238,7 +237,6 @@ static const ctl_named_node_t opt_node[] = {
{NAME("quarantine"), CTL(opt_quarantine)}, {NAME("quarantine"), CTL(opt_quarantine)},
{NAME("redzone"), CTL(opt_redzone)}, {NAME("redzone"), CTL(opt_redzone)},
{NAME("utrace"), CTL(opt_utrace)}, {NAME("utrace"), CTL(opt_utrace)},
{NAME("valgrind"), CTL(opt_valgrind)},
{NAME("xmalloc"), CTL(opt_xmalloc)}, {NAME("xmalloc"), CTL(opt_xmalloc)},
{NAME("tcache"), CTL(opt_tcache)}, {NAME("tcache"), CTL(opt_tcache)},
{NAME("lg_tcache_max"), CTL(opt_lg_tcache_max)}, {NAME("lg_tcache_max"), CTL(opt_lg_tcache_max)},
@ -1159,7 +1157,6 @@ CTL_RO_NL_CGEN(config_fill, opt_quarantine, opt_quarantine, size_t)
CTL_RO_NL_CGEN(config_fill, opt_redzone, opt_redzone, bool) CTL_RO_NL_CGEN(config_fill, opt_redzone, opt_redzone, bool)
CTL_RO_NL_CGEN(config_fill, opt_zero, opt_zero, bool) CTL_RO_NL_CGEN(config_fill, opt_zero, opt_zero, bool)
CTL_RO_NL_CGEN(config_utrace, opt_utrace, opt_utrace, bool) CTL_RO_NL_CGEN(config_utrace, opt_utrace, opt_utrace, bool)
CTL_RO_NL_CGEN(config_valgrind, opt_valgrind, opt_valgrind, bool)
CTL_RO_NL_CGEN(config_xmalloc, opt_xmalloc, opt_xmalloc, bool) CTL_RO_NL_CGEN(config_xmalloc, opt_xmalloc, opt_xmalloc, bool)
CTL_RO_NL_CGEN(config_tcache, opt_tcache, opt_tcache, bool) CTL_RO_NL_CGEN(config_tcache, opt_tcache, opt_tcache, bool)
CTL_RO_NL_CGEN(config_tcache, opt_lg_tcache_max, opt_lg_tcache_max, ssize_t) CTL_RO_NL_CGEN(config_tcache, opt_lg_tcache_max, opt_lg_tcache_max, ssize_t)

View File

@ -27,11 +27,13 @@ bool opt_junk =
size_t opt_quarantine = ZU(0); size_t opt_quarantine = ZU(0);
bool opt_redzone = false; bool opt_redzone = false;
bool opt_utrace = false; bool opt_utrace = false;
bool opt_valgrind = false;
bool opt_xmalloc = false; bool opt_xmalloc = false;
bool opt_zero = false; bool opt_zero = false;
size_t opt_narenas = 0; size_t opt_narenas = 0;
/* Initialized to true if the process is running inside Valgrind. */
bool in_valgrind;
unsigned ncpus; unsigned ncpus;
malloc_mutex_t arenas_lock; malloc_mutex_t arenas_lock;
@ -394,14 +396,14 @@ malloc_conf_init(void)
* valgrind option remains in jemalloc 3.x for compatibility reasons. * valgrind option remains in jemalloc 3.x for compatibility reasons.
*/ */
if (config_valgrind) { if (config_valgrind) {
opt_valgrind = (RUNNING_ON_VALGRIND != 0) ? true : false; in_valgrind = (RUNNING_ON_VALGRIND != 0) ? true : false;
if (config_fill && opt_valgrind) { if (config_fill && in_valgrind) {
opt_junk = false; opt_junk = false;
assert(opt_zero == false); assert(opt_zero == false);
opt_quarantine = JEMALLOC_VALGRIND_QUARANTINE_DEFAULT; opt_quarantine = JEMALLOC_VALGRIND_QUARANTINE_DEFAULT;
opt_redzone = true; opt_redzone = true;
} }
if (config_tcache && opt_valgrind) if (config_tcache && in_valgrind)
opt_tcache = false; opt_tcache = false;
} }
@ -608,9 +610,6 @@ malloc_conf_init(void)
if (config_utrace) { if (config_utrace) {
CONF_HANDLE_BOOL(opt_utrace, "utrace") CONF_HANDLE_BOOL(opt_utrace, "utrace")
} }
if (config_valgrind) {
CONF_HANDLE_BOOL(opt_valgrind, "valgrind")
}
if (config_xmalloc) { if (config_xmalloc) {
CONF_HANDLE_BOOL(opt_xmalloc, "xmalloc") CONF_HANDLE_BOOL(opt_xmalloc, "xmalloc")
} }
@ -910,7 +909,7 @@ imalloc_prof(size_t usize, prof_thr_cnt_t *cnt)
ret = imalloc_prof(usize, cnt); \ ret = imalloc_prof(usize, cnt); \
} else { \ } else { \
if (config_stats || (config_valgrind && \ if (config_stats || (config_valgrind && \
opt_valgrind)) \ in_valgrind)) \
usize = s2u(size); \ usize = s2u(size); \
ret = imalloc(size); \ ret = imalloc(size); \
} \ } \
@ -1153,7 +1152,7 @@ je_calloc(size_t num, size_t size)
PROF_ALLOC_PREP(1, usize, cnt); PROF_ALLOC_PREP(1, usize, cnt);
ret = icalloc_prof(usize, cnt); ret = icalloc_prof(usize, cnt);
} else { } else {
if (config_stats || (config_valgrind && opt_valgrind)) if (config_stats || (config_valgrind && in_valgrind))
usize = s2u(num_size); usize = s2u(num_size);
ret = icalloc(num_size); ret = icalloc(num_size);
} }
@ -1228,7 +1227,7 @@ ifree(void *ptr)
usize = isalloc(ptr, config_prof); usize = isalloc(ptr, config_prof);
if (config_stats) if (config_stats)
thread_allocated_tsd_get()->deallocated += usize; thread_allocated_tsd_get()->deallocated += usize;
if (config_valgrind && opt_valgrind) if (config_valgrind && in_valgrind)
rzsize = p2rz(ptr); rzsize = p2rz(ptr);
iqalloc(ptr); iqalloc(ptr);
JEMALLOC_VALGRIND_FREE(ptr, rzsize); JEMALLOC_VALGRIND_FREE(ptr, rzsize);
@ -1257,9 +1256,9 @@ je_realloc(void *ptr, size_t size)
malloc_thread_init(); malloc_thread_init();
if ((config_prof && opt_prof) || config_stats || if ((config_prof && opt_prof) || config_stats ||
(config_valgrind && opt_valgrind)) (config_valgrind && in_valgrind))
old_usize = isalloc(ptr, config_prof); old_usize = isalloc(ptr, config_prof);
if (config_valgrind && opt_valgrind) if (config_valgrind && in_valgrind)
old_rzsize = config_prof ? p2rz(ptr) : u2rz(old_usize); old_rzsize = config_prof ? p2rz(ptr) : u2rz(old_usize);
if (config_prof && opt_prof) { if (config_prof && opt_prof) {
@ -1269,7 +1268,7 @@ je_realloc(void *ptr, size_t size)
PROF_ALLOC_PREP(1, usize, cnt); PROF_ALLOC_PREP(1, usize, cnt);
ret = irealloc_prof(ptr, old_usize, usize, cnt); ret = irealloc_prof(ptr, old_usize, usize, cnt);
} else { } else {
if (config_stats || (config_valgrind && opt_valgrind)) if (config_stats || (config_valgrind && in_valgrind))
usize = s2u(size); usize = s2u(size);
ret = iralloc(ptr, size, 0, 0, false); ret = iralloc(ptr, size, 0, 0, false);
} }
@ -1574,9 +1573,9 @@ je_rallocx(void *ptr, size_t size, int flags)
} }
if ((config_prof && opt_prof) || config_stats || if ((config_prof && opt_prof) || config_stats ||
(config_valgrind && opt_valgrind)) (config_valgrind && in_valgrind))
old_usize = isalloc(ptr, config_prof); old_usize = isalloc(ptr, config_prof);
if (config_valgrind && opt_valgrind) if (config_valgrind && in_valgrind)
old_rzsize = u2rz(old_usize); old_rzsize = u2rz(old_usize);
if (config_prof && opt_prof) { if (config_prof && opt_prof) {
@ -1594,7 +1593,7 @@ je_rallocx(void *ptr, size_t size, int flags)
try_tcache_dalloc, arena); try_tcache_dalloc, arena);
if (p == NULL) if (p == NULL)
goto label_oom; goto label_oom;
if (config_stats || (config_valgrind && opt_valgrind)) if (config_stats || (config_valgrind && in_valgrind))
usize = isalloc(p, config_prof); usize = isalloc(p, config_prof);
} }
@ -1702,7 +1701,7 @@ je_xallocx(void *ptr, size_t size, size_t extra, int flags)
arena = NULL; arena = NULL;
old_usize = isalloc(ptr, config_prof); old_usize = isalloc(ptr, config_prof);
if (config_valgrind && opt_valgrind) if (config_valgrind && in_valgrind)
old_rzsize = u2rz(old_usize); old_rzsize = u2rz(old_usize);
if (config_prof && opt_prof) { if (config_prof && opt_prof) {
@ -1784,7 +1783,7 @@ je_dallocx(void *ptr, int flags)
} }
if (config_stats) if (config_stats)
thread_allocated_tsd_get()->deallocated += usize; thread_allocated_tsd_get()->deallocated += usize;
if (config_valgrind && opt_valgrind) if (config_valgrind && in_valgrind)
rzsize = p2rz(ptr); rzsize = p2rz(ptr);
iqalloct(ptr, try_tcache); iqalloct(ptr, try_tcache);
JEMALLOC_VALGRIND_FREE(ptr, rzsize); JEMALLOC_VALGRIND_FREE(ptr, rzsize);

View File

@ -146,7 +146,7 @@ quarantine(void *ptr)
* Only do redzone validation if Valgrind isn't in * Only do redzone validation if Valgrind isn't in
* operation. * operation.
*/ */
if ((config_valgrind == false || opt_valgrind == false) if ((config_valgrind == false || in_valgrind == false)
&& usize <= SMALL_MAXCLASS) && usize <= SMALL_MAXCLASS)
arena_quarantine_junk_small(ptr, usize); arena_quarantine_junk_small(ptr, usize);
else else

View File

@ -170,7 +170,6 @@ TEST_BEGIN(test_mallctl_opt)
TEST_MALLCTL_OPT(bool, redzone, fill); TEST_MALLCTL_OPT(bool, redzone, fill);
TEST_MALLCTL_OPT(bool, zero, fill); TEST_MALLCTL_OPT(bool, zero, fill);
TEST_MALLCTL_OPT(bool, utrace, utrace); TEST_MALLCTL_OPT(bool, utrace, utrace);
TEST_MALLCTL_OPT(bool, valgrind, valgrind);
TEST_MALLCTL_OPT(bool, xmalloc, xmalloc); TEST_MALLCTL_OPT(bool, xmalloc, xmalloc);
TEST_MALLCTL_OPT(bool, tcache, tcache); TEST_MALLCTL_OPT(bool, tcache, tcache);
TEST_MALLCTL_OPT(size_t, lg_tcache_max, tcache); TEST_MALLCTL_OPT(size_t, lg_tcache_max, tcache);