diff --git a/include/jemalloc/internal/hpdata.h b/include/jemalloc/internal/hpdata.h index 66473d2e..12a72a66 100644 --- a/include/jemalloc/internal/hpdata.h +++ b/include/jemalloc/internal/hpdata.h @@ -77,6 +77,10 @@ struct hpdata_s { fb_group_t dirty_pages[FB_NGROUPS(HUGEPAGE_PAGES)]; }; +TYPED_LIST(hpdata_list, hpdata_t, ql_link) +typedef ph(hpdata_t) hpdata_age_heap_t; +ph_proto(, hpdata_age_heap_, hpdata_age_heap_t, hpdata_t); + static inline void * hpdata_addr_get(const hpdata_t *hpdata) { return hpdata->h_address; @@ -188,11 +192,6 @@ hpdata_assert_consistent(hpdata_t *hpdata) { assert(hpdata_consistent(hpdata)); } -TYPED_LIST(hpdata_list, hpdata_t, ql_link) - -typedef ph(hpdata_t) hpdata_age_heap_t; -ph_proto(, hpdata_age_heap_, hpdata_age_heap_t, hpdata_t); - static inline bool hpdata_empty(hpdata_t *hpdata) { return hpdata->h_nactive == 0; diff --git a/src/hpa.c b/src/hpa.c index 5230f6ba..4069c1ea 100644 --- a/src/hpa.c +++ b/src/hpa.c @@ -135,16 +135,20 @@ hpa_alloc_ps(tsdn_t *tsdn, hpa_shard_t *shard) { } static bool -hpa_should_hugify(hpa_shard_t *shard, hpdata_t *ps) { +hpa_good_hugification_candidate(hpa_shard_t *shard, hpdata_t *ps) { /* * For now, just use a static check; hugify a page if it's <= 5% * inactive. Eventually, this should be a malloc conf option. */ - if (hpdata_changing_state_get(ps)) { + return hpdata_nactive_get(ps) >= (HUGEPAGE_PAGES) * 95 / 100; +} + +static bool +hpa_should_hugify(hpa_shard_t *shard, hpdata_t *ps) { + if (hpdata_changing_state_get(ps) || hpdata_huge_get(ps)) { return false; } - return !hpdata_huge_get(ps) - && hpdata_nactive_get(ps) >= (HUGEPAGE_PAGES) * 95 / 100; + return hpa_good_hugification_candidate(shard, ps); } /*