From 011cfdfb6b96dc6d2069f1be85906f35e605d63a Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 12 Nov 2014 10:55:47 +0100 Subject: [PATCH] Check THP support at startup and warn about it. --- src/latency.h | 1 + src/redis.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/latency.h b/src/latency.h index 6ddbe041..240f54b4 100644 --- a/src/latency.h +++ b/src/latency.h @@ -63,6 +63,7 @@ struct latencyStats { void latencyMonitorInit(void); void latencyAddSample(char *event, mstime_t latency); +int THPIsEnabled(void); /* Latency monitoring macros. */ diff --git a/src/redis.c b/src/redis.c index 03a8a1cb..bb451397 100644 --- a/src/redis.c +++ b/src/redis.c @@ -30,6 +30,7 @@ #include "redis.h" #include "slowlog.h" #include "bio.h" +#include "latency.h" #include #include @@ -3035,10 +3036,13 @@ int linuxOvercommitMemoryValue(void) { return atoi(buf); } -void linuxOvercommitMemoryWarning(void) { +void linuxMemoryWarnings(void) { if (linuxOvercommitMemoryValue() == 0) { redisLog(REDIS_WARNING,"WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect."); } + if (THPIsEnabled()) { + redisLog(REDIS_WARNING,"WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled."); + } } #endif /* __linux__ */ @@ -3304,7 +3308,7 @@ int main(int argc, char **argv) { /* Things not needed when running in Sentinel mode. */ redisLog(REDIS_WARNING,"Server started, Redis version " REDIS_VERSION); #ifdef __linux__ - linuxOvercommitMemoryWarning(); + linuxMemoryWarnings(); #endif loadDataFromDisk(); if (server.ipfd_count > 0)