MADV_DO[NOT]DUMP support equivalence on FreeBSD.

This commit is contained in:
David Carlier 2020-11-01 20:52:56 +00:00 committed by David Goldblatt
parent 180b843159
commit d2d941017b
3 changed files with 21 additions and 2 deletions

View File

@ -2132,6 +2132,16 @@ if test "x${je_cv_madvise}" = "xyes" ; then
madvise((void *)0, 0, MADV_HUGEPAGE); madvise((void *)0, 0, MADV_HUGEPAGE);
madvise((void *)0, 0, MADV_NOHUGEPAGE); madvise((void *)0, 0, MADV_NOHUGEPAGE);
], [je_cv_thp]) ], [je_cv_thp])
dnl Check for madvise(..., MADV_[NO]CORE).
JE_COMPILABLE([madvise(..., MADV_[[NO]]CORE)], [
#include <sys/mman.h>
], [
madvise((void *)0, 0, MADV_NOCORE);
madvise((void *)0, 0, MADV_CORE);
], [je_cv_madv_nocore])
if test "x${je_cv_madv_nocore}" = "xyes" ; then
AC_DEFINE([JEMALLOC_MADVISE_NOCORE], [ ])
fi
case "${host_cpu}" in case "${host_cpu}" in
arm*) arm*)
;; ;;

View File

@ -298,6 +298,11 @@
*/ */
#undef JEMALLOC_MADVISE_DONTDUMP #undef JEMALLOC_MADVISE_DONTDUMP
/*
* Defined if MADV_[NO]CORE is supported as an argument to madvise.
*/
#undef JEMALLOC_MADVISE_NOCORE
/* /*
* Defined if transparent huge pages (THPs) are supported via the * Defined if transparent huge pages (THPs) are supported via the
* MADV_[NO]HUGEPAGE arguments to madvise(2), and THP support is enabled. * MADV_[NO]HUGEPAGE arguments to madvise(2), and THP support is enabled.

View File

@ -413,8 +413,10 @@ bool
pages_dontdump(void *addr, size_t size) { pages_dontdump(void *addr, size_t size) {
assert(PAGE_ADDR2BASE(addr) == addr); assert(PAGE_ADDR2BASE(addr) == addr);
assert(PAGE_CEILING(size) == size); assert(PAGE_CEILING(size) == size);
#ifdef JEMALLOC_MADVISE_DONTDUMP #if defined(JEMALLOC_MADVISE_DONTDUMP)
return madvise(addr, size, MADV_DONTDUMP) != 0; return madvise(addr, size, MADV_DONTDUMP) != 0;
#elif defined(JEMALLOC_MADVISE_NOCORE)
return madvise(addr, size, MADV_NOCORE) != 0;
#else #else
return false; return false;
#endif #endif
@ -424,8 +426,10 @@ bool
pages_dodump(void *addr, size_t size) { pages_dodump(void *addr, size_t size) {
assert(PAGE_ADDR2BASE(addr) == addr); assert(PAGE_ADDR2BASE(addr) == addr);
assert(PAGE_CEILING(size) == size); assert(PAGE_CEILING(size) == size);
#ifdef JEMALLOC_MADVISE_DONTDUMP #if defined(JEMALLOC_MADVISE_DONTDUMP)
return madvise(addr, size, MADV_DODUMP) != 0; return madvise(addr, size, MADV_DODUMP) != 0;
#elif defined(JEMALLOC_MADVISE_NOCORE)
return madvise(addr, size, MADV_CORE) != 0;
#else #else
return false; return false;
#endif #endif