Add huge page configuration and pages_[no}huge().
Add the --with-lg-hugepage configure option, but automatically configure LG_HUGEPAGE even if it isn't specified. Add the pages_[no]huge() functions, which toggle huge page state via madvise(..., MADV_[NO]HUGEPAGE) calls.
This commit is contained in:
30
test/unit/pages.c
Normal file
30
test/unit/pages.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
TEST_BEGIN(test_pages_huge)
|
||||
{
|
||||
size_t alloc_size;
|
||||
bool commit;
|
||||
void *pages, *hugepage;
|
||||
|
||||
alloc_size = HUGEPAGE * 2 - PAGE;
|
||||
commit = true;
|
||||
pages = pages_map(NULL, alloc_size, &commit);
|
||||
assert_ptr_not_null(pages, "Unexpected pages_map() error");
|
||||
|
||||
hugepage = (void *)(ALIGNMENT_CEILING((uintptr_t)pages, HUGEPAGE));
|
||||
assert_b_ne(pages_huge(hugepage, HUGEPAGE), have_thp,
|
||||
"Unexpected pages_huge() result");
|
||||
assert_false(pages_nohuge(hugepage, HUGEPAGE),
|
||||
"Unexpected pages_nohuge() result");
|
||||
|
||||
pages_unmap(pages, alloc_size);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
||||
return (test(
|
||||
test_pages_huge));
|
||||
}
|
Reference in New Issue
Block a user