Switch from opt.lg_tcache_max to opt.tcache_max
Though for convenience, keep parsing lg_tcache_max.
This commit is contained in:
@@ -109,7 +109,7 @@ CTL_PROTO(opt_zero)
|
||||
CTL_PROTO(opt_utrace)
|
||||
CTL_PROTO(opt_xmalloc)
|
||||
CTL_PROTO(opt_tcache)
|
||||
CTL_PROTO(opt_lg_tcache_max)
|
||||
CTL_PROTO(opt_tcache_max)
|
||||
CTL_PROTO(opt_tcache_nslots_small_min)
|
||||
CTL_PROTO(opt_tcache_nslots_small_max)
|
||||
CTL_PROTO(opt_tcache_nslots_large)
|
||||
@@ -362,7 +362,7 @@ static const ctl_named_node_t opt_node[] = {
|
||||
{NAME("utrace"), CTL(opt_utrace)},
|
||||
{NAME("xmalloc"), CTL(opt_xmalloc)},
|
||||
{NAME("tcache"), CTL(opt_tcache)},
|
||||
{NAME("lg_tcache_max"), CTL(opt_lg_tcache_max)},
|
||||
{NAME("tcache_max"), CTL(opt_tcache_max)},
|
||||
{NAME("tcache_nslots_small_min"),
|
||||
CTL(opt_tcache_nslots_small_min)},
|
||||
{NAME("tcache_nslots_small_max"),
|
||||
@@ -1837,7 +1837,7 @@ 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_xmalloc, opt_xmalloc, opt_xmalloc, bool)
|
||||
CTL_RO_NL_GEN(opt_tcache, opt_tcache, bool)
|
||||
CTL_RO_NL_GEN(opt_lg_tcache_max, opt_lg_tcache_max, ssize_t)
|
||||
CTL_RO_NL_GEN(opt_tcache_max, opt_tcache_max, size_t)
|
||||
CTL_RO_NL_GEN(opt_tcache_nslots_small_min, opt_tcache_nslots_small_min,
|
||||
unsigned)
|
||||
CTL_RO_NL_GEN(opt_tcache_nslots_small_max, opt_tcache_nslots_small_max,
|
||||
|
@@ -1170,15 +1170,18 @@ malloc_conf_init_helper(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS],
|
||||
#define CONF_DONT_CHECK_MAX(um, max) false
|
||||
#define CONF_CHECK_MAX(um, max) ((um) > (max))
|
||||
|
||||
#define CONF_VALUE_READ(max_t, result) \
|
||||
char *end; \
|
||||
set_errno(0); \
|
||||
result = (max_t)malloc_strtoumax(v, &end, 0);
|
||||
#define CONF_VALUE_READ_FAIL() \
|
||||
(get_errno() != 0 || (uintptr_t)end - (uintptr_t)v != vlen)
|
||||
|
||||
#define CONF_HANDLE_T(t, max_t, o, n, min, max, check_min, check_max, clip) \
|
||||
if (CONF_MATCH(n)) { \
|
||||
max_t mv; \
|
||||
char *end; \
|
||||
\
|
||||
set_errno(0); \
|
||||
mv = (max_t)malloc_strtoumax(v, &end, 0); \
|
||||
if (get_errno() != 0 || (uintptr_t)end -\
|
||||
(uintptr_t)v != vlen) { \
|
||||
CONF_VALUE_READ(max_t, mv) \
|
||||
if (CONF_VALUE_READ_FAIL()) { \
|
||||
CONF_ERROR("Invalid conf value",\
|
||||
k, klen, v, vlen); \
|
||||
} else if (clip) { \
|
||||
@@ -1379,8 +1382,24 @@ malloc_conf_init_helper(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS],
|
||||
CONF_HANDLE_BOOL(opt_xmalloc, "xmalloc")
|
||||
}
|
||||
CONF_HANDLE_BOOL(opt_tcache, "tcache")
|
||||
CONF_HANDLE_SSIZE_T(opt_lg_tcache_max, "lg_tcache_max",
|
||||
-1, (sizeof(size_t) << 3) - 1)
|
||||
CONF_HANDLE_SIZE_T(opt_tcache_max, "tcache_max",
|
||||
0, TCACHE_MAXCLASS_LIMIT, CONF_DONT_CHECK_MIN,
|
||||
CONF_CHECK_MAX, /* clip */ true)
|
||||
if (CONF_MATCH("lg_tcache_max")) {
|
||||
size_t m;
|
||||
CONF_VALUE_READ(size_t, m)
|
||||
if (CONF_VALUE_READ_FAIL()) {
|
||||
CONF_ERROR("Invalid conf value",
|
||||
k, klen, v, vlen);
|
||||
} else {
|
||||
/* clip if necessary */
|
||||
if (m > TCACHE_LG_MAXCLASS_LIMIT) {
|
||||
m = TCACHE_LG_MAXCLASS_LIMIT;
|
||||
}
|
||||
opt_tcache_max = (size_t)1 << m;
|
||||
}
|
||||
CONF_CONTINUE;
|
||||
}
|
||||
/*
|
||||
* Anyone trying to set a value outside -16 to 16 is
|
||||
* deeply confused.
|
||||
|
14
src/tcache.c
14
src/tcache.c
@@ -11,11 +11,8 @@
|
||||
|
||||
bool opt_tcache = true;
|
||||
|
||||
/*
|
||||
* (1U << opt_lg_tcache_max) is used to compute tcache_maxclass. This choice
|
||||
* (32kb by default) works well as a default in practice.
|
||||
*/
|
||||
ssize_t opt_lg_tcache_max = 15;
|
||||
/* tcache_maxclass is set to 32KB by default. */
|
||||
size_t opt_tcache_max = ((size_t)1) << 15;
|
||||
|
||||
/* Reasonable defaults for min and max values. */
|
||||
unsigned opt_tcache_nslots_small_min = 20;
|
||||
@@ -935,14 +932,11 @@ tcache_ncached_max_compute(szind_t szind) {
|
||||
|
||||
bool
|
||||
tcache_boot(tsdn_t *tsdn, base_t *base) {
|
||||
/* If necessary, clamp opt_lg_tcache_max. */
|
||||
tcache_maxclass = opt_lg_tcache_max < 0 ? 0 :
|
||||
ZU(1) << opt_lg_tcache_max;
|
||||
tcache_maxclass = sz_s2u(opt_tcache_max);
|
||||
if (tcache_maxclass < SC_SMALL_MAXCLASS) {
|
||||
tcache_maxclass = SC_SMALL_MAXCLASS;
|
||||
} else if (tcache_maxclass > TCACHE_MAXCLASS_LIMIT) {
|
||||
tcache_maxclass = TCACHE_MAXCLASS_LIMIT;
|
||||
}
|
||||
assert(tcache_maxclass <= TCACHE_MAXCLASS_LIMIT);
|
||||
nhbins = sz_size2index(tcache_maxclass) + 1;
|
||||
|
||||
if (malloc_mutex_init(&tcaches_mtx, "tcaches", WITNESS_RANK_TCACHES,
|
||||
|
Reference in New Issue
Block a user