From patchwork Mon Oct 16 05:16:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 826124 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yFmlt3LcXz9sPk for ; Mon, 16 Oct 2017 16:17:14 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yFmlt2LXTzDrJc for ; Mon, 16 Oct 2017 16:17:14 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=ozlabs.ru (client-ip=107.173.13.209; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Received: from ozlabs.ru (ozlabs.ru [107.173.13.209]) by lists.ozlabs.org (Postfix) with ESMTP id 3yFmln6n5gzDrFw for ; Mon, 16 Oct 2017 16:17:09 +1100 (AEDT) Received: from vpl1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id D2CB63A600FC; Mon, 16 Oct 2017 01:15:56 -0400 (EDT) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Mon, 16 Oct 2017 16:16:53 +1100 Message-Id: <20171016051653.31014-7-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171016051653.31014-1-aik@ozlabs.ru> References: <20171016051653.31014-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof v5 6/6] RFC: fdt: Implement "fdt-fetch" method for client interface X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.24 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" The guest kernel fetches the device tree via the client interface, calling it for every node and property, and traversing the entire tree twice - first to build strings blob, second - to build struct blob. On top of that there is also not so efficient implementation of the "getprop" method - it calls slow "get-property" which does full search for a property. As the result, on a 256 CPU + 256 Intel E1000 virtual devices, the guest's flatten_device_tree() takes roughly 8.5sec. However now we have a FDT rendering helper in SLOF which takes about 350ms to render the FDT. This implements a client interface call to allow the guest to read it during early boot and save time. The produced DTB is almost the same as the guest kernel would have produced itself - the differences are: 1. SLOF creates an empty reserved map; the guest can easily fix it up later; 2. SLOF only reuses 40 most popular strings; the guest reuses everything it can - on a 256CPU + 256 PCI devices guest, the difference is about 20KB for 350KB FDT blob. Note, that the guest also ditches the "name" property just like SLOF does: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/kernel/prom_init.c?h=v4.13#n2302 Signed-off-by: Alexey Kardashevskiy --- If the guest tries "fdt-fetch" and SLOF does not have it, than SLOF prints an error: === copying OF device tree... fdt-fetch NOT FOUNDBuilding dt strings... Building dt structure... === and the guest continues with the old method. We could suppress SLOF error for such unlikely situation though. --- slof/fs/client.fs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/slof/fs/client.fs b/slof/fs/client.fs index 7d537a6..8a7f6ac 100644 --- a/slof/fs/client.fs +++ b/slof/fs/client.fs @@ -308,4 +308,20 @@ ALSO client-voc DEFINITIONS : set-callback ( newfunc -- oldfunc ) client-callback @ swap client-callback ! ; +\ Custom method to get FDT blob +: fdt-fetch ( buf len -- ret ) + fdt-flatten-tree ( buf len dtb ) + dup >r + >fdth_tsize l@ ( buf len size r: dtb ) + 2dup < IF + ." ERROR: need " .d ." bytes, the buffer is " .d ." bytes only" cr + drop + -1 + ELSE + nip r@ -rot move + 0 + THEN + r> fdt-flatten-tree-free +; + PREVIOUS DEFINITIONS