hpdata: Return the number of pages to be purged.
We'll use this in the next commit.
This commit is contained in:
parent
9fd9c876bb
commit
dc886e5608
@ -363,8 +363,11 @@ struct hpdata_purge_state_s {
|
||||
* Once you begin purging, you have to follow through and call hpdata_purge_next
|
||||
* until you're done, and then end. Allocating out of an hpdata undergoing
|
||||
* purging is not allowed.
|
||||
*
|
||||
* Returns the number of pages that will be purged.
|
||||
*/
|
||||
void hpdata_purge_begin(hpdata_t *hpdata, hpdata_purge_state_t *purge_state);
|
||||
size_t hpdata_purge_begin(hpdata_t *hpdata, hpdata_purge_state_t *purge_state);
|
||||
|
||||
/*
|
||||
* If there are more extents to purge, sets *r_purge_addr and *r_purge_size to
|
||||
* true, and returns true. Otherwise, returns false to indicate that we're
|
||||
|
@ -158,7 +158,7 @@ hpdata_unreserve(hpdata_t *hpdata, void *addr, size_t sz) {
|
||||
hpdata_assert_consistent(hpdata);
|
||||
}
|
||||
|
||||
void
|
||||
size_t
|
||||
hpdata_purge_begin(hpdata_t *hpdata, hpdata_purge_state_t *purge_state) {
|
||||
hpdata_assert_consistent(hpdata);
|
||||
/* See the comment in reserve. */
|
||||
@ -181,10 +181,13 @@ hpdata_purge_begin(hpdata_t *hpdata, hpdata_purge_state_t *purge_state) {
|
||||
hpdata->touched_pages, HUGEPAGE_PAGES);
|
||||
|
||||
/* We purge everything we can. */
|
||||
assert(hpdata->h_ntouched - hpdata->h_nactive == fb_scount(
|
||||
size_t to_purge = hpdata->h_ntouched - hpdata->h_nactive;
|
||||
assert(to_purge == fb_scount(
|
||||
purge_state->to_purge, HUGEPAGE_PAGES, 0, HUGEPAGE_PAGES));
|
||||
|
||||
hpdata_assert_consistent(hpdata);
|
||||
|
||||
return to_purge;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -68,7 +68,8 @@ TEST_BEGIN(test_purge_simple) {
|
||||
expect_zu_eq(hpdata_ntouched_get(&hpdata), HUGEPAGE_PAGES / 2, "");
|
||||
|
||||
hpdata_purge_state_t purge_state;
|
||||
hpdata_purge_begin(&hpdata, &purge_state);
|
||||
size_t to_purge = hpdata_purge_begin(&hpdata, &purge_state);
|
||||
expect_zu_eq(HUGEPAGE_PAGES / 4, to_purge, "");
|
||||
|
||||
void *purge_addr;
|
||||
size_t purge_size;
|
||||
@ -112,7 +113,8 @@ TEST_BEGIN(test_purge_intervening_dalloc) {
|
||||
expect_zu_eq(hpdata_ntouched_get(&hpdata), 3 * HUGEPAGE_PAGES / 4, "");
|
||||
|
||||
hpdata_purge_state_t purge_state;
|
||||
hpdata_purge_begin(&hpdata, &purge_state);
|
||||
size_t to_purge = hpdata_purge_begin(&hpdata, &purge_state);
|
||||
expect_zu_eq(HUGEPAGE_PAGES / 2, to_purge, "");
|
||||
|
||||
void *purge_addr;
|
||||
size_t purge_size;
|
||||
|
Loading…
Reference in New Issue
Block a user