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

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