[SLOF] [PATCH slof] fdt: Avoid recursion when traversing tree
Greg Kurz
groug at kaod.org
Fri Jul 17 01:54:30 AEST 2020
Hi Alexey,
It seems it did again ! I haven't received this in my inbox, despite you've
put me on Cc... :-\
On Thu, 16 Jul 2020 14:55:42 +1000
Alexey Kardashevskiy <aik at ozlabs.ru> wrote:
> A loop over peers does not need recursion which becomes a problem with
> hundreds devices.
>
You're likely right but, per curiosity, do you have some numbers to
share ?
> Cc: Greg Kurz <groug at kaod.org>
> Fixes: efa56b851fab ("fdt: Delete nodes of devices removed between boot and CAS")
> Suggested-by: Jordan Niethe <jniethe5 at gmail.com>
> Signed-off-by: Alexey Kardashevskiy <aik at ozlabs.ru>
> ---
> board-qemu/slof/fdt.fs | 27 +++++++++++++++------------
> 1 file changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/board-qemu/slof/fdt.fs b/board-qemu/slof/fdt.fs
> index 7da4ff066702..03b1d4034d0a 100644
> --- a/board-qemu/slof/fdt.fs
> +++ b/board-qemu/slof/fdt.fs
> @@ -636,20 +636,23 @@ r> drop
> THEN
> ;
>
> -: (fdt-cas-search-obsolete-nodes) ( start node -- )
> - dup IF
> - dup child 2 pick swap recurse
> - dup peer 2 pick swap recurse
> -
> - dup fdt-cas-node-obsolete? IF
> - fdt-debug IF dup ." Deleting obsolete node: " dup .node ." = " . cr THEN
> - dup delete-node
> - THEN
> +: (fdt-cas-search-obsolete-nodes) ( node -- )
> + dup child
> + BEGIN
> + dup
> + WHILE
> + dup recurse
> + peer
> + REPEAT
> + drop
> + dup fdt-cas-node-obsolete? IF
> + fdt-debug IF dup ." Deleting obsolete node: " dup .node ." = " . cr THEN
> + dup delete-node
> THEN
> - 2drop
> + drop
> ;
>
> -: fdt-cas-delete-obsolete-nodes ( start -- )
> +: fdt-cas-delete-obsolete-nodes ( -- )
> s" /" find-device get-node (fdt-cas-search-obsolete-nodes)
> fdt-cas-delete-obsolete-aliases
> ;
> @@ -657,7 +660,7 @@ r> drop
> : fdt-fix-cas-node ( start -- )
> fdt-generation# 1+ to fdt-generation#
> 0 to fdt-cas-pass dup (fdt-fix-cas-node) drop \ Add phandles
> - dup fdt-cas-delete-obsolete-nodes \ Delete removed devices
> + fdt-cas-delete-obsolete-nodes \ Delete removed devices
Maybe keep the comment aligned with the other ones ?
Reviewed-by: Greg Kurz <groug at kaod.org>
> 1 to fdt-cas-pass dup (fdt-fix-cas-node) drop \ Patch+add other properties
> 2 to fdt-cas-pass dup (fdt-fix-cas-node) drop \ Delete phandles from pass 0
> drop
More information about the SLOF
mailing list