hpdata: count active pages instead of free ones.

This will be more consistent with later naming choices.
This commit is contained in:
David Goldblatt
2020-12-02 17:01:57 -08:00
committed by David Goldblatt
parent 3624dd42ff
commit ff4086aa6b
4 changed files with 18 additions and 23 deletions

View File

@@ -125,7 +125,7 @@ hpa_should_hugify(hpa_shard_t *shard, hpdata_t *ps) {
* inactive. Eventually, this should be a malloc conf option.
*/
return !hpdata_huge_get(ps)
&& hpdata_nfree_get(ps) < (HUGEPAGE / PAGE) * 5 / 100;
&& hpdata_nactive_get(ps) >= (HUGEPAGE_PAGES) * 95 / 100;
}
/* Returns true on error. */

View File

@@ -22,7 +22,7 @@ hpdata_init(hpdata_t *hpdata, void *addr, uint64_t age) {
hpdata_addr_set(hpdata, addr);
hpdata_age_set(hpdata, age);
hpdata_huge_set(hpdata, false);
hpdata_nfree_set(hpdata, HUGEPAGE_PAGES);
hpdata->h_nactive = 0;
hpdata_longest_free_range_set(hpdata, HUGEPAGE_PAGES);
fb_init(hpdata->active_pages, HUGEPAGE_PAGES);
@@ -72,7 +72,7 @@ hpdata_reserve_alloc(hpdata_t *hpdata, size_t sz) {
/* We found a range; remember it. */
result = begin;
fb_set_range(hpdata->active_pages, HUGEPAGE_PAGES, begin, npages);
hpdata_nfree_set(hpdata, hpdata_nfree_get(hpdata) - npages);
hpdata->h_nactive += npages;
/*
* We might have shrunk the longest free range. We have to keep
@@ -123,7 +123,7 @@ hpdata_unreserve(hpdata_t *hpdata, void *addr, size_t sz) {
hpdata_longest_free_range_set(hpdata, new_range_len);
}
hpdata_nfree_set(hpdata, hpdata_nfree_get(hpdata) + npages);
hpdata->h_nactive -= npages;
hpdata_assert_consistent(hpdata);
}

View File

@@ -57,8 +57,8 @@ psset_bin_stats_insert_remove(psset_bin_stats_t *binstats, hpdata_t *ps,
size_t *ninactive_dst = hpdata_huge_get(ps)
? &binstats->ninactive_huge : &binstats->ninactive_nonhuge;
size_t ninactive = hpdata_nfree_get(ps);
size_t nactive = HUGEPAGE_PAGES - ninactive;
size_t nactive = hpdata_nactive_get(ps);
size_t ninactive = HUGEPAGE_PAGES - nactive;
size_t mul = insert ? (size_t)1 : (size_t)-1;
*npageslabs_dst += mul * 1;