[LEDE-DEV] [PATCH] kernel: speed up mtdsplit_uimage for the most common use

Bjørn Mork bjorn at mork.no
Thu Apr 19 13:08:25 PDT 2018


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 <bjorn at mork.no>
---

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;
 }
-- 
2.11.0




More information about the Lede-dev mailing list