diff mbox series

hw/phb4: Use local_alloc for phb4 structures

Message ID 20180731065541.14002-1-oohall@gmail.com
State Accepted
Headers show
Series hw/phb4: Use local_alloc for phb4 structures | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied
snowpatch_ozlabs/make_check success Test make_check on branch master

Commit Message

Oliver O'Halloran July 31, 2018, 6:55 a.m. UTC
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@linux.vnet.ibm.com>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 hw/phb4.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Stewart Smith Aug. 2, 2018, 6:42 a.m. UTC | #1
"Oliver O'Halloran" <oohall@gmail.com> writes:
> 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@linux.vnet.ibm.com>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
>  hw/phb4.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

Yeah, I think this ends up making sense.

I wonder what crazy "particularly large PCIe topologies" Ryan has been
playing with...

Merged to master as of 7a7ff2d6281fa7c4d90c836144f9c451427ecd25
diff mbox series

Patch

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);