summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDan Crowell <dcrowell@us.ibm.com>2019-02-10 13:12:10 -0600
committerDaniel M. Crowell <dcrowell@us.ibm.com>2019-02-12 16:24:46 -0600
commita733a70261d1c847e3130c509cc911f86d71453d (patch)
tree2d7b267b41bd857a52fbcd149e10fb75fdbee2a5 /src
parent4d92ae4d4ac17899bb2a521dc82cc0de09608478 (diff)
downloadblackbird-hostboot-a733a70261d1c847e3130c509cc911f86d71453d.tar.gz
blackbird-hostboot-a733a70261d1c847e3130c509cc911f86d71453d.zip
Add more agressive memory allocation calls
If we hit a situation where we can't allocate a page of memory, this will force a coalesce (defrag) a few times and then eventually trigger other memory reclamation actions. Also tweaked a few spots in the kernel to enhance debug: - add more stops to look at errors (HB_BREAK_ON_ERROR) - add more backtrace calls - add a new debug flag to count the extra coalesce calls Change-Id: Ibac7079a44a12dc61e41304de4c4ae518c206d13 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/71653 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Reviewed-by: Matt Derksen <mderkse1@us.ibm.com> Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/build/debug/Hostboot/MemStats.pm7
-rw-r--r--src/include/kernel/pagemgr.H3
-rw-r--r--src/include/usr/debugpointers.H1
-rw-r--r--src/kernel/cpumgr.C2
-rw-r--r--src/kernel/exception.C3
-rw-r--r--src/kernel/msghandler.C6
-rw-r--r--src/kernel/pagemgr.C29
7 files changed, 43 insertions, 8 deletions
diff --git a/src/build/debug/Hostboot/MemStats.pm b/src/build/debug/Hostboot/MemStats.pm
index 9156d8267..723b76aae 100755
--- a/src/build/debug/Hostboot/MemStats.pm
+++ b/src/build/debug/Hostboot/MemStats.pm
@@ -5,7 +5,7 @@
#
# OpenPOWER HostBoot Project
#
-# Contributors Listed Below - COPYRIGHT 2011,2018
+# Contributors Listed Below - COPYRIGHT 2011,2019
# [+] International Business Machines Corp.
#
#
@@ -75,6 +75,10 @@ sub main
::findPointer("PAGEMCNT",
"PageManager::cv_coalesce_count");
+ my $page_alloc_coal = ::read64
+ ::findPointer("PAGEMACC",
+ "PageManager::cv_alloc_coalesce_count");
+
my $big_heap_pages_used = ::read32
::findPointer("HEAPMLPC",
"HeapManager::cv_largeheap_page_count");
@@ -118,6 +122,7 @@ sub main
::userDisplay " Free pages: $free_pages\n";
::userDisplay " Free pages Low mark: $free_min\n";
::userDisplay " Page chunks coalesced: $page_coal\n";
+ ::userDisplay " Page alloc coalesces: $page_alloc_coal\n";
::userDisplay "\nHeap:\n";
::userDisplay " Pages used by heap: $heap_total ".
"(B:$big_heap_pages_used,S:$small_heap_pages_used)\n";
diff --git a/src/include/kernel/pagemgr.H b/src/include/kernel/pagemgr.H
index 2431c613d..7b5deddb4 100644
--- a/src/include/kernel/pagemgr.H
+++ b/src/include/kernel/pagemgr.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2010,2018 */
+/* Contributors Listed Below - COPYRIGHT 2010,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -200,6 +200,7 @@ class PageManager
static size_t cv_coalesce_count; //!< running coalesced counter
static size_t cv_low_page_count; //!< lowest page count
+ static size_t cv_alloc_coalesce_count; //!< number of repeat allocs
protected:
diff --git a/src/include/usr/debugpointers.H b/src/include/usr/debugpointers.H
index 01de1a0d8..5815761e8 100644
--- a/src/include/usr/debugpointers.H
+++ b/src/include/usr/debugpointers.H
@@ -95,6 +95,7 @@ constexpr uint64_t HEAPMANAGERFREECHUNKS = 0x4845415043484e4b; //'HEAPCHNK'
constexpr uint64_t PAGEMANAGER = 0x504147454d475220; //'PAGEMGR '
constexpr uint64_t PAGEMANAGERCOALESCECOUNT = 0x504147454d434e54; //'PAGEMCNT'
constexpr uint64_t PAGEMANAGERLOWPAGECOUNT = 0x504147454d4c5043; //'PAGEMLPC'
+constexpr uint64_t PAGEMANAGERALLOCCOUNT = 0x504147454d414343; //'PAGEMACC'
constexpr uint64_t SEGMENTMANAGER = 0x53474d4e544d4752; //'SGMNTMGR'
constexpr uint64_t BLOCKREADONLYEVICT = 0x424c4f434b524f45; //'BLOCKROE'
constexpr uint64_t BLOCKREADWRITEEVICT = 0x424c4f434b525745; //'BLOCKRWE'
diff --git a/src/kernel/cpumgr.C b/src/kernel/cpumgr.C
index 425cc2d28..87c5251c7 100644
--- a/src/kernel/cpumgr.C
+++ b/src/kernel/cpumgr.C
@@ -553,7 +553,7 @@ void CpuManager::critAssert(uint64_t i_failAddr)
{
// print status to the console.
printk("TI initiated on all threads (crit_assert)\n");
-
+ MAGIC_INSTRUCTION(MAGIC_BREAK_ON_ERROR);
}
void activeMainWork()
diff --git a/src/kernel/exception.C b/src/kernel/exception.C
index d3a1dbe6b..938d57515 100644
--- a/src/kernel/exception.C
+++ b/src/kernel/exception.C
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2010,2018 */
+/* Contributors Listed Below - COPYRIGHT 2010,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -150,6 +150,7 @@ void kernel_execute_inst_storage()
{
printk("Inst Storage exception on %d: %lx, %lx\n",
t->tid, getSRR0(), getSRR1());
+ KernelMisc::printkBacktrace(t);
MAGIC_INSTRUCTION(MAGIC_BREAK_ON_ERROR);
TaskManager::endTask(t, NULL, TASK_STATUS_CRASHED);
}
diff --git a/src/kernel/msghandler.C b/src/kernel/msghandler.C
index 1f22a7a70..8e7244d2b 100644
--- a/src/kernel/msghandler.C
+++ b/src/kernel/msghandler.C
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2011,2017 */
+/* Contributors Listed Below - COPYRIGHT 2011,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -32,6 +32,8 @@
#include <kernel/taskmgr.H>
#include <kernel/console.H>
#include <kernel/doorbell.H>
+#include <kernel/misc.H>
+
void MessageHandler::sendMessage(msg_sys_types_t i_type, void* i_key,
void* i_data, task_t* i_task)
@@ -181,6 +183,8 @@ int MessageHandler::recvMessage(msg_t* i_msg)
printk("Unhandled msg rc %d (%s) for key %p on task %d @ %p\n",
msg_rc, ErrnoToString(msg_rc), key, deferred_task->tid,
deferred_task->context.nip);
+ KernelMisc::printkBacktrace(deferred_task);
+ MAGIC_INSTRUCTION(MAGIC_BREAK_ON_ERROR);
endTaskList.insert(deferred_task);
}
else if (CONTINUE_DEFER == rc)
diff --git a/src/kernel/pagemgr.C b/src/kernel/pagemgr.C
index bfc1bbf7a..ee3a3ff39 100644
--- a/src/kernel/pagemgr.C
+++ b/src/kernel/pagemgr.C
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2010,2018 */
+/* Contributors Listed Below - COPYRIGHT 2010,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -39,11 +39,12 @@
#include <kernel/bltohbdatamgr.H>
#include <kernel/misc.H>
#include <usr/debugpointers.H>
+#include <kernel/cpumgr.H>
size_t PageManager::cv_coalesce_count = 0;
size_t PageManager::cv_low_page_count = -1;
-
+size_t PageManager::cv_alloc_coalesce_count = 0;
void PageManagerCore::addMemory( size_t i_addr, size_t i_pageCount )
{
@@ -165,10 +166,11 @@ void* PageManager::allocatePage(size_t n, bool userspace)
// Didn't successfully allocate, so yield in hopes that memory
// will eventually free up (ex. VMM flushes).
+ constexpr size_t MAX_ATTEMPTS = 10000;
if (NULL == page)
{
l_attempts++;
- if( l_attempts == 10000 )
+ if( l_attempts == MAX_ATTEMPTS )
{
printk( "Cannot allocate %ld pages to %d!\n",
n, task_gettid() );
@@ -176,7 +178,25 @@ void* PageManager::allocatePage(size_t n, bool userspace)
KernelMisc::printkBacktrace(nullptr);
task_crash();
}
+
task_yield();
+
+ // Force a defrag of the memory 10 times
+ if( l_attempts % (MAX_ATTEMPTS/10) == 0 )
+ {
+ printkd( "Forcing coalesce to allocate %ld pages to %d!\n",
+ n, task_gettid() );
+ coalesce();
+ ++PageManager::cv_alloc_coalesce_count;
+ }
+
+ // Try to evict some pages once
+ if( l_attempts == MAX_ATTEMPTS/2 )
+ {
+ printkd( "Forcing periodics to allocate %ld pages to %d!\n",
+ n, task_gettid() );
+ CpuManager::forceMemoryPeriodic();
+ }
}
}
}
@@ -496,4 +516,7 @@ void PageManager::_addDebugPointers()
DEBUG::add_debug_pointer(DEBUG::PAGEMANAGERCOALESCECOUNT,
&PageManager::cv_coalesce_count,
sizeof(PageManager::cv_coalesce_count));
+ DEBUG::add_debug_pointer(DEBUG::PAGEMANAGERALLOCCOUNT,
+ &PageManager::cv_alloc_coalesce_count,
+ sizeof(PageManager::cv_alloc_coalesce_count));
}
OpenPOWER on IntegriCloud