pages.c 726 B

123456789101112131415161718192021222324252627282930
  1. #include "test/jemalloc_test.h"
  2. TEST_BEGIN(test_pages_huge) {
  3. size_t alloc_size;
  4. bool commit;
  5. void *pages, *hugepage;
  6. alloc_size = HUGEPAGE * 2 - PAGE;
  7. commit = true;
  8. pages = pages_map(NULL, alloc_size, PAGE, &commit);
  9. expect_ptr_not_null(pages, "Unexpected pages_map() error");
  10. if (init_system_thp_mode == thp_mode_default) {
  11. hugepage = (void *)(ALIGNMENT_CEILING((uintptr_t)pages, HUGEPAGE));
  12. expect_b_ne(pages_huge(hugepage, HUGEPAGE), have_madvise_huge,
  13. "Unexpected pages_huge() result");
  14. expect_false(pages_nohuge(hugepage, HUGEPAGE),
  15. "Unexpected pages_nohuge() result");
  16. }
  17. pages_unmap(pages, alloc_size);
  18. }
  19. TEST_END
  20. int
  21. main(void) {
  22. return test(
  23. test_pages_huge);
  24. }