devicetree: Add local makeshift allocator to avoid straining malloc()

Trick question: What happens when you call a simple malloc()
implementation with linear time complexity several thousand times in a
small loop?

This patch adds an extremely simple constant-time "allocator" for device
tree properties and nodes to cut down fdt_unflatten() time from several
dozen milliseconds to essentially nothing. There's no need for free() or
any of that fancy stuff since we generally only unflatten one kernel
device tree per boot.

The buffer sizes (1000 nodes and 5000 properties) were chosen as roughly
double of what a current Nyan kernel needs, which should hopefully be
reasonably future-proof for a while. The only cost is zeroing another
100-something KB of BSS, which is negligible.

BRANCH=nyan
BUG=None
TEST=Measured a firmware boot time reduction of 37ms on Nyan_Big.

Change-Id: Idc4ac9c81e3a42b400ae614b9b72a57af5155d91
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203034
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
Reviewed-by: Tom Warren <twarren@nvidia.com>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
1 file changed