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

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