diff --git a/include/jemalloc/internal/counter.h b/include/jemalloc/internal/counter.h index 4aee23dd..896fd02a 100644 --- a/include/jemalloc/internal/counter.h +++ b/include/jemalloc/internal/counter.h @@ -51,31 +51,6 @@ counter_accum(tsdn_t *tsdn, counter_accum_t *counter, uint64_t accumbytes) { return overflow; } -JEMALLOC_ALWAYS_INLINE void -counter_rollback(tsdn_t *tsdn, counter_accum_t *counter, uint64_t bytes) { - /* - * Cancel out as much of the excessive accumbytes increase as possible - * without underflowing. Interval-triggered events occur slightly more - * often than intended as a result of incomplete canceling. - */ - uint64_t a0, a1; -#ifdef JEMALLOC_ATOMIC_U64 - a0 = atomic_load_u64(&counter->accumbytes, - ATOMIC_RELAXED); - do { - a1 = (a0 >= bytes) ? a0 - bytes : 0; - } while (!atomic_compare_exchange_weak_u64( - &counter->accumbytes, &a0, a1, ATOMIC_RELAXED, - ATOMIC_RELAXED)); -#else - malloc_mutex_lock(tsdn, &counter->mtx); - a0 = counter->accumbytes; - a1 = (a0 >= bytes) ? a0 - bytes : 0; - counter->accumbytes = a1; - malloc_mutex_unlock(tsdn, &counter->mtx); -#endif -} - bool counter_accum_init(counter_accum_t *counter, uint64_t interval); #endif /* JEMALLOC_INTERNAL_COUNTER_H */ diff --git a/include/jemalloc/internal/prof_externs.h b/include/jemalloc/internal/prof_externs.h index 35181671..f03ef74b 100644 --- a/include/jemalloc/internal/prof_externs.h +++ b/include/jemalloc/internal/prof_externs.h @@ -50,7 +50,6 @@ extern bool prof_booted; /* Functions only accessed in prof_inlines_a.h */ bool prof_idump_accum_impl(tsdn_t *tsdn, uint64_t accumbytes); -void prof_idump_rollback_impl(tsdn_t *tsdn, size_t usize); /* Functions only accessed in prof_inlines_b.h */ prof_tdata_t *prof_tdata_init(tsd_t *tsd); diff --git a/include/jemalloc/internal/prof_inlines_a.h b/include/jemalloc/internal/prof_inlines_a.h index 61773a2b..63d429e3 100644 --- a/include/jemalloc/internal/prof_inlines_a.h +++ b/include/jemalloc/internal/prof_inlines_a.h @@ -36,15 +36,4 @@ prof_idump_accum(tsdn_t *tsdn, uint64_t accumbytes) { return prof_idump_accum_impl(tsdn, accumbytes); } -JEMALLOC_ALWAYS_INLINE void -prof_idump_rollback(tsdn_t *tsdn, size_t usize) { - cassert(config_prof); - - if (prof_interval == 0 || !prof_active_get_unlocked()) { - return; - } - - prof_idump_rollback_impl(tsdn, usize); -} - #endif /* JEMALLOC_INTERNAL_PROF_INLINES_A_H */ diff --git a/src/arena.c b/src/arena.c index 4ed3c88a..12c6b0a8 100644 --- a/src/arena.c +++ b/src/arena.c @@ -1061,8 +1061,6 @@ arena_prof_promote(tsdn_t *tsdn, void *ptr, size_t usize) { edata_szind_set(edata, szind); emap_remap(tsdn, &arena_emap_global, edata, szind, /* slab */ false); - prof_idump_rollback(tsdn, usize); - assert(isalloc(tsdn, ptr) == usize); } diff --git a/src/prof.c b/src/prof.c index bbf8e9d1..9c1fc2a6 100644 --- a/src/prof.c +++ b/src/prof.c @@ -50,7 +50,7 @@ bool opt_prof_accum = false; char opt_prof_prefix[PROF_DUMP_FILENAME_LEN]; bool opt_prof_experimental_use_sys_thread_name = false; -/* Accessed via prof_idump_[accum/rollback](). */ +/* Accessed via prof_idump_accum(). */ static counter_accum_t prof_idump_accumulated; /* @@ -655,16 +655,6 @@ prof_idump_accum_impl(tsdn_t *tsdn, uint64_t accumbytes) { return counter_accum(tsdn, &prof_idump_accumulated, accumbytes); } -void -prof_idump_rollback_impl(tsdn_t *tsdn, size_t usize) { - cassert(config_prof); - - /* Rollback is only done on arena_prof_promote of small sizes. */ - assert(SC_LARGE_MINCLASS > usize); - return counter_rollback(tsdn, &prof_idump_accumulated, - SC_LARGE_MINCLASS - usize); -} - bool prof_dump_prefix_set(tsdn_t *tsdn, const char *prefix) { cassert(config_prof); diff --git a/test/unit/counter.c b/test/unit/counter.c index 585cbc63..c14eee31 100644 --- a/test/unit/counter.c +++ b/test/unit/counter.c @@ -36,48 +36,6 @@ expect_counter_value(counter_accum_t *c, uint64_t v) { expect_u64_eq(accum, v, "Counter value mismatch"); } -TEST_BEGIN(test_counter_rollback) { - uint64_t half_interval = interval / 2; - - counter_accum_t c; - counter_accum_init(&c, interval); - - tsd_t *tsd = tsd_fetch(); - counter_rollback(tsd_tsdn(tsd), &c, half_interval); - - bool trigger; - trigger = counter_accum(tsd_tsdn(tsd), &c, half_interval); - expect_b_eq(trigger, false, "Should not trigger"); - counter_rollback(tsd_tsdn(tsd), &c, half_interval + 1); - expect_counter_value(&c, 0); - - trigger = counter_accum(tsd_tsdn(tsd), &c, half_interval); - expect_b_eq(trigger, false, "Should not trigger"); - counter_rollback(tsd_tsdn(tsd), &c, half_interval - 1); - expect_counter_value(&c, 1); - - counter_rollback(tsd_tsdn(tsd), &c, 1); - expect_counter_value(&c, 0); - - trigger = counter_accum(tsd_tsdn(tsd), &c, half_interval); - expect_b_eq(trigger, false, "Should not trigger"); - counter_rollback(tsd_tsdn(tsd), &c, 1); - expect_counter_value(&c, half_interval - 1); - - trigger = counter_accum(tsd_tsdn(tsd), &c, half_interval); - expect_b_eq(trigger, false, "Should not trigger"); - expect_counter_value(&c, interval - 1); - - trigger = counter_accum(tsd_tsdn(tsd), &c, 1); - expect_b_eq(trigger, true, "Should have triggered"); - expect_counter_value(&c, 0); - - trigger = counter_accum(tsd_tsdn(tsd), &c, interval + 1); - expect_b_eq(trigger, true, "Should have triggered"); - expect_counter_value(&c, 1); -} -TEST_END - #define N_THDS (16) #define N_ITER_THD (1 << 12) #define ITER_INCREMENT (interval >> 4) @@ -123,6 +81,5 @@ int main(void) { return test( test_counter_accum, - test_counter_rollback, test_counter_mt); }