Check THP support at startup and warn about it.

This commit is contained in:
antirez 2014-11-12 10:55:47 +01:00
parent 3ef0876b95
commit 110f0464e0
2 changed files with 7 additions and 2 deletions

View File

@ -63,6 +63,7 @@ struct latencyStats {
void latencyMonitorInit(void); void latencyMonitorInit(void);
void latencyAddSample(char *event, mstime_t latency); void latencyAddSample(char *event, mstime_t latency);
int THPIsEnabled(void);
/* Latency monitoring macros. */ /* Latency monitoring macros. */

View File

@ -31,6 +31,7 @@
#include "cluster.h" #include "cluster.h"
#include "slowlog.h" #include "slowlog.h"
#include "bio.h" #include "bio.h"
#include "latency.h"
#include <time.h> #include <time.h>
#include <signal.h> #include <signal.h>
@ -3330,10 +3331,13 @@ int linuxOvercommitMemoryValue(void) {
return atoi(buf); return atoi(buf);
} }
void linuxOvercommitMemoryWarning(void) { void linuxMemoryWarnings(void) {
if (linuxOvercommitMemoryValue() == 0) { 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."); 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__ */ #endif /* __linux__ */
@ -3606,7 +3610,7 @@ int main(int argc, char **argv) {
/* Things not needed when running in Sentinel mode. */ /* Things not needed when running in Sentinel mode. */
redisLog(REDIS_WARNING,"Server started, Redis version " REDIS_VERSION); redisLog(REDIS_WARNING,"Server started, Redis version " REDIS_VERSION);
#ifdef __linux__ #ifdef __linux__
linuxOvercommitMemoryWarning(); linuxMemoryWarnings();
#endif #endif
loadDataFromDisk(); loadDataFromDisk();
if (server.cluster_enabled) { if (server.cluster_enabled) {