Convert arena_t's purging field to non-atomic bool.

The decay mutex already protects all accesses.
This commit is contained in:
Jason Evans 2017-03-07 19:18:27 -08:00
parent 75fddc786c
commit 3a2b183d5f
2 changed files with 12 additions and 12 deletions

View File

@ -167,14 +167,6 @@ struct arena_s {
/* Synchronization: atomic. */ /* Synchronization: atomic. */
dss_prec_t dss_prec; dss_prec_t dss_prec;
/*
* 1/0 (true/false) if a thread is currently executing
* arena_purge_to_limit().
*
* Synchronization: atomic.
*/
unsigned purging;
/* /*
* Number of pages in active extents. * Number of pages in active extents.
* *
@ -207,6 +199,13 @@ struct arena_s {
extents_t extents_cached; extents_t extents_cached;
extents_t extents_retained; extents_t extents_retained;
/*
* True if a thread is currently executing arena_purge_to_limit().
*
* Synchronization: decay.mtx.
*/
bool purging;
/* /*
* Next extent size class in a growing series to use when satisfying a * Next extent size class in a growing series to use when satisfying a
* request via the extent hooks (only if !config_munmap). This limits * request via the extent hooks (only if !config_munmap). This limits

View File

@ -777,9 +777,10 @@ arena_purge_to_limit(tsdn_t *tsdn, arena_t *arena, size_t ndirty_limit) {
witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 1); witness_assert_depth_to_rank(tsdn, WITNESS_RANK_CORE, 1);
malloc_mutex_assert_owner(tsdn, &arena->decay.mtx); malloc_mutex_assert_owner(tsdn, &arena->decay.mtx);
if (atomic_cas_u(&arena->purging, 0, 1)) { if (arena->purging) {
return; return;
} }
arena->purging = true;
extent_hooks_t *extent_hooks = extent_hooks_get(arena); extent_hooks_t *extent_hooks = extent_hooks_get(arena);
size_t npurge, npurged; size_t npurge, npurged;
@ -809,7 +810,7 @@ arena_purge_to_limit(tsdn_t *tsdn, arena_t *arena, size_t ndirty_limit) {
} }
label_return: label_return:
atomic_write_u(&arena->purging, 0); arena->purging = false;
} }
void void
@ -934,7 +935,6 @@ arena_reset(tsd_t *tsd, arena_t *arena) {
malloc_mutex_unlock(tsd_tsdn(tsd), &bin->lock); malloc_mutex_unlock(tsd_tsdn(tsd), &bin->lock);
} }
assert(atomic_read_u(&arena->purging) == 0);
atomic_write_zu(&arena->nactive, 0); atomic_write_zu(&arena->nactive, 0);
} }
@ -1676,7 +1676,6 @@ arena_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) {
arena->dss_prec = extent_dss_prec_get(); arena->dss_prec = extent_dss_prec_get();
atomic_write_u(&arena->purging, 0);
atomic_write_zu(&arena->nactive, 0); atomic_write_zu(&arena->nactive, 0);
if (arena_decay_init(arena, arena_decay_time_default_get())) { if (arena_decay_init(arena, arena_decay_time_default_get())) {
@ -1710,6 +1709,8 @@ arena_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) {
goto label_error; goto label_error;
} }
arena->purging = false;
if (!config_munmap) { if (!config_munmap) {
arena->extent_grow_next = psz2ind(HUGEPAGE); arena->extent_grow_next = psz2ind(HUGEPAGE);
} }