From f2706de026e453069bd2a4f25257172ebc91ec6b Mon Sep 17 00:00:00 2001 From: William Brown Date: Thu, 2 Jun 2016 11:04:05 +1000 Subject: [PATCH] Ticket 48863 - remove check for vmsize from util_info_sys_pages Bug Description: https://bugzilla.redhat.com/show_bug.cgi?id=1341709 and on another instance could not allocate cache because it would exceed memory size In both cases I suspect that that vmsize was low, and this causes the util_info_sys_pages check to return a low pages number, which triggers the checking to fail Fix Description: Remove the checks related to vmsize. It's either too low, or just too high and wrong. Either way, we never rely on it. Lets use reliable data. https://fedorahosted.org/389/ticket/48863 Author: wibrown Review by: ??? --- ldap/servers/slapd/util.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c index 89c7579..443e2a4 100644 --- a/ldap/servers/slapd/util.c +++ b/ldap/servers/slapd/util.c @@ -1538,7 +1538,7 @@ int util_info_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size * This space is a "funny number". It's a best effort based system * where linux instead of telling us how much memory *actually* exists * for us to use, gives us a virtual memory allocation which is the - * value of ram + swap. + * value of ram + swap.... sometimes. Depends on platform. * * But none of these pages even exist or belong to us on the real system * until will malloc them AND write a non-zero to them. @@ -1569,13 +1569,12 @@ int util_info_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size * potentially allocate: generally, this will be MemAvailable. */ - size_t vmsize = 0; size_t freesize = 0; size_t rlimsize = 0; *pagesize = getpagesize(); - /* Get the amount of freeram, rss, and the vmsize */ + /* Get the amount of freeram, rss */ FILE *f; char fn[40], s[80]; @@ -1596,9 +1595,6 @@ int util_info_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size /* VmRSS shows us what we are ACTUALLY using for proc pages * Rather than "funny" pages. */ - if (strncmp(s, "VmSize:", 7) == 0) { - sscanf(s+7, "%lu", (long unsigned int *)&vmsize); - } if (strncmp(s, "VmRSS:", 6) == 0) { sscanf(s+6, "%lu", (long unsigned int *)procpages); } @@ -1641,29 +1637,13 @@ int util_info_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size /* This is in bytes, make it pages */ rlimsize = rlimsize / *pagesize; } - /* Now we have vmsize, the availpages from getrlimit, our freesize */ - vmsize /= (*pagesize / 1024); /* Pages is the total ram on the system. We should smaller of: - * - vmsize * - pages */ - LDAPDebug(LDAP_DEBUG_TRACE,"util_info_sys_pages pages=%lu, vmsize=%lu, \n", - (unsigned long) *pages, (unsigned long) vmsize,0); -#if __GNUC__ -#if __x86_64__ || __ppc64__ - /* On 64bit platforms, vmsize is set high (VmSize), and doesn't change. IE 17tb */ - if (vmsize < *pages) { - LDAPDebug(LDAP_DEBUG_TRACE,"util_info_sys_pages using vmsize for pages \n",0,0,0); - *pages = vmsize; - } else { - LDAPDebug(LDAP_DEBUG_TRACE,"util_info_sys_pages using pages for pages \n",0,0,0); - } -#else - /* On 32bit platforms, vmsize is set low (VmSize) and grows. */ + LDAPDebug(LDAP_DEBUG_TRACE,"util_info_sys_pages pages=%lu, \n", + (unsigned long) *pages, 0,0); LDAPDebug(LDAP_DEBUG_TRACE,"util_info_sys_pages using pages for pages \n",0,0,0); -#endif -#endif /* Availpages is how much we *could* alloc. We should take the smallest: * - pages @@ -1809,6 +1789,7 @@ int util_is_cachesize_sane(size_t *cachesize) * the remaining system mem to the cachesize instead, and log a warning */ *cachesize = (size_t)((availpages * 0.75 ) * pagesize); + slapi_log_error(SLAPI_LOG_FATAL, "util_is_cachesize_sane", "Available pages %lu, requested pages %lu, pagesize %lu\n", (unsigned long)availpages, (unsigned long)cachepages, (unsigned long)pagesize); slapi_log_error(SLAPI_LOG_FATAL, "util_is_cachesize_sane", "WARNING adjusted cachesize to %lu\n", (unsigned long)*cachesize); } #else -- 2.5.5