2016-11-18 05:36:17 +08:00
|
|
|
#include "test/jemalloc_test.h"
|
|
|
|
|
2017-01-16 08:56:30 +08:00
|
|
|
TEST_BEGIN(test_pages_huge) {
|
2016-11-18 05:36:17 +08:00
|
|
|
size_t alloc_size;
|
|
|
|
bool commit;
|
|
|
|
void *pages, *hugepage;
|
|
|
|
|
|
|
|
alloc_size = HUGEPAGE * 2 - PAGE;
|
|
|
|
commit = true;
|
2017-04-17 07:23:32 +08:00
|
|
|
pages = pages_map(NULL, alloc_size, PAGE, &commit);
|
2016-11-18 05:36:17 +08:00
|
|
|
assert_ptr_not_null(pages, "Unexpected pages_map() error");
|
|
|
|
|
2017-09-12 04:32:58 +08:00
|
|
|
if (thp_state_madvise) {
|
|
|
|
hugepage = (void *)(ALIGNMENT_CEILING((uintptr_t)pages, HUGEPAGE));
|
|
|
|
assert_b_ne(pages_huge(hugepage, HUGEPAGE), have_madvise_huge,
|
|
|
|
"Unexpected pages_huge() result");
|
|
|
|
assert_false(pages_nohuge(hugepage, HUGEPAGE),
|
|
|
|
"Unexpected pages_nohuge() result");
|
|
|
|
}
|
2016-11-18 05:36:17 +08:00
|
|
|
|
|
|
|
pages_unmap(pages, alloc_size);
|
|
|
|
}
|
|
|
|
TEST_END
|
|
|
|
|
|
|
|
int
|
2017-01-16 08:56:30 +08:00
|
|
|
main(void) {
|
2017-01-20 10:15:45 +08:00
|
|
|
return test(
|
|
|
|
test_pages_huge);
|
2016-11-18 05:36:17 +08:00
|
|
|
}
|