From: Anup Patel <apatel@ventanamicro.com>
To: opensbi@lists.infradead.org
Subject: [PATCH v2 00/18] Introduce and use simple heap allocator
Date: Mon, 5 Jun 2023 17:07:31 +0530 [thread overview]
Message-ID: <20230605113749.230696-1-apatel@ventanamicro.com> (raw)
Currently, we use global variables instead of explicitly allocating
memory in different parts of OpenSBI. This leads to a bloated BSS
section in the firmware binaries and this will continue to grow as
more drivers (and frameworks) with global variables are added.
To improve memory utilizaiton in OpenSBI:
1) We introduce a simple heap allocator which based on linked list.
This is a reasonable heap implementation to start with because
heap allocation and free-up won't be in hot path.
2) Use a combination of heap allocations and scratch space allocations
to improve the reduce the BSS memory foot-print.
As a by-product, this series also redunces global arrays indexed by hartid
which is preparatory work for the upcoming full sparse hartid support.
These patches can also be found in simple_heap_v2 branch at:
https://github.com/avpatel/opensbi.git
Chagnes since v1:
- Addressed Drew's comments in PATCH2, PATCH6, PATCH10, PATCH12, and
PATCH15
- New PATCH which adds helper macros in sbi_scratch.h to access
data type from scratch space.
Anup Patel (18):
include: sbi_scratch: Add helper macros to access data type
platform: Allow platforms to specify heap size
lib: sbi: Introduce simple heap allocator
lib: sbi: Print scratch size and usage at boot time
lib: sbi_pmu: Use heap for per-HART PMU state
lib: sbi: Use heap for root domain creation
lib: sbi: Use scratch space to save per-HART domain pointer
lib: utils/gpio: Use heap in SiFive and StartFive GPIO drivers
lib: utils/i2c: Use heap in DesignWare and SiFive I2C drivers
lib: utils/ipi: Use heap in ACLINT MSWI driver
lib: utils/irqchip: Use heap in PLIC, APLIC and IMSIC drivers
lib: utils/timer: Use heap in ACLINT MTIMER driver
lib: utils/fdt: Use heap in FDT domain parsing
lib: utils/ipi: Use scratch space to save per-HART MSWI pointer
lib: utils/timer: Use scratch space to save per-HART MTIMER pointer
lib: utils/irqchip: Use scratch space to save per-HART PLIC pointer
lib: utils/irqchip: Don't check hartid in imsic_update_hartid_table()
lib: utils/irqchip: Use scratch space to save per-HART IMSIC pointer
firmware/fw_base.S | 15 ++
include/sbi/sbi_domain.h | 6 +-
include/sbi/sbi_heap.h | 44 ++++++
include/sbi/sbi_platform.h | 18 ++-
include/sbi/sbi_scratch.h | 48 ++++--
lib/sbi/objects.mk | 1 +
lib/sbi/sbi_domain.c | 84 ++++++++--
lib/sbi/sbi_heap.c | 206 ++++++++++++++++++++++++
lib/sbi/sbi_init.c | 20 +++
lib/sbi/sbi_pmu.c | 215 +++++++++++++++-----------
lib/sbi/sbi_scratch.c | 11 ++
lib/utils/fdt/fdt_domain.c | 113 +++++++++-----
lib/utils/gpio/fdt_gpio_sifive.c | 21 ++-
lib/utils/gpio/fdt_gpio_starfive.c | 20 +--
lib/utils/i2c/fdt_i2c_dw.c | 24 ++-
lib/utils/i2c/fdt_i2c_sifive.c | 23 ++-
lib/utils/ipi/aclint_mswi.c | 43 ++++--
lib/utils/ipi/fdt_ipi_mswi.c | 21 ++-
lib/utils/irqchip/fdt_irqchip_aplic.c | 24 +--
lib/utils/irqchip/fdt_irqchip_imsic.c | 35 ++---
lib/utils/irqchip/fdt_irqchip_plic.c | 118 +++++++++-----
lib/utils/irqchip/imsic.c | 76 +++++++--
lib/utils/timer/aclint_mtimer.c | 76 +++++++--
lib/utils/timer/fdt_timer_mtimer.c | 47 ++++--
platform/fpga/ariane/platform.c | 1 +
platform/fpga/openpiton/platform.c | 2 +
platform/generic/platform.c | 3 +-
platform/kendryte/k210/platform.c | 2 +
platform/nuclei/ux600/platform.c | 2 +
platform/template/platform.c | 1 +
30 files changed, 971 insertions(+), 349 deletions(-)
create mode 100644 include/sbi/sbi_heap.h
create mode 100644 lib/sbi/sbi_heap.c
--
2.34.1
next reply other threads:[~2023-06-05 11:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-05 11:37 Anup Patel [this message]
2023-06-05 11:37 ` [PATCH v2 01/18] include: sbi_scratch: Add helper macros to access data type Anup Patel
2023-06-05 11:37 ` [PATCH v2 02/18] platform: Allow platforms to specify heap size Anup Patel
2023-06-05 11:37 ` [PATCH v2 03/18] lib: sbi: Introduce simple heap allocator Anup Patel
2023-06-05 11:37 ` [PATCH v2 04/18] lib: sbi: Print scratch size and usage at boot time Anup Patel
2023-06-05 11:37 ` [PATCH v2 05/18] lib: sbi_pmu: Use heap for per-HART PMU state Anup Patel
2023-06-05 11:37 ` [PATCH v2 06/18] lib: sbi: Use heap for root domain creation Anup Patel
2023-06-05 11:37 ` [PATCH v2 07/18] lib: sbi: Use scratch space to save per-HART domain pointer Anup Patel
2023-06-05 11:37 ` [PATCH v2 08/18] lib: utils/gpio: Use heap in SiFive and StartFive GPIO drivers Anup Patel
2023-06-05 11:37 ` [PATCH v2 09/18] lib: utils/i2c: Use heap in DesignWare and SiFive I2C drivers Anup Patel
2023-06-05 11:37 ` [PATCH v2 10/18] lib: utils/ipi: Use heap in ACLINT MSWI driver Anup Patel
2023-06-05 11:37 ` [PATCH v2 11/18] lib: utils/irqchip: Use heap in PLIC, APLIC and IMSIC drivers Anup Patel
2023-06-05 11:37 ` [PATCH v2 12/18] lib: utils/timer: Use heap in ACLINT MTIMER driver Anup Patel
2023-06-05 11:37 ` [PATCH v2 13/18] lib: utils/fdt: Use heap in FDT domain parsing Anup Patel
2023-06-05 11:37 ` [PATCH v2 14/18] lib: utils/ipi: Use scratch space to save per-HART MSWI pointer Anup Patel
2023-06-05 11:37 ` [PATCH v2 15/18] lib: utils/timer: Use scratch space to save per-HART MTIMER pointer Anup Patel
2023-06-05 11:37 ` [PATCH v2 16/18] lib: utils/irqchip: Use scratch space to save per-HART PLIC pointer Anup Patel
2023-06-05 11:37 ` [PATCH v2 17/18] lib: utils/irqchip: Don't check hartid in imsic_update_hartid_table() Anup Patel
2023-06-05 11:37 ` [PATCH v2 18/18] lib: utils/irqchip: Use scratch space to save per-HART IMSIC pointer Anup Patel
2023-06-06 10:33 ` [PATCH v2 00/18] Introduce and use simple heap allocator Anup Patel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230605113749.230696-1-apatel@ventanamicro.com \
--to=apatel@ventanamicro.com \
--cc=opensbi@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.