MINOR: pools: add a debugging flag for memory poisonning option

Now -dM will set POOL_DBG_POISON for consistency with the rest of the
pool debugging options. As such now we only check for the new flag,
which allows the default value to be preset.
This commit is contained in:
Willy Tarreau 2022-02-23 14:15:18 +01:00
parent 13d7775b06
commit ef301b7556
3 changed files with 9 additions and 3 deletions

View File

@ -49,6 +49,7 @@
#define POOL_DBG_NO_CACHE 0x00000020 // disable thread-local pool caches
#define POOL_DBG_CALLER 0x00000040 // trace last caller's location
#define POOL_DBG_TAG 0x00000080 // place a tag at the end of the area
#define POOL_DBG_POISON 0x00000100 // poison memory area on pool_alloc()
/* This is the head of a thread-local cache */

View File

@ -1629,8 +1629,13 @@ static void init(int argc, char **argv)
arg_mode |= MODE_DIAG;
else if (*flag == 'd' && flag[1] == 'W')
arg_mode |= MODE_ZERO_WARNING;
else if (*flag == 'd' && flag[1] == 'M')
else if (*flag == 'd' && flag[1] == 'M') {
mem_poison_byte = flag[2] ? strtol(flag + 2, NULL, 0) : 'P';
if (mem_poison_byte >= 0)
pool_debugging |= POOL_DBG_POISON;
else
pool_debugging &= ~POOL_DBG_POISON;
}
else if (*flag == 'd' && flag[1] == 'r')
global.tune.options |= GTUNE_RESOLVE_DONTFAIL;
#if defined(HA_HAVE_DUMP_LIBS)

View File

@ -34,7 +34,7 @@ THREAD_LOCAL size_t pool_cache_bytes = 0; /* total cache size */
THREAD_LOCAL size_t pool_cache_count = 0; /* #cache objects */
static struct list pools __read_mostly = LIST_HEAD_INIT(pools);
int mem_poison_byte __read_mostly = -1;
int mem_poison_byte __read_mostly = 'P';
uint pool_debugging __read_mostly = /* set of POOL_DBG_* flags */
#ifdef DEBUG_FAIL_ALLOC
POOL_DBG_FAIL_ALLOC |
@ -700,7 +700,7 @@ void *__pool_alloc(struct pool_head *pool, unsigned int flags)
if (likely(p)) {
if (unlikely(flags & POOL_F_MUST_ZERO))
memset(p, 0, pool->size);
else if (unlikely(!(flags & POOL_F_NO_POISON) && mem_poison_byte >= 0))
else if (unlikely(!(flags & POOL_F_NO_POISON) && (pool_debugging & POOL_DBG_POISON)))
memset(p, mem_poison_byte, pool->size);
}
return p;