mbox series

[RFC,0/7] Cleanup the LMB subsystem

Message ID 20241208105223.2821049-1-ilias.apalodimas@linaro.org
Headers show
Series Cleanup the LMB subsystem | expand

Message

Ilias Apalodimas Dec. 8, 2024, 10:52 a.m. UTC
The LMB subsystem was used opportunistically for a number of years.
A while back Sughosh merged it with the EFI subsystem in order to have a
common allocator and avoid subsystems overwriting memory they shouldn't.

This is an initial cleanup of all the crud we gathered over the years.
There's no functional change expected from the patches as they just cleanup
some abstraction functions and rename a few variables to make more
sense.

This has to be rebased on top of Sam's [0] changes but that should be
trivial.

I plan to make even bigger changes -- e.g I don't see the point of
having *_alloc() and *_reserve() versions of the functions since they mostly
do the same thing and just cause confusion. lmb_alloc_addr_flags()
returning the base address on success makes little sense since we
already *request* the address on the function arguments, etc.
But since this patchset grew enough already, I'd like to get it in
before more refactoring happens.

It's worth noting that although some patches slightly increase the code
size due to an extra flags argument being carried around, the final
result is eventually smaller.

add/remove: 2/5 grow/shrink: 17/3 up/down: 479/-524 (-45)
Function                                     old     new   delta
lmb_alloc_base_flags                           -     299    +299
lmb_alloc_addr_flags                           -      90     +90
test_alloc_addr                             2933    2963     +30
lib_test_lmb_overlapping_reserve            1018    1030     +12
test_multi_alloc.constprop                  3034    3042      +8
test_get_unreserved_size                    1032    1038      +6
boot_relocate_fdt                            599     605      +6
lmb_alloc                                      4       9      +5
wget_handler                                1530    1533      +3
tftp_handler                                1190    1192      +2
test_noreserved                             1207    1209      +2
test_bigblock                                911     913      +2
load_serial                                  946     948      +2
lib_test_lmb_flags                          2101    2103      +2
do_spi_flash                                3150    3152      +2
do_bootz                                     526     528      +2
do_bootm_linux                              2067    2069      +2
bootm_run_states                            5275    5277      +2
_fs_read.lto_priv                            331     333      +2
lmb_reserve                                    4       -      -4
lmb_alloc_addr                                 4       -      -4
lmb_overlaps_region                           62      52     -10
lmb_add_region_flags                         600     568     -32
lmb_alloc_base                                48       -     -48
efi_allocate_pages.part                      303     249     -54
_lmb_alloc_addr.lto_priv                      92       -     -92
_lmb_alloc_base.lto_priv                     280       -    -280
Total: Before=2492742, After=2492697, chg -0.00%

[0] https://lore.kernel.org/u-boot/20241208002121.31887-1-semen.protsenko@linaro.org/


Ilias Apalodimas (7):
  lmb: Replace lmb_reserve() with lmb_reserve_flags()
  lmb: Simplify lmb_addrs_overlap()
  lmb: Rename free_mem to available_mem
  lmb: Remove lmb_add_region()
  lmb: Replace lmb_alloc_addr() with lmb_alloc_addr_flags()
  lmb: Replace lmb_alloc_base() with lmb_alloc_base_flags()
  lmb: Rename _lmb_alloc_addr_flags()

 arch/powerpc/cpu/mpc85xx/mp.c |   2 +-
 arch/powerpc/lib/misc.c       |   2 +-
 boot/bootm.c                  |   3 +-
 boot/image-board.c            |  24 +++++---
 boot/image-fdt.c              |  11 ++--
 cmd/booti.c                   |   2 +-
 cmd/bootz.c                   |   2 +-
 cmd/load.c                    |   2 +-
 fs/fs.c                       |   2 +-
 include/lmb.h                 |  11 ++--
 lib/lmb.c                     | 111 +++++++++++-----------------------
 test/cmd/bdinfo.c             |   2 +-
 test/lib/lmb.c                |  68 +++++++++++----------
 13 files changed, 105 insertions(+), 137 deletions(-)

--
2.45.2

Comments

Ilias Apalodimas Dec. 8, 2024, 11:09 a.m. UTC | #1
+CC Sam

Apologies, I forgot to CC you, I guess you can find the rest of the
series on lore?

On Sun, 8 Dec 2024 at 12:52, Ilias Apalodimas
<ilias.apalodimas@linaro.org> wrote:
>
> The LMB subsystem was used opportunistically for a number of years.
> A while back Sughosh merged it with the EFI subsystem in order to have a
> common allocator and avoid subsystems overwriting memory they shouldn't.
>
> This is an initial cleanup of all the crud we gathered over the years.
> There's no functional change expected from the patches as they just cleanup
> some abstraction functions and rename a few variables to make more
> sense.
>
> This has to be rebased on top of Sam's [0] changes but that should be
> trivial.
>
> I plan to make even bigger changes -- e.g I don't see the point of
> having *_alloc() and *_reserve() versions of the functions since they mostly
> do the same thing and just cause confusion. lmb_alloc_addr_flags()
> returning the base address on success makes little sense since we
> already *request* the address on the function arguments, etc.
> But since this patchset grew enough already, I'd like to get it in
> before more refactoring happens.
>
> It's worth noting that although some patches slightly increase the code
> size due to an extra flags argument being carried around, the final
> result is eventually smaller.
>
> add/remove: 2/5 grow/shrink: 17/3 up/down: 479/-524 (-45)
> Function                                     old     new   delta
> lmb_alloc_base_flags                           -     299    +299
> lmb_alloc_addr_flags                           -      90     +90
> test_alloc_addr                             2933    2963     +30
> lib_test_lmb_overlapping_reserve            1018    1030     +12
> test_multi_alloc.constprop                  3034    3042      +8
> test_get_unreserved_size                    1032    1038      +6
> boot_relocate_fdt                            599     605      +6
> lmb_alloc                                      4       9      +5
> wget_handler                                1530    1533      +3
> tftp_handler                                1190    1192      +2
> test_noreserved                             1207    1209      +2
> test_bigblock                                911     913      +2
> load_serial                                  946     948      +2
> lib_test_lmb_flags                          2101    2103      +2
> do_spi_flash                                3150    3152      +2
> do_bootz                                     526     528      +2
> do_bootm_linux                              2067    2069      +2
> bootm_run_states                            5275    5277      +2
> _fs_read.lto_priv                            331     333      +2
> lmb_reserve                                    4       -      -4
> lmb_alloc_addr                                 4       -      -4
> lmb_overlaps_region                           62      52     -10
> lmb_add_region_flags                         600     568     -32
> lmb_alloc_base                                48       -     -48
> efi_allocate_pages.part                      303     249     -54
> _lmb_alloc_addr.lto_priv                      92       -     -92
> _lmb_alloc_base.lto_priv                     280       -    -280
> Total: Before=2492742, After=2492697, chg -0.00%
>
> [0] https://lore.kernel.org/u-boot/20241208002121.31887-1-semen.protsenko@linaro.org/
>
>
> Ilias Apalodimas (7):
>   lmb: Replace lmb_reserve() with lmb_reserve_flags()
>   lmb: Simplify lmb_addrs_overlap()
>   lmb: Rename free_mem to available_mem
>   lmb: Remove lmb_add_region()
>   lmb: Replace lmb_alloc_addr() with lmb_alloc_addr_flags()
>   lmb: Replace lmb_alloc_base() with lmb_alloc_base_flags()
>   lmb: Rename _lmb_alloc_addr_flags()
>
>  arch/powerpc/cpu/mpc85xx/mp.c |   2 +-
>  arch/powerpc/lib/misc.c       |   2 +-
>  boot/bootm.c                  |   3 +-
>  boot/image-board.c            |  24 +++++---
>  boot/image-fdt.c              |  11 ++--
>  cmd/booti.c                   |   2 +-
>  cmd/bootz.c                   |   2 +-
>  cmd/load.c                    |   2 +-
>  fs/fs.c                       |   2 +-
>  include/lmb.h                 |  11 ++--
>  lib/lmb.c                     | 111 +++++++++++-----------------------
>  test/cmd/bdinfo.c             |   2 +-
>  test/lib/lmb.c                |  68 +++++++++++----------
>  13 files changed, 105 insertions(+), 137 deletions(-)
>
> --
> 2.45.2
>