[PATCH 04/40] lib: Convert str_to_list() to use alist
Sughosh Ganu
sughosh.ganu at linaro.org
Mon Jul 29 20:08:20 CEST 2024
On Mon, 29 Jul 2024 at 20:59, Simon Glass <sjg at chromium.org> wrote:
>
> Hi Sughosh,
>
> On Sun, 28 Jul 2024 at 12:07, Sughosh Ganu <sughosh.ganu at linaro.org> wrote:
> >
> > On Thu, 25 Jul 2024 at 18:24, Sughosh Ganu <sughosh.ganu at linaro.org> wrote:
> > >
> > > On Thu, 25 Jul 2024 at 02:24, Tom Rini <trini at konsulko.com> wrote:
> > > >
> > > > On Wed, Jul 24, 2024 at 11:31:48AM +0530, Sughosh Ganu wrote:
> > > >
> > > > > From: Simon Glass <sjg at chromium.org>
> > > > >
> > > > > Use this new data structure in the utility function.
> > > > >
> > > > > Signed-off-by: Simon Glass <sjg at chromium.org>
> > > > > Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
> > > > > ---
> > > > > lib/strto.c | 35 +++++++++++++++++++----------------
> > > > > 1 file changed, 19 insertions(+), 16 deletions(-)
> > > >
> > > > This is rather big growth when we didn't already have realloc:
> > > > 05: lib: Convert str_to_list() to use alist
> > > > aarch64: (for 1/1 boards) all +1765.0 rodata +37.0 text +1728.0
> > > > xilinx_versal_mini_emmc0: all +1765 rodata +37 text +1728
> > > > u-boot: add: 7/0, grow: 1/0 bytes: 1728/0 (1728)
> > > > function old new delta
> > > > realloc - 1120 +1120
> > > > alist_ensure_ptr - 140 +140
> > > > alist_expand_to - 136 +136
> > > > alist_init - 108 +108
> > > > alist_uninit_move_ptr - 76 +76
> > > > alist_add_ptr - 72 +72
> > > > alist_uninit - 48 +48
> > > > str_to_list 204 232 +28
> > > >
> > >
> > > I am working on an implementation of lmb maps using lists. The list
> > > nodes are then allocated with calloc, which I believe is included in
> > > most of the board images. We can then compare the size impact with the
> > > two implementations (alist vs list). Thanks.
> >
> > I have worked on implementing the LMB maps using simple lists, and we
> > do get a good size benefit with the list based implementation. I have
> > used the script that was shared by Tom some time back to get the size
> > impact [1]. The readings are with 1) alists with realloc 2) alist with
> > malloc and 3) using linked list. These are on a RPI4 build, which has
> > LMB enabled. I have checked the impact on a xilinx_versal_mini config
> > as well, which does not have LMB enabled, and the size impact result
> > is best with lists. The list based changes can be checked on my github
> > [2].
>
> Thanks for doing that. It is quite hard to read with the LTO enabled.
> You can try with the -L flag and should get a cleaner result. Also see
> my comment about how you are using alist directly instead of going
> through the API...that might affect things.
I can post the results with the -L flag used. Regarding your comment
on using the alist API's, I don't think that has a bearing on the size
of the image. Using the alist_add() might be faster in certain
scenarios, but I don't see how it impacts the size.
>
> Anyway (once you are using the API), my assumption from my previous
> refactor attempt was that lmb would be easier to deal with with simple
> arrays, which I why I wrote alist. Is that true, or not?
Yes, using the arrays keeps the code on similar lines to it's current
state. But I thought that the main consideration here was the size
impact.
-sughosh
>
> >
> > -sughosh
> >
> > [1] - https://gist.github.com/sughoshg/d4f9bda8d8a33f715dab892738d192ba
> > [2] - https://github.com/sughoshg/u-boot/tree/lmb_only_linked_lists_v3
>
> Regards,
> Simon
More information about the U-Boot
mailing list