chiark / gitweb /
readahead: disable on low memory machines
[elogind.git] / src / readahead-common.c
index 8533717d479ae7aa8befb3b4812aea5b537ec649..88441dbe1c913e35ae1e21245a760650347485af 100644 (file)
@@ -23,6 +23,7 @@
 #include <libudev.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/sysinfo.h>
 
 #include "log.h"
 #include "readahead-common.h"
@@ -105,3 +106,13 @@ finish:
 
         return b;
 }
+
+bool enough_ram(void) {
+        struct sysinfo si;
+
+        assert_se(sysinfo(&si) >= 0);
+
+        return si.totalram > 127 * 1024*1024; /* Enable readahead only
+                                               * with at least 128MB
+                                               * memory */
+}