| 945 | } |
| 946 | |
| 947 | static bool |
| 948 | arena_decay_impl(tsdn_t *tsdn, arena_t *arena, arena_decay_t *decay, |
| 949 | extents_t *extents, bool is_background_thread, bool all) { |
| 950 | if (all) { |
| 951 | malloc_mutex_lock(tsdn, &decay->mtx); |
| 952 | arena_decay_to_limit(tsdn, arena, decay, extents, all, 0, |
| 953 | extents_npages_get(extents), is_background_thread); |
| 954 | malloc_mutex_unlock(tsdn, &decay->mtx); |
| 955 | |
| 956 | return false; |
| 957 | } |
| 958 | |
| 959 | if (malloc_mutex_trylock(tsdn, &decay->mtx)) { |
| 960 | /* No need to wait if another thread is in progress. */ |
| 961 | return true; |
| 962 | } |
| 963 | |
| 964 | bool epoch_advanced = arena_maybe_decay(tsdn, arena, decay, extents, |
| 965 | is_background_thread); |
| 966 | size_t npages_new; |
| 967 | if (epoch_advanced) { |
| 968 | /* Backlog is updated on epoch advance. */ |
| 969 | npages_new = decay->backlog[SMOOTHSTEP_NSTEPS-1]; |
| 970 | } |
| 971 | malloc_mutex_unlock(tsdn, &decay->mtx); |
| 972 | |
| 973 | if (have_background_thread && background_thread_enabled() && |
| 974 | epoch_advanced && !is_background_thread) { |
| 975 | background_thread_interval_check(tsdn, arena, decay, |
| 976 | npages_new); |
| 977 | } |
| 978 | |
| 979 | return false; |
| 980 | } |
| 981 | |
| 982 | static bool |
| 983 | arena_decay_dirty(tsdn_t *tsdn, arena_t *arena, bool is_background_thread, |
no test coverage detected