aboutsummaryrefslogtreecommitdiff
path: root/core/mem_region.c
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2015-04-29 16:50:27 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-04-30 11:53:08 +1000
commit2aa878889dab81828183bca940aafcc45a209ae1 (patch)
tree6b9a8614f588248328a48fe5f092a3860fbe279a /core/mem_region.c
parentca755775fe760f8f2e3673b7f0f3140cc816e8cd (diff)
downloadskiboot-2aa878889dab81828183bca940aafcc45a209ae1.zip
skiboot-2aa878889dab81828183bca940aafcc45a209ae1.tar.gz
skiboot-2aa878889dab81828183bca940aafcc45a209ae1.tar.bz2
Adjust skiboot_cpu_stacks region size according to real max PIR
In skiboot, CPU stacks are indexed by PIR. During boot, we have two ideas about what the actual maximum PIR is: 1) detect CPU type (P7 or P8): we know max PIR is max for that proc (e.g. 1024, 8192) 2) start all CPUs (go through device tree for CPUs that exist). We now know the *actual* CPUs we have and the max PIR. e.g 1, 64, 3319 or whatever Each CPU stack is 16KB. So max CPU stacks size for P7 is 16MB, for P8 is 128MB. The *actual* max for the machine we're booting on is based on max PIR we detect during boot. I have found the following: Mambo: 16kb max (one CPU) P7: 64, meaning 64*16k = 1MB P8: 3320, meaning 3320*16k = 51MB So, currently, we were not reseting the size of the skiboot_cpu_stacks memory region correctly before boot (we construct that part of the device tree as the very last thing before booting the payload), even though the comment in mem_region.c would suggest we were, we weren't. Because code comments are evil and are nothing but filty, filthy lies. With this patch, we now properly adjust the CPU stacks memory region size after we've detected CPU type and after we've found the real max PIR. This saves between about 77MB and 128MB-16kB of memory from being in a reserved region and it'll now be available to the OS to use for things such as cat pictures rather than being firmware stack space waiting for a CPU that will never appear. You can see the difference in skiboot log, "Reserved regions:": Before: ALL: 0x000031a00000..0000399fffff : ibm,firmware-stacks AFTER: Mambo: 0x000031a00000..000031a1ffff : ibm,firmware-stacks P7: 0x000031a00000..000031afffff : ibm,firmware-stacks. P8: 0x000031a00000..000034ddffff : ibm,firmware-stacks Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core/mem_region.c')
-rw-r--r--core/mem_region.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/core/mem_region.c b/core/mem_region.c
index 5a496aa..d7c677d 100644
--- a/core/mem_region.c
+++ b/core/mem_region.c
@@ -725,6 +725,15 @@ struct mem_region *find_mem_region(const char *name)
return NULL;
}
+void adjust_cpu_stacks_alloc(void)
+{
+ /* CPU stacks start at 0, then when we know max possible PIR,
+ * we adjust, then when we bring all CPUs online we know the
+ * runtime max PIR, so we adjust this a few times during boot.
+ */
+ skiboot_cpu_stacks.len = (cpu_max_pir + 1) * STACK_SIZE;
+}
+
/* Trawl through device tree, create memory regions from nodes. */
void mem_region_init(void)
{
@@ -773,8 +782,7 @@ void mem_region_init(void)
unlock(&mem_region_lock);
}
- /* Now we know how many CPU stacks we have, fix that up. */
- skiboot_cpu_stacks.len = (cpu_max_pir + 1) * STACK_SIZE;
+ adjust_cpu_stacks_alloc();
lock(&mem_region_lock);