[SLOF] [PATCH slof] fdt: Avoid recursion when traversing tree
Alexey Kardashevskiy
aik at ozlabs.ru
Thu Jul 16 14:55:42 AEST 2020
A loop over peers does not need recursion which becomes a problem with
hundreds devices.
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
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
--
2.17.1
More information about the SLOF
mailing list