summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2017-08-11 22:41:52 (GMT)
committerQi Wang <interwq@gmail.com>2017-08-11 22:57:12 (GMT)
commit3ec279ba1c702286b2a7d4ce7aaf48d7905f1c5b (patch)
treed4777143d2244dfe788c23bc0f341e1fa0c3443b
parent8fdd9a579779b84d6af27f94c295f82a4df8e5be (diff)
downloadjemalloc-3ec279ba1c702286b2a7d4ce7aaf48d7905f1c5b.zip
jemalloc-3ec279ba1c702286b2a7d4ce7aaf48d7905f1c5b.tar.gz
jemalloc-3ec279ba1c702286b2a7d4ce7aaf48d7905f1c5b.tar.bz2
Fix test/unit/pages.
As part of the metadata_thp support, We now have a separate swtich (JEMALLOC_HAVE_MADVISE_HUGE) for MADV_HUGEPAGE availability. Use that instead of JEMALLOC_THP (which doesn't guard pages_huge anymore) in tests.
-rw-r--r--include/jemalloc/internal/jemalloc_preamble.h.in7
-rw-r--r--src/pages.c13
-rw-r--r--test/unit/pages.c2
3 files changed, 15 insertions, 7 deletions
diff --git a/include/jemalloc/internal/jemalloc_preamble.h.in b/include/jemalloc/internal/jemalloc_preamble.h.in
index 099f98d..f6ed731 100644
--- a/include/jemalloc/internal/jemalloc_preamble.h.in
+++ b/include/jemalloc/internal/jemalloc_preamble.h.in
@@ -61,6 +61,13 @@ static const bool have_dss =
false
#endif
;
+static const bool have_madvise_huge =
+#ifdef JEMALLOC_HAVE_MADVISE_HUGE
+ true
+#else
+ false
+#endif
+ ;
static const bool config_fill =
#ifdef JEMALLOC_FILL
true
diff --git a/src/pages.c b/src/pages.c
index 9561f6d..70f1fd3 100644
--- a/src/pages.c
+++ b/src/pages.c
@@ -417,13 +417,14 @@ os_overcommits_proc(void) {
static void
init_thp_state(void) {
-#ifndef JEMALLOC_HAVE_MADVISE_HUGE
- if (opt_metadata_thp && opt_abort) {
- malloc_write("<jemalloc>: no MADV_HUGEPAGE support\n");
- abort();
+ if (!have_madvise_huge) {
+ if (opt_metadata_thp && opt_abort) {
+ malloc_write("<jemalloc>: no MADV_HUGEPAGE support\n");
+ abort();
+ }
+ goto label_error;
}
- goto label_error;
-#endif
+
static const char madvise_state[] = "always [madvise] never\n";
char buf[sizeof(madvise_state)];
diff --git a/test/unit/pages.c b/test/unit/pages.c
index 67dbb4c..1a979e6 100644
--- a/test/unit/pages.c
+++ b/test/unit/pages.c
@@ -11,7 +11,7 @@ TEST_BEGIN(test_pages_huge) {
assert_ptr_not_null(pages, "Unexpected pages_map() error");
hugepage = (void *)(ALIGNMENT_CEILING((uintptr_t)pages, HUGEPAGE));
- assert_b_ne(pages_huge(hugepage, HUGEPAGE), config_thp,
+ assert_b_ne(pages_huge(hugepage, HUGEPAGE), have_madvise_huge,
"Unexpected pages_huge() result");
assert_false(pages_nohuge(hugepage, HUGEPAGE),
"Unexpected pages_nohuge() result");