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>
</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">
<term>
<mallctl>opt.xmalloc</mallctl>

View File

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

View File

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

View File

@ -98,7 +98,6 @@ CTL_PROTO(opt_zero)
CTL_PROTO(opt_quarantine)
CTL_PROTO(opt_redzone)
CTL_PROTO(opt_utrace)
CTL_PROTO(opt_valgrind)
CTL_PROTO(opt_xmalloc)
CTL_PROTO(opt_tcache)
CTL_PROTO(opt_lg_tcache_max)
@ -238,7 +237,6 @@ static const ctl_named_node_t opt_node[] = {
{NAME("quarantine"), CTL(opt_quarantine)},
{NAME("redzone"), CTL(opt_redzone)},
{NAME("utrace"), CTL(opt_utrace)},
{NAME("valgrind"), CTL(opt_valgrind)},
{NAME("xmalloc"), CTL(opt_xmalloc)},
{NAME("tcache"), CTL(opt_tcache)},
{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_zero, opt_zero, 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_tcache, opt_tcache, opt_tcache, bool)
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);
bool opt_redzone = false;
bool opt_utrace = false;
bool opt_valgrind = false;
bool opt_xmalloc = false;
bool opt_zero = false;
size_t opt_narenas = 0;
/* Initialized to true if the process is running inside Valgrind. */
bool in_valgrind;
unsigned ncpus;
malloc_mutex_t arenas_lock;
@ -394,14 +396,14 @@ malloc_conf_init(void)
* valgrind option remains in jemalloc 3.x for compatibility reasons.
*/
if (config_valgrind) {
opt_valgrind = (RUNNING_ON_VALGRIND != 0) ? true : false;
if (config_fill && opt_valgrind) {
in_valgrind = (RUNNING_ON_VALGRIND != 0) ? true : false;
if (config_fill && in_valgrind) {
opt_junk = false;
assert(opt_zero == false);
opt_quarantine = JEMALLOC_VALGRIND_QUARANTINE_DEFAULT;
opt_redzone = true;
}
if (config_tcache && opt_valgrind)
if (config_tcache && in_valgrind)
opt_tcache = false;
}
@ -608,9 +610,6 @@ malloc_conf_init(void)
if (config_utrace) {
CONF_HANDLE_BOOL(opt_utrace, "utrace")
}
if (config_valgrind) {
CONF_HANDLE_BOOL(opt_valgrind, "valgrind")
}
if (config_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); \
} else { \
if (config_stats || (config_valgrind && \
opt_valgrind)) \
in_valgrind)) \
usize = s2u(size); \
ret = imalloc(size); \
} \
@ -1153,7 +1152,7 @@ je_calloc(size_t num, size_t size)
PROF_ALLOC_PREP(1, usize, cnt);
ret = icalloc_prof(usize, cnt);
} else {
if (config_stats || (config_valgrind && opt_valgrind))
if (config_stats || (config_valgrind && in_valgrind))
usize = s2u(num_size);
ret = icalloc(num_size);
}
@ -1228,7 +1227,7 @@ ifree(void *ptr)
usize = isalloc(ptr, config_prof);
if (config_stats)
thread_allocated_tsd_get()->deallocated += usize;
if (config_valgrind && opt_valgrind)
if (config_valgrind && in_valgrind)
rzsize = p2rz(ptr);
iqalloc(ptr);
JEMALLOC_VALGRIND_FREE(ptr, rzsize);
@ -1257,9 +1256,9 @@ je_realloc(void *ptr, size_t size)
malloc_thread_init();
if ((config_prof && opt_prof) || config_stats ||
(config_valgrind && opt_valgrind))
(config_valgrind && in_valgrind))
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);
if (config_prof && opt_prof) {
@ -1269,7 +1268,7 @@ je_realloc(void *ptr, size_t size)
PROF_ALLOC_PREP(1, usize, cnt);
ret = irealloc_prof(ptr, old_usize, usize, cnt);
} else {
if (config_stats || (config_valgrind && opt_valgrind))
if (config_stats || (config_valgrind && in_valgrind))
usize = s2u(size);
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 ||
(config_valgrind && opt_valgrind))
(config_valgrind && in_valgrind))
old_usize = isalloc(ptr, config_prof);
if (config_valgrind && opt_valgrind)
if (config_valgrind && in_valgrind)
old_rzsize = u2rz(old_usize);
if (config_prof && opt_prof) {
@ -1594,7 +1593,7 @@ je_rallocx(void *ptr, size_t size, int flags)
try_tcache_dalloc, arena);
if (p == NULL)
goto label_oom;
if (config_stats || (config_valgrind && opt_valgrind))
if (config_stats || (config_valgrind && in_valgrind))
usize = isalloc(p, config_prof);
}
@ -1702,7 +1701,7 @@ je_xallocx(void *ptr, size_t size, size_t extra, int flags)
arena = NULL;
old_usize = isalloc(ptr, config_prof);
if (config_valgrind && opt_valgrind)
if (config_valgrind && in_valgrind)
old_rzsize = u2rz(old_usize);
if (config_prof && opt_prof) {
@ -1784,7 +1783,7 @@ je_dallocx(void *ptr, int flags)
}
if (config_stats)
thread_allocated_tsd_get()->deallocated += usize;
if (config_valgrind && opt_valgrind)
if (config_valgrind && in_valgrind)
rzsize = p2rz(ptr);
iqalloct(ptr, try_tcache);
JEMALLOC_VALGRIND_FREE(ptr, rzsize);

View File

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

View File

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