From 110f0464e09ef3ff2d4f3a3a319377c77ed70d93 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 09b8103b..83e0946e 100644 --- a/src/redis.c +++ b/src/redis.c @@ -31,6 +31,7 @@ #include "cluster.h" #include "slowlog.h" #include "bio.h" +#include "latency.h" #include #include @@ -3330,10 +3331,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__ */ @@ -3606,7 +3610,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.cluster_enabled) {