fix a compilation error around madvise when make with jemalloc on MacOS (#9350)

We only use MADV_DONTNEED on Linux, that's were it was tested.
This commit is contained in:
DarrenJiang13 2021-08-10 16:32:27 +08:00 committed by GitHub
parent 8f8117f78e
commit 8ab33c18e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -537,9 +537,9 @@ void dismissObject(robj *o, size_t size_hint) {
/* madvise(MADV_DONTNEED) may not work if Transparent Huge Pages is enabled. */
if (server.thp_enabled) return;
/* Currently we use zmadvise_dontneed only when we use jemalloc.
/* Currently we use zmadvise_dontneed only when we use jemalloc with Linux.
* so we avoid these pointless loops when they're not going to do anything. */
#if defined(USE_JEMALLOC)
#if defined(USE_JEMALLOC) && defined(__linux__)
if (o->refcount != 1) return;
switch(o->type) {
case OBJ_STRING: dismissStringObject(o); break;

View File

@ -5987,9 +5987,9 @@ void dismissMemoryInChild(void) {
/* madvise(MADV_DONTNEED) may not work if Transparent Huge Pages is enabled. */
if (server.thp_enabled) return;
/* Currently we use zmadvise_dontneed only when we use jemalloc.
/* Currently we use zmadvise_dontneed only when we use jemalloc with Linux.
* so we avoid these pointless loops when they're not going to do anything. */
#if defined(USE_JEMALLOC)
#if defined(USE_JEMALLOC) && defined(__linux__)
/* Dismiss replication backlog. */
if (server.repl_backlog != NULL) {

View File

@ -346,7 +346,7 @@ void zmalloc_set_oom_handler(void (*oom_handler)(size_t)) {
* We do that in a fork child process to avoid CoW when the parent modifies
* these shared pages. */
void zmadvise_dontneed(void *ptr) {
#if defined(USE_JEMALLOC)
#if defined(USE_JEMALLOC) && defined(__linux__)
static size_t page_size = 0;
if (page_size == 0) page_size = sysconf(_SC_PAGESIZE);
size_t page_size_mask = page_size - 1;