Julius Werner has submitted this change. ( https://review.coreboot.org/c/coreboot/+/83208?usp=email )
Change subject: commonlib/device_tree: Improve node and property allocation speed
......................................................................
commonlib/device_tree: Improve node and property allocation speed
Now that the device tree code has been made available in libpayload, we
should reintroduce the node and property allocation optimization for
libpayload's memory allocator that was originally dropped when porting
this code from depthcharge to coreboot.
On a Qualcomm SC7180 unflattening a normal ChromeOS kernel device tree,
this saves roughly ~145ms. The total scratch space used is about ~1350
nodes and ~5200 properties, so we leave a little room to grow with the
constants hardcoded here.
Change-Id: I0f4d80a8b750febfb069b32ef47304ccecdc35af
Signed-off-by: Julius Werner <jwerner(a)chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/83208
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org>
Reviewed-by: Maximilian Brune <maximilian.brune(a)9elements.com>
Reviewed-by: Raul Rangel <rrangel(a)chromium.org>
---
M src/commonlib/device_tree.c
1 file changed, 41 insertions(+), 8 deletions(-)
Approvals:
Maximilian Brune: Looks good to me, approved
build bot (Jenkins): Verified
Raul Rangel: Looks good to me, approved
diff --git a/src/commonlib/device_tree.c b/src/commonlib/device_tree.c
index f70aaf7..0ec6ea9 100644
--- a/src/commonlib/device_tree.c
+++ b/src/commonlib/device_tree.c
@@ -25,6 +25,41 @@
#define FDT_MAX_MEMORY_REGIONS 16 // should be a good enough upper bound
/*
+ * libpayload's malloc() has a linear allocation complexity, which means that it
+ * degrades massively if we make a few thousand small allocations. Preventing
+ * that problem with a custom scratchpad is well-worth some increase in BSS
+ * size (64 * 2000 + 40 * 10000 = ~1/2 MB).
+ */
+
+/* Try to give these a healthy margin above what the average kernel DT needs. */
+#define LP_ALLOC_NODE_SCRATCH_COUNT 2000
+#define LP_ALLOC_PROP_SCRATCH_COUNT 10000
+
+static struct device_tree_node *alloc_node(void)
+{
+#ifndef __COREBOOT__
+ static struct device_tree_node scratch[LP_ALLOC_NODE_SCRATCH_COUNT];
+ static int counter = 0;
+
+ if (counter < ARRAY_SIZE(scratch))
+ return &scratch[counter++];
+#endif
+ return xzalloc(sizeof(struct device_tree_node));
+}
+
+static struct device_tree_property *alloc_prop(void)
+{
+#ifndef __COREBOOT__
+ static struct device_tree_property scratch[LP_ALLOC_PROP_SCRATCH_COUNT];
+ static int counter = 0;
+
+ if (counter < ARRAY_SIZE(scratch))
+ return &scratch[counter++];
+#endif
+ return xzalloc(sizeof(struct device_tree_property));
+}
+
+/*
* Functions for picking apart flattened trees.
*/
@@ -625,14 +660,14 @@
return 0;
offset += size;
- struct device_tree_node *node = xzalloc(sizeof(*node));
+ struct device_tree_node *node = alloc_node();
*new_node = node;
node->name = name;
struct fdt_property fprop;
last = &node->properties;
while ((size = fdt_next_property(blob, offset, &fprop))) {
- struct device_tree_property *prop = xzalloc(sizeof(*prop));
+ struct device_tree_property *prop = alloc_prop();
prop->prop = fprop;
if (dt_prop_is_phandle(prop)) {
@@ -1003,9 +1038,7 @@
if (!create)
return NULL;
- found = calloc(1, sizeof(*found));
- if (!found)
- return NULL;
+ found = alloc_node();
found->name = strdup(*path);
if (!found->name)
return NULL;
@@ -1333,7 +1366,7 @@
}
}
- prop = xzalloc(sizeof(*prop));
+ prop = alloc_prop();
list_insert_after(&prop->list_node, &node->properties);
prop->prop.name = name;
prop->prop.data = data;
@@ -1847,7 +1880,7 @@
continue;
}
} else {
- dst_prop = xzalloc(sizeof(*dst_prop));
+ dst_prop = alloc_prop();
list_insert_after(&dst_prop->list_node,
&dst->properties);
}
@@ -1866,7 +1899,7 @@
}
if (!dst_node) {
- dst_node = xzalloc(sizeof(*dst_node));
+ dst_node = alloc_node();
*dst_node = *src_node;
list_insert_after(&dst_node->list_node, &dst->children);
} else {
--
To view, visit https://review.coreboot.org/c/coreboot/+/83208?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: I0f4d80a8b750febfb069b32ef47304ccecdc35af
Gerrit-Change-Number: 83208
Gerrit-PatchSet: 4
Gerrit-Owner: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Maximilian Brune <maximilian.brune(a)9elements.com>
Gerrit-Reviewer: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Gerrit-Reviewer: Raul Rangel <rrangel(a)chromium.org>
Gerrit-Reviewer: Reka Norman <rekanorman(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Attention is currently required from: Felix Held.
Matt DeVillier has posted comments on this change by Felix Held. ( https://review.coreboot.org/c/coreboot/+/83224?usp=email )
Change subject: lib/string: use size_t for local variable in strncmp
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://review.coreboot.org/c/coreboot/+/83224?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: Ibe35d3741bc6d8a16a3bad3ec27aafc30745d931
Gerrit-Change-Number: 83224
Gerrit-PatchSet: 1
Gerrit-Owner: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-Reviewer: Marshall Dawson <marshalldawson3rd(a)gmail.com>
Gerrit-Reviewer: Matt DeVillier <matt.devillier(a)gmail.com>
Gerrit-Reviewer: Varshit Pandya <pandyavarshit(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-Comment-Date: Wed, 26 Jun 2024 23:52:17 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: Arthur Heymans, Felix Held, Martin L Roth.
Matt DeVillier has posted comments on this change by Felix Held. ( https://review.coreboot.org/c/coreboot/+/83223?usp=email )
Change subject: lib/string: change return types to match C standard
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://review.coreboot.org/c/coreboot/+/83223?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: I0ff612e2eee4f556f5c572b02cbc600ca411ae20
Gerrit-Change-Number: 83223
Gerrit-PatchSet: 1
Gerrit-Owner: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Marshall Dawson <marshalldawson3rd(a)gmail.com>
Gerrit-Reviewer: Martin L Roth <gaumless(a)gmail.com>
Gerrit-Reviewer: Matt DeVillier <matt.devillier(a)gmail.com>
Gerrit-Reviewer: Varshit Pandya <pandyavarshit(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Martin L Roth <gaumless(a)gmail.com>
Gerrit-Attention: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Attention: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-Comment-Date: Wed, 26 Jun 2024 23:52:01 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: Arthur Heymans, Felix Held, Martin L Roth.
Matt DeVillier has posted comments on this change by Felix Held. ( https://review.coreboot.org/c/coreboot/+/83222?usp=email )
Change subject: lib/string: change parameter types to match C standard
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://review.coreboot.org/c/coreboot/+/83222?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: I485e45e18232a0d1625d4d626f923ec66cfbe4a2
Gerrit-Change-Number: 83222
Gerrit-PatchSet: 1
Gerrit-Owner: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Marshall Dawson <marshalldawson3rd(a)gmail.com>
Gerrit-Reviewer: Martin L Roth <gaumless(a)gmail.com>
Gerrit-Reviewer: Matt DeVillier <matt.devillier(a)gmail.com>
Gerrit-Reviewer: Varshit Pandya <pandyavarshit(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Martin L Roth <gaumless(a)gmail.com>
Gerrit-Attention: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Attention: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-Comment-Date: Wed, 26 Jun 2024 23:51:26 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: Hung-Te Lin, Xuxin Xiong, Yang Wu, Yidi Lin.
Yu-Ping Wu has posted comments on this change by Yang Wu. ( https://review.coreboot.org/c/coreboot/+/83221?usp=email )
Change subject: mb/google/corsola/var/wugtrio: Add LCE_LMFBX101117480 MIPI panel
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://review.coreboot.org/c/coreboot/+/83221?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: I863e172400ffb26b5c9c240a21d15c6a2240b4ad
Gerrit-Change-Number: 83221
Gerrit-PatchSet: 1
Gerrit-Owner: Yang Wu <wuyang5(a)huaqin.corp-partner.google.com>
Gerrit-Reviewer: Hung-Te Lin <hungte(a)chromium.org>
Gerrit-Reviewer: Xuxin Xiong <xuxinxiong(a)huaqin.corp-partner.google.com>
Gerrit-Reviewer: Yidi Lin <yidilin(a)google.com>
Gerrit-Reviewer: Yu-Ping Wu <yupingso(a)google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Hung-Te Lin <hungte(a)chromium.org>
Gerrit-Attention: Xuxin Xiong <xuxinxiong(a)huaqin.corp-partner.google.com>
Gerrit-Attention: Yang Wu <wuyang5(a)huaqin.corp-partner.google.com>
Gerrit-Attention: Yidi Lin <yidilin(a)google.com>
Gerrit-Comment-Date: Wed, 26 Jun 2024 23:35:40 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: Xuxin Xiong, Yang Wu, Yu-Ping Wu.
Yidi Lin has posted comments on this change by Yang Wu. ( https://review.coreboot.org/c/coreboot/+/83220?usp=email )
Change subject: drivers/mipi: Add support for LCE_LMFBX101117480 panel
......................................................................
Patch Set 1:
(1 comment)
File src/drivers/mipi/panel-LCE_LMFBX101117480.c:
https://review.coreboot.org/c/coreboot/+/83220/comment/24470d80_d0211c09?us… :
PS1, Line 5: KD_KD101NE3_40TI
this should be `LCE_LMFBX101117480` ?
--
To view, visit https://review.coreboot.org/c/coreboot/+/83220?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: I60858109e4b07f720461e320212d7b197ec1130c
Gerrit-Change-Number: 83220
Gerrit-PatchSet: 1
Gerrit-Owner: Yang Wu <wuyang5(a)huaqin.corp-partner.google.com>
Gerrit-Reviewer: Xuxin Xiong <xuxinxiong(a)huaqin.corp-partner.google.com>
Gerrit-Reviewer: Yidi Lin <yidilin(a)google.com>
Gerrit-Reviewer: Yu-Ping Wu <yupingso(a)google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Xuxin Xiong <xuxinxiong(a)huaqin.corp-partner.google.com>
Gerrit-Attention: Yu-Ping Wu <yupingso(a)google.com>
Gerrit-Attention: Yang Wu <wuyang5(a)huaqin.corp-partner.google.com>
Gerrit-Comment-Date: Wed, 26 Jun 2024 23:20:10 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Attention is currently required from: Angel Pons, Arthur Heymans.
Nico Huber has posted comments on this change by Angel Pons. ( https://review.coreboot.org/c/coreboot/+/83218?usp=email )
Change subject: device/azalia_device.c: Always read-write GCAP
......................................................................
Patch Set 1: Code-Review+2
(1 comment)
Patchset:
PS1:
LGTM. I wouldn't mind keeping the Kconfig either. But given that selecting
it was missed once, I guess something tries to tell us we shouldn't optimize too much.
--
To view, visit https://review.coreboot.org/c/coreboot/+/83218?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: Id61e6976a455273e8c681dbeb4bad35d57b1a8a2
Gerrit-Change-Number: 83218
Gerrit-PatchSet: 1
Gerrit-Owner: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Comment-Date: Wed, 26 Jun 2024 22:00:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes