From patchwork Thu Jul 16 04:55:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 1329994 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B6hmX3HNNz9sR4 for ; Thu, 16 Jul 2020 14:56:28 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.ru Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4B6hmW58g9zDqcv for ; Thu, 16 Jul 2020 14:56:27 +1000 (AEST) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.ru (client-ip=107.174.27.60; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.ru Received: from ozlabs.ru (unknown [107.174.27.60]) by lists.ozlabs.org (Postfix) with ESMTP id 4B6hmL5kN3zDqpv for ; Thu, 16 Jul 2020 14:56:17 +1000 (AEST) Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 95857AE80021; Thu, 16 Jul 2020 00:53:10 -0400 (EDT) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Thu, 16 Jul 2020 14:55:42 +1000 Message-Id: <20200716045542.33554-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 Subject: [SLOF] [PATCH slof] fdt: Avoid recursion when traversing tree X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" A loop over peers does not need recursion which becomes a problem with hundreds devices. Cc: Greg Kurz Fixes: efa56b851fab ("fdt: Delete nodes of devices removed between boot and CAS") Suggested-by: Jordan Niethe Signed-off-by: Alexey Kardashevskiy Reviewed-by: Greg Kurz --- 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