[Skiboot] [PATCH] hw/phb4: Use local_alloc for phb4 structures

Oliver O'Halloran oohall at gmail.com
Tue Jul 31 16:55:41 AEST 2018


Struct phb4 is fairly heavyweight at 283664 bytes. On systems with
6x PHBs per socket this results in using 3.2MB of heap space the PHB
structures alone. This is a fairly large chunk of our 12MB heap and
on systems with particularly large PCIe topologies, or additional
PHBs we can fail to boot because we cannot allocate space for the
FDT blob.

This patch switches to using local_alloc() for the PHB structures
so they don't consume too large a portion of our 12MB heap space.

Signed-off-by: Ryan Grimm <grimm at linux.vnet.ibm.com>
Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
 hw/phb4.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/phb4.c b/hw/phb4.c
index a95a4b3301a7..8c231a9d93e5 100644
--- a/hw/phb4.c
+++ b/hw/phb4.c
@@ -5341,7 +5341,7 @@ static u64 lane_eq_default[8] = {
 static void phb4_create(struct dt_node *np)
 {
 	const struct dt_property *prop;
-	struct phb4 *p = zalloc(sizeof(struct phb4));
+	struct phb4 *p;
 	struct pci_slot *slot;
 	size_t lane_eq_len, lane_eq_len_req;
 	struct dt_node *iplp;
@@ -5349,12 +5349,16 @@ static void phb4_create(struct dt_node *np)
 	uint32_t irq_base, irq_flags;
 	int i;
 	struct proc_chip *chip;
+	int chip_id;
 
+	chip_id = dt_prop_get_u32(np, "ibm,chip-id");
+	p = local_alloc(chip_id, sizeof(struct phb4), 8);
 	assert(p);
+	memset(p, 0x0, sizeof(struct phb4));
 
 	/* Populate base stuff */
 	p->index = dt_prop_get_u32(np, "ibm,phb-index");
-	p->chip_id = dt_prop_get_u32(np, "ibm,chip-id");
+	p->chip_id = chip_id;
 	chip = get_chip(p->chip_id);
 	p->regs = (void *)dt_get_address(np, 0, NULL);
 	p->int_mmio = (void *)dt_get_address(np, 1, NULL);
-- 
2.9.5



More information about the Skiboot mailing list