From patchwork Thu Apr 19 20:08:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 901483 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (helo) smtp.helo=arrakis.dune.hu (client-ip=78.24.191.176; helo=arrakis.dune.hu; envelope-from=openwrt-devel-bounces@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mork.no Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=mork.no header.i=@mork.no header.b="fQpgbmSf"; dkim-atps=neutral Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40Rqnk3wzhz9s1t for ; Fri, 20 Apr 2018 06:09:12 +1000 (AEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 0A9CBB803C7; Thu, 19 Apr 2018 22:09:07 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Thu, 19 Apr 2018 22:09:07 +0200 (CEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 216A1B80324 for ; Thu, 19 Apr 2018 22:09:06 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -6.1 Received: from canardo.mork.no (canardo.mork.no [148.122.252.1]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Thu, 19 Apr 2018 22:09:05 +0200 (CEST) Received: from canardo.mork.no (ip6-localhost [IPv6:0:0:0:0:0:0:0:1]) by canardo.mork.no (8.15.2/8.15.2) with ESMTPS id w3JK8hBP005297 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Apr 2018 22:08:43 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mork.no; s=b; t=1524168523; bh=h9uPMNDxmzs884OrDtfOy0j7YJcIDPikGluTxZHh73A=; h=From:To:Cc:Subject:Date:Message-Id:From; b=fQpgbmSfv+MIl8+8n6kLLaiKo8SGAT28bYrvY5y19ksQ//Pcf+u8gop+C4OLsGh6H +7ALVo4cV8L63GsNXpIcqPp+9PvHLUxMgXS6fm9gprd8K/UjW6iz7pvKrvpiavlxCX Bg4orMsNeJDY+PFfMCz+eCeVNKtAta9D3TtIOofM= Received: (from bjorn@localhost) by canardo.mork.no (8.15.2/8.15.2/Submit) id w3JK8fZq005296; Thu, 19 Apr 2018 22:08:41 +0200 From: =?utf-8?q?Bj=C3=B8rn_Mork?= To: lede-dev@lists.infradead.org, openwrt-devel@lists.openwrt.org Date: Thu, 19 Apr 2018 22:08:25 +0200 Message-Id: <20180419200825.5237-1-bjorn@mork.no> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.3 at canardo X-Virus-Status: Clean Subject: [OpenWrt-Devel] [PATCH] kernel: speed up mtdsplit_uimage for the most common use X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" The driver scans the complete partition for every one of the three header formats it supports. So every non-matching format adds a considerable delay. It therefore makes sense to order the scanning by (assumed) popularity: 1) uimage 2) netgear 3) edimax This is achieved by registering in the reverse order. Typical example of speedup - before: [ 1.340391] 8 fixed-partitions partitions found on MTD device MT7621-NAND [ 1.353897] Creating 8 MTD partitions on "MT7621-NAND": [ 1.364307] 0x000000000000-0x000000100000 : "Bootloader" [ 1.376046] 0x000000100000-0x000000200000 : "MRD" [ 1.386515] 0x000000200000-0x000000300000 : "Factory" [ 1.397648] 0x000000300000-0x000000400000 : "Config" [ 1.408588] 0x000000400000-0x000004400000 : "firmware" [ 2.314262] 2 uimage-fw partitions found on MTD device firmware [ 2.326072] 0x000000400000-0x0000005e0000 : "kernel" [ 2.337227] 0x0000005e0000-0x000004400000 : "ubi" [ 2.348162] 0x000004400000-0x000004500000 : "Private" [ 2.359309] 0x000004500000-0x000005500000 : "Log" [ 2.369891] 0x000005500000-0x000008000000 : "App" [ 2.380691] [mtk_nand] probe successfully! after: [ 1.339471] 8 fixed-partitions partitions found on MTD device MT7621-NAND [ 1.352981] Creating 8 MTD partitions on "MT7621-NAND": [ 1.363387] 0x000000000000-0x000000100000 : "Bootloader" [ 1.375150] 0x000000100000-0x000000200000 : "MRD" [ 1.385603] 0x000000200000-0x000000300000 : "Factory" [ 1.396744] 0x000000300000-0x000000400000 : "Config" [ 1.407705] 0x000000400000-0x000004400000 : "firmware" [ 1.716393] 2 uimage-fw partitions found on MTD device firmware [ 1.728233] 0x000000400000-0x0000005e0000 : "kernel" [ 1.739291] 0x0000005e0000-0x000004400000 : "ubi" [ 1.750251] 0x000004400000-0x000004500000 : "Private" [ 1.761403] 0x000004500000-0x000005500000 : "Log" [ 1.771983] 0x000005500000-0x000008000000 : "App" [ 1.782811] [mtk_nand] probe successfully! The time spent in mtdsplit was reduced from .9 to .3 seconds! Signed-off-by: Bjørn Mork --- Stumbled across this while fiddling with a new device. There is still much room for improvements here, but this simple reordering seems like a quick fix. At least for uimage devices... For further improments: - Do we have to scan the whole partition? - Can we run a list of header matching functions against the block we want to test instead of having to read through every block before continuing to the next matching function? Bjørn target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c index bd1c723e7499..4194c547cc2e 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c @@ -351,9 +351,9 @@ static struct mtd_part_parser uimage_edimax_parser = { static int __init mtdsplit_uimage_init(void) { - register_mtd_parser(&uimage_generic_parser); - register_mtd_parser(&uimage_netgear_parser); register_mtd_parser(&uimage_edimax_parser); + register_mtd_parser(&uimage_netgear_parser); + register_mtd_parser(&uimage_generic_parser); return 0; }