Repository navigation
Closed
Description
The system I am testing on is 4.5.0-19.el7.aarch64 (CentOS 7.3), more below. I am using dev branch, 379dd44 commit.
% arch
aarch64
% gcc -dumpversion
4.8.5
% ld --version
GNU ld version 2.25.1-22.base.el7
% cat /boot/config-4.5.0-19.el7.aarch64 | grep CONFIG_TRANSPARENT_HUGEPAGE
# CONFIG_TRANSPARENT_HUGEPAGE is not set
I got the following test failing:
=== test/unit/pages ===
test_pages_huge:test/unit/pages.c:15: Failed assertion: (pages_huge(hugepage, HUGEPAGE)) != (have_thp) --> true == true: Unexpected pages_huge() result
test_pages_huge:test/unit/pages.c:17: Failed assertion: (jet_pages_nohuge(hugepage, ((size_t)(1U << 29)))) == (false) --> true != false: Unexpected pages_nohuge() result
test_pages_huge: fail
--- pass: 0/1, skip: 0/1, fail: 1/1 ---
From config.log:
[..]
configure:11040: checking whether madvise(..., MADV_[NO]HUGEPAGE) is compilable
configure:11061: gcc -o conftest -std=gnu11 -Wall -Wsign-compare -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -D_GNU_SOURCE -D_REENTRANT conftest.c -lm -lpthread >&5
configure:11061: $? = 0
[..]
je_cv_thp=yes
[..]
#define JEMALLOC_THP
[..]
Test fails because JEMALLOC_THP get set while it shouldn't (kernel does has THP disabled). The following seems to work:
diff --git a/configure.ac b/configure.ac
index 5e65547..0681d87 100644
--- a/configure.ac
+++ b/configure.ac
@@ -103,6 +103,18 @@ AC_CACHE_CHECK([whether $1 is compilable],
[$4=no])])
])
+dnl JE_RUNNABLE(label, hcode, mcode, rvar)
+AC_DEFUN([JE_RUNNABLE],
+[
+AC_CACHE_CHECK([whether $1 is runnable],
+ [$4],
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([$2],
+ [$3])],
+ [$4=yes],
+ [$4=no])])
+])
+
+
dnl ============================================================================
CONFIG=`echo ${ac_configure_args} | sed -e 's#'"'"'\([^ ]*\)'"'"'#\1#g'`
@@ -1812,11 +1824,14 @@ if test "x${je_cv_madvise}" = "xyes" ; then
fi
dnl Check for madvise(..., MADV_[NO]HUGEPAGE).
- JE_COMPILABLE([madvise(..., MADV_[[NO]]HUGEPAGE)], [
+ JE_RUNNABLE([madvise(..., MADV_[[NO]]HUGEPAGE)], [
#include <sys/mman.h>
+#include <errno.h>
], [
- madvise((void *)0, 0, MADV_HUGEPAGE);
- madvise((void *)0, 0, MADV_NOHUGEPAGE);
+ if (0 != madvise((void *)0, 0, MADV_HUGEPAGE) && EINVAL == errno)
+ return 1;
+ if (0 != madvise((void *)0, 0, MADV_NOHUGEPAGE) && EINVAL == errno)
+ return 1;
], [je_cv_thp])
if test "x${je_cv_thp}" = "xyes" ; then
AC_DEFINE([JEMALLOC_THP], [ ])
Basically MADV_HUGEPAGE and MADV_NOHUGEPAGE are defined in the headers, thus it will compile, but we need to execute it figure out if it actually works. If something like that is acceptable, I could make a proper PR. Same should be done with other madvise checks, I guess.
Activity
jasone commentedon Mar 1, 2017
I made a very similar change (a2e601a) and reverted it (4066b4e) when a similar issue came up for mutex configuration on macOS. Unfortunately, the approach isn't robust with regard to cross compilation. I added the
--disable-thpworkaround (d84d290) for the 4.5.0 release, which we can also do for the dev branch, ugly as it is.madscientist commentedon Mar 1, 2017
Thank you for keeping us poor cross-compilers in mind... we appreciate it!! :)
Add the --disable-thp option to support cross compiling.
Add the --disable-thp option to support cross compiling.