mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-14 14:41:42 +03:00
Fix static analysis warnings.
This commit is contained in:
parent
e4817c8d89
commit
eda05b3994
9 changed files with 33 additions and 15 deletions
|
|
@ -63,7 +63,7 @@ void arena_do_deferred_work(tsdn_t *tsdn, arena_t *arena);
|
||||||
void arena_reset(tsd_t *tsd, arena_t *arena);
|
void arena_reset(tsd_t *tsd, arena_t *arena);
|
||||||
void arena_destroy(tsd_t *tsd, arena_t *arena);
|
void arena_destroy(tsd_t *tsd, arena_t *arena);
|
||||||
void arena_cache_bin_fill_small(tsdn_t *tsdn, arena_t *arena,
|
void arena_cache_bin_fill_small(tsdn_t *tsdn, arena_t *arena,
|
||||||
cache_bin_t *cache_bin, szind_t binind, const unsigned nfill);
|
cache_bin_t *cache_bin, szind_t binind, const cache_bin_sz_t nfill);
|
||||||
|
|
||||||
void *arena_malloc_hard(tsdn_t *tsdn, arena_t *arena, size_t size,
|
void *arena_malloc_hard(tsdn_t *tsdn, arena_t *arena, size_t size,
|
||||||
szind_t ind, bool zero, bool slab);
|
szind_t ind, bool zero, bool slab);
|
||||||
|
|
|
||||||
|
|
@ -1019,7 +1019,7 @@ arena_bin_choose(tsdn_t *tsdn, arena_t *arena, szind_t binind,
|
||||||
|
|
||||||
void
|
void
|
||||||
arena_cache_bin_fill_small(tsdn_t *tsdn, arena_t *arena,
|
arena_cache_bin_fill_small(tsdn_t *tsdn, arena_t *arena,
|
||||||
cache_bin_t *cache_bin, szind_t binind, const unsigned nfill) {
|
cache_bin_t *cache_bin, szind_t binind, const cache_bin_sz_t nfill) {
|
||||||
assert(cache_bin_ncached_get_local(cache_bin) == 0);
|
assert(cache_bin_ncached_get_local(cache_bin) == 0);
|
||||||
assert(nfill != 0);
|
assert(nfill != 0);
|
||||||
|
|
||||||
|
|
@ -1056,7 +1056,7 @@ arena_cache_bin_fill_small(tsdn_t *tsdn, arena_t *arena,
|
||||||
bool made_progress = true;
|
bool made_progress = true;
|
||||||
edata_t *fresh_slab = NULL;
|
edata_t *fresh_slab = NULL;
|
||||||
bool alloc_and_retry = false;
|
bool alloc_and_retry = false;
|
||||||
unsigned filled = 0;
|
cache_bin_sz_t filled = 0;
|
||||||
unsigned binshard;
|
unsigned binshard;
|
||||||
bin_t *bin = arena_bin_choose(tsdn, arena, binind, &binshard);
|
bin_t *bin = arena_bin_choose(tsdn, arena, binind, &binshard);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,8 +201,6 @@ ecache_evict(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks,
|
||||||
* concurrent operations.
|
* concurrent operations.
|
||||||
*/
|
*/
|
||||||
switch (ecache->state) {
|
switch (ecache->state) {
|
||||||
case extent_state_active:
|
|
||||||
not_reached();
|
|
||||||
case extent_state_dirty:
|
case extent_state_dirty:
|
||||||
case extent_state_muzzy:
|
case extent_state_muzzy:
|
||||||
emap_update_edata_state(tsdn, pac->emap, edata,
|
emap_update_edata_state(tsdn, pac->emap, edata,
|
||||||
|
|
@ -211,6 +209,9 @@ ecache_evict(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks,
|
||||||
case extent_state_retained:
|
case extent_state_retained:
|
||||||
extent_deregister(tsdn, pac, edata);
|
extent_deregister(tsdn, pac, edata);
|
||||||
break;
|
break;
|
||||||
|
case extent_state_active:
|
||||||
|
case extent_state_transition:
|
||||||
|
case extent_state_merging:
|
||||||
default:
|
default:
|
||||||
not_reached();
|
not_reached();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -460,8 +460,12 @@ arena_bind(tsd_t *tsd, unsigned ind, bool internal) {
|
||||||
tsd_iarena_set(tsd, arena);
|
tsd_iarena_set(tsd, arena);
|
||||||
} else {
|
} else {
|
||||||
tsd_arena_set(tsd, arena);
|
tsd_arena_set(tsd, arena);
|
||||||
unsigned shard = atomic_fetch_add_u(&arena->binshard_next, 1,
|
/*
|
||||||
ATOMIC_RELAXED);
|
* While shard acts as a random seed, the cast below should
|
||||||
|
* not make much difference.
|
||||||
|
*/
|
||||||
|
uint8_t shard = (uint8_t)atomic_fetch_add_u(
|
||||||
|
&arena->binshard_next, 1, ATOMIC_RELAXED);
|
||||||
tsd_binshards_t *bins = tsd_binshardsp_get(tsd);
|
tsd_binshards_t *bins = tsd_binshardsp_get(tsd);
|
||||||
for (unsigned i = 0; i < SC_NBINS; i++) {
|
for (unsigned i = 0; i < SC_NBINS; i++) {
|
||||||
assert(bin_infos[i].n_shards > 0 &&
|
assert(bin_infos[i].n_shards > 0 &&
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,10 @@ pac_decay_data_get(pac_t *pac, extent_state_t state,
|
||||||
*r_decay_stats = &pac->stats->decay_muzzy;
|
*r_decay_stats = &pac->stats->decay_muzzy;
|
||||||
*r_ecache = &pac->ecache_muzzy;
|
*r_ecache = &pac->ecache_muzzy;
|
||||||
return;
|
return;
|
||||||
|
case extent_state_active:
|
||||||
|
case extent_state_retained:
|
||||||
|
case extent_state_transition:
|
||||||
|
case extent_state_merging:
|
||||||
default:
|
default:
|
||||||
unreachable();
|
unreachable();
|
||||||
}
|
}
|
||||||
|
|
@ -385,8 +389,6 @@ pac_decay_stashed(tsdn_t *tsdn, pac_t *pac, decay_t *decay,
|
||||||
npurged += npages;
|
npurged += npages;
|
||||||
|
|
||||||
switch (ecache->state) {
|
switch (ecache->state) {
|
||||||
case extent_state_active:
|
|
||||||
not_reached();
|
|
||||||
case extent_state_dirty:
|
case extent_state_dirty:
|
||||||
if (try_muzzy) {
|
if (try_muzzy) {
|
||||||
err = extent_purge_lazy_wrapper(tsdn, ehooks,
|
err = extent_purge_lazy_wrapper(tsdn, ehooks,
|
||||||
|
|
@ -402,7 +404,10 @@ pac_decay_stashed(tsdn_t *tsdn, pac_t *pac, decay_t *decay,
|
||||||
extent_dalloc_wrapper(tsdn, pac, ehooks, edata);
|
extent_dalloc_wrapper(tsdn, pac, ehooks, edata);
|
||||||
nunmapped += npages;
|
nunmapped += npages;
|
||||||
break;
|
break;
|
||||||
|
case extent_state_active:
|
||||||
case extent_state_retained:
|
case extent_state_retained:
|
||||||
|
case extent_state_transition:
|
||||||
|
case extent_state_merging:
|
||||||
default:
|
default:
|
||||||
not_reached();
|
not_reached();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,8 @@ prof_sample_new_event_wait(tsd_t *tsd) {
|
||||||
* otherwise bytes_until_sample would be 0 if u is exactly 1.0.
|
* otherwise bytes_until_sample would be 0 if u is exactly 1.0.
|
||||||
*/
|
*/
|
||||||
uint64_t r = prng_lg_range_u64(tsd_prng_statep_get(tsd), 53);
|
uint64_t r = prng_lg_range_u64(tsd_prng_statep_get(tsd), 53);
|
||||||
double u = (r == 0U) ? 1.0 : (double)r * (1.0/9007199254740992.0L);
|
double u = (r == 0U) ? 1.0 : (double)((long double)r *
|
||||||
|
(1.0L/9007199254740992.0L));
|
||||||
return (uint64_t)(log(u) /
|
return (uint64_t)(log(u) /
|
||||||
log(1.0 - (1.0 / (double)((uint64_t)1U << lg_prof_sample))))
|
log(1.0 - (1.0 / (double)((uint64_t)1U << lg_prof_sample))))
|
||||||
+ (uint64_t)1U;
|
+ (uint64_t)1U;
|
||||||
|
|
|
||||||
|
|
@ -709,6 +709,7 @@ prof_tctx_merge_iter(prof_tctx_tree_t *tctxs, prof_tctx_t *tctx, void *arg) {
|
||||||
case prof_tctx_state_purgatory:
|
case prof_tctx_state_purgatory:
|
||||||
prof_tctx_merge_gctx(tsdn, tctx, tctx->gctx);
|
prof_tctx_merge_gctx(tsdn, tctx, tctx->gctx);
|
||||||
break;
|
break;
|
||||||
|
case prof_tctx_state_initializing:
|
||||||
default:
|
default:
|
||||||
not_reached();
|
not_reached();
|
||||||
}
|
}
|
||||||
|
|
@ -764,6 +765,7 @@ prof_tctx_finish_iter(prof_tctx_tree_t *tctxs, prof_tctx_t *tctx, void *arg) {
|
||||||
case prof_tctx_state_purgatory:
|
case prof_tctx_state_purgatory:
|
||||||
ret = tctx;
|
ret = tctx;
|
||||||
goto label_return;
|
goto label_return;
|
||||||
|
case prof_tctx_state_initializing:
|
||||||
default:
|
default:
|
||||||
not_reached();
|
not_reached();
|
||||||
}
|
}
|
||||||
|
|
@ -1393,6 +1395,8 @@ prof_tctx_destroy(tsd_t *tsd, prof_tctx_t *tctx) {
|
||||||
destroy_tctx = false;
|
destroy_tctx = false;
|
||||||
destroy_gctx = false;
|
destroy_gctx = false;
|
||||||
break;
|
break;
|
||||||
|
case prof_tctx_state_initializing:
|
||||||
|
case prof_tctx_state_purgatory:
|
||||||
default:
|
default:
|
||||||
not_reached();
|
not_reached();
|
||||||
destroy_tctx = false;
|
destroy_tctx = false;
|
||||||
|
|
|
||||||
3
src/sz.c
3
src/sz.c
|
|
@ -100,7 +100,8 @@ sz_boot_size2index_tab(const sc_data_t *sc_data) {
|
||||||
size_t max_ind = ((sz + (ZU(1) << SC_LG_TINY_MIN) - 1)
|
size_t max_ind = ((sz + (ZU(1) << SC_LG_TINY_MIN) - 1)
|
||||||
>> SC_LG_TINY_MIN);
|
>> SC_LG_TINY_MIN);
|
||||||
for (; dst_ind <= max_ind && dst_ind < dst_max; dst_ind++) {
|
for (; dst_ind <= max_ind && dst_ind < dst_max; dst_ind++) {
|
||||||
sz_size2index_tab[dst_ind] = sc_ind;
|
assert(sc_ind < 1 << (sizeof(uint8_t) * 8));
|
||||||
|
sz_size2index_tab[dst_ind] = (uint8_t)sc_ind;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
src/tcache.c
10
src/tcache.c
|
|
@ -250,7 +250,7 @@ tcache_alloc_small_hard(tsdn_t *tsdn, arena_t *arena,
|
||||||
|
|
||||||
assert(tcache_slow->arena != NULL);
|
assert(tcache_slow->arena != NULL);
|
||||||
assert(!tcache_bin_disabled(binind, cache_bin, tcache_slow));
|
assert(!tcache_bin_disabled(binind, cache_bin, tcache_slow));
|
||||||
unsigned nfill = cache_bin_ncached_max_get(cache_bin)
|
cache_bin_sz_t nfill = cache_bin_ncached_max_get(cache_bin)
|
||||||
>> tcache_slow->lg_fill_div[binind];
|
>> tcache_slow->lg_fill_div[binind];
|
||||||
if (nfill == 0) {
|
if (nfill == 0) {
|
||||||
nfill = 1;
|
nfill = 1;
|
||||||
|
|
@ -529,7 +529,7 @@ tcache_bin_flush_bottom(tsd_t *tsd, tcache_t *tcache, cache_bin_t *cache_bin,
|
||||||
|
|
||||||
cache_bin_sz_t ncached = cache_bin_ncached_get_local(cache_bin);
|
cache_bin_sz_t ncached = cache_bin_ncached_get_local(cache_bin);
|
||||||
assert((cache_bin_sz_t)rem <= ncached);
|
assert((cache_bin_sz_t)rem <= ncached);
|
||||||
unsigned nflush = ncached - rem;
|
cache_bin_sz_t nflush = ncached - (cache_bin_sz_t)rem;
|
||||||
|
|
||||||
CACHE_BIN_PTR_ARRAY_DECLARE(ptrs, nflush);
|
CACHE_BIN_PTR_ARRAY_DECLARE(ptrs, nflush);
|
||||||
cache_bin_init_ptr_array_for_flush(cache_bin, &ptrs, nflush);
|
cache_bin_init_ptr_array_for_flush(cache_bin, &ptrs, nflush);
|
||||||
|
|
@ -537,7 +537,8 @@ tcache_bin_flush_bottom(tsd_t *tsd, tcache_t *tcache, cache_bin_t *cache_bin,
|
||||||
tcache_bin_flush_impl(tsd, tcache, cache_bin, binind, &ptrs, nflush,
|
tcache_bin_flush_impl(tsd, tcache, cache_bin, binind, &ptrs, nflush,
|
||||||
small);
|
small);
|
||||||
|
|
||||||
cache_bin_finish_flush(cache_bin, &ptrs, ncached - rem);
|
cache_bin_finish_flush(cache_bin, &ptrs,
|
||||||
|
ncached - (cache_bin_sz_t)rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -817,7 +818,8 @@ tcache_bin_info_compute(cache_bin_info_t tcache_bin_info[TCACHE_NBINS_MAX]) {
|
||||||
(unsigned)tcache_get_default_ncached_max()[i].ncached_max:
|
(unsigned)tcache_get_default_ncached_max()[i].ncached_max:
|
||||||
tcache_ncached_max_compute(i);
|
tcache_ncached_max_compute(i);
|
||||||
assert(ncached_max <= CACHE_BIN_NCACHED_MAX);
|
assert(ncached_max <= CACHE_BIN_NCACHED_MAX);
|
||||||
cache_bin_info_init(&tcache_bin_info[i], ncached_max);
|
cache_bin_info_init(&tcache_bin_info[i],
|
||||||
|
(cache_bin_sz_t)ncached_max);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue