Blame SOURCES/0013-Ticket-49392-memavailable-not-available.patch

081b2d
From 9369164f45ba19519158286590aaefae1c64ef05 Mon Sep 17 00:00:00 2001
081b2d
From: William Brown <firstyear@redhat.com>
081b2d
Date: Thu, 5 Oct 2017 09:54:48 +1000
081b2d
Subject: [PATCH] Ticket 49392 - memavailable not available
081b2d
081b2d
Bug Description:  On certain linux platforms memAvailable is
081b2d
not actually available! This means that the value was 0, so
081b2d
cgroup max was read instead, setting the system ram to:
081b2d
081b2d
9223372036854771712
081b2d
081b2d
That's a bit excessive, and can cause memory allocations to fail.
081b2d
081b2d
Fix Description:  If memavail can't be found, fall back to
081b2d
memtotal instead.
081b2d
081b2d
https://pagure.io/389-ds-base/issue/49392
081b2d
081b2d
Author: wibrown
081b2d
081b2d
Review by: mreynolds (Thanks!)
081b2d
---
081b2d
 ldap/servers/slapd/slapi_pal.c | 11 ++++++++++-
081b2d
 1 file changed, 10 insertions(+), 1 deletion(-)
081b2d
081b2d
diff --git a/ldap/servers/slapd/slapi_pal.c b/ldap/servers/slapd/slapi_pal.c
081b2d
index 38c178cfa..600d03d4d 100644
081b2d
--- a/ldap/servers/slapd/slapi_pal.c
081b2d
+++ b/ldap/servers/slapd/slapi_pal.c
081b2d
@@ -155,7 +155,16 @@ spal_meminfo_get()
081b2d
 
081b2d
     /* Both memtotal and memavail are in kb */
081b2d
     memtotal = memtotal * 1024;
081b2d
-    memavail = memavail * 1024;
081b2d
+
081b2d
+    /*
081b2d
+     * Oracle Enterprise Linux doesn't provide a valid memavail value, so fall
081b2d
+     * back to 80% of memtotal.
081b2d
+     */
081b2d
+    if (memavail == 0) {
081b2d
+        memavail = memtotal * 0.8;
081b2d
+    } else {
081b2d
+        memavail = memavail * 1024;
081b2d
+    }
081b2d
 
081b2d
     /* If it's possible, get our cgroup info */
081b2d
     uint64_t cg_mem_soft = 0;
081b2d
-- 
081b2d
2.13.6
081b2d