Skip to contentSkip to conversation

u-boot 2011.10rc: add patch to speed up ext2load

RFC PATCH In review Koen Kooi 2 participants 4 messages Mar 31, 2012 – Apr 1, 2012

lore
Share & tools
lore

Koen Kooi

author
#0 lore raw

RFC PATCH 1/1 u-boot 2011.10rc: add patch to speed up ext2load

---

Please test this patch on your am335x boards, I need to run out and buy a mini usb cable because I misplaced mine during traveling this week.

Untested, but I wanted to get it out before the weekend.

 .../0011-ext2load-increase-read-speed.patch        |   74 ++++++++++++++++++++
 recipes-bsp/u-boot/u-boot_2011.10rc.bb             |    3 +-
 2 files changed, 76 insertions(+), 1 deletions(-)
 create mode 100644 recipes-bsp/u-boot/u-boot/2011.09git/0011-ext2load-increase-read-speed.patch
recipes-bsp/u-boot/u-boot/2011.09git/0011-ext2load-increase-read-speed.patch new file +74 -0
new file mode 100644
index 0000000..7d4ce87
@@ -0,0 +1,74 @@
+From 5d6d85e090e6ff57972e7cc9d38fa0c62be08031 Mon Sep 17 00:00:00 2001
+From: [email protected] <[email protected]>
+Date: Wed, 28 Mar 2012 04:37:11 +0000
+Subject: [PATCH 11/11] ext2load: increase read speed
+
+This patch dramatically drops the amount of time u-boot needs to read a
+file from an ext2 partition.  On a typical 2 to 5 MB file (kernels and
+initrds) it goes from tens of seconds to a couple seconds.
+
+All we are doing here is grouping contiguous blocks into one read.
+
+Boot tested on Globalscale Technologies Dreamplug (Kirkwood ARM SoC)
+with three different files.  sha1sums were calculated in Linux
+userspace, and then confirmed after ext2load.
+
+Signed-off-by: Jason Cooper <[email protected]>
+---
+ fs/ext2/ext2fs.c |   26 ++++++++++++++++++++++++--
+ 1 files changed, 24 insertions(+), 2 deletions(-)
+
+diff --git a/fs/ext2/ext2fs.c b/fs/ext2/ext2fs.c
+index e119e13..8531db5 100644
+--- a/fs/ext2/ext2fs.c
++++ b/fs/ext2/ext2fs.c
+@@ -414,7 +414,6 @@ int ext2fs_read_file
+ 		if (blknr < 0) {
+ 			return (-1);
+ 		}
+-		blknr = blknr << log2blocksize;
+ 
+ 		/* Last block.  */
+ 		if (i == blockcnt - 1) {
+@@ -432,6 +431,29 @@ int ext2fs_read_file
+ 			blockend -= skipfirst;
+ 		}
+ 
++		/* grab middle blocks in one go */
++		if (i != pos / blocksize && i != blockcnt - 1 && blockcnt > 3) {
++			int oldblk = blknr;
++			int blocknxt;
++			while (i < blockcnt - 1) {
++				blocknxt = ext2fs_read_block(node, i + 1);
++				if (blocknxt == (oldblk + 1)) {
++					oldblk = blocknxt;
++					i++;
++				} else {
++					blocknxt = ext2fs_read_block(node, i);
++					break;
++				}
++			}
++
++			if (oldblk == blknr)
++				blockend = blocksize;
++			else
++				blockend = (1 + blocknxt - blknr) * blocksize;
++		}
++
++		blknr = blknr << log2blocksize;
++
+ 		/* If the block number is 0 this block is not stored on disk but
+ 		   is zero filled instead.  */
+ 		if (blknr) {
+@@ -444,7 +466,7 @@ int ext2fs_read_file
+ 		} else {
+ 			memset (buf, 0, blocksize - skipfirst);
+ 		}
+-		buf += blocksize - skipfirst;
++		buf += blockend - skipfirst;
+ 	}
+ 	return (len);
+ }
+-- 
+1.7.2.5
+
recipes-bsp/u-boot/u-boot_2011.10rc.bb +2 -1
index 0102d15..8f2c137 100644
@@ -6,7 +6,7 @@ COMPATIBLE_MACHINE = "(ti33x)"
 DEFAULT_PREFERENCE_ti33x = "99"
 
 PV = "2011.09+git"
-PR = "r26"
+PR = "r27"
 
 # SPL build
 UBOOT_BINARY = "u-boot.img"
@@ -24,6 +24,7 @@ SRC_URI = "git://arago-project.org/git/projects/u-boot-am33x.git;protocol=git;br
            file://2011.09git/0008-HACK-am335x-evm-turn-d-cache-on-globally-turn-it-off.patch \
            file://2011.09git/0009-am335x-evm-enable-i2c2-pinmux-for-beaglebone.patch \
            file://2011.09git/0001-ddr_defs-change-DDR-timings-for-15x15-EVM.patch \
+           file://2011.09git/0011-ext2load-increase-read-speed.patch \
           "
 
 SRCREV = "f63b270e47f62f4d1a05b2001357e215966c6f5a"
Signature · 1 line
1.7.2.5
author
#1 lore raw

Op 30 mrt. 2012, om 19:04 heeft Koen Kooi het volgende geschreven:

Quoted 4 lines

---

Please test this patch on your am335x boards, I need to run out and buy a mini usb cable because I misplaced mine during traveling this week.

With the following in uEnv.txt:

uenvcmd=mmc rescan ; setenv mmc_dev 0:1 ; echo starting fatload ; run mmc_load_uimage ; setenv mmc_dev mmc 0:2; echo starting ext2load ; run mmc_load_uimage_ext2

First run:

0.40	   0	Running uenvcmd ...
0.46	   6	starting fatload
0.48	   1	reading uImage
0.70	  22	
0.70	   0	3140296 bytes read
0.70	   0	starting ext2load
0.72	   1	Loading file "/boot/uImage" from mmc device 0:2 (xxa2)
0.78	   6	3140296 bytes read

Second run:

0.85	   0	Running uenvcmd ...
0.91	   6	starting fatload
0.91	   0	reading uImage
1.15	  23	
1.15	   0	3140296 bytes read
1.15	   0	starting ext2load
1.15	   0	Loading file "/boot/uImage" from mmc device 0:2 (xxa2)
1.21	   6	3140296 bytes read

Strangely enough ext2load seems to be faster now. More testing needed :)

regards,

Koen

author
#2 lore raw
In reply to Koen Kooi

Op 30 mrt. 2012, om 19:04 heeft Koen Kooi het volgende geschreven:

Quoted 6 lines

---

Please test this patch on your am335x boards, I need to run out and buy a mini usb cable because I misplaced mine during traveling this week.

Untested, but I wanted to get it out before the weekend.

Something funny is going on:

U-Boot# mw 0x80007fc0 ffffffff 9999
U-Boot# md 0x80007fc0

80007fc0: ffffffff ffffffff ffffffff ffffffff    ................
80007fd0: ffffffff ffffffff ffffffff ffffffff    ................
80007fe0: ffffffff ffffffff ffffffff ffffffff    ................
80007ff0: ffffffff ffffffff ffffffff ffffffff    ................
80008000: ffffffff ffffffff ffffffff ffffffff    ................
80008010: ffffffff ffffffff ffffffff ffffffff    ................
80008020: ffffffff ffffffff ffffffff ffffffff    ................
80008030: ffffffff ffffffff ffffffff ffffffff    ................
80008040: ffffffff ffffffff ffffffff ffffffff    ................
80008050: ffffffff ffffffff ffffffff ffffffff    ................
80008060: ffffffff ffffffff ffffffff ffffffff    ................
80008070: ffffffff ffffffff ffffffff ffffffff    ................
80008080: ffffffff ffffffff ffffffff ffffffff    ................
80008090: ffffffff ffffffff ffffffff ffffffff    ................
800080a0: ffffffff ffffffff ffffffff ffffffff    ................
800080b0: ffffffff ffffffff ffffffff ffffffff    ................

U-Boot# ext2ls mmc 0:2 /boot
<DIR> 1024 .
<DIR> 1024 ..

         3135840 uImage-3.2.0+
<SYM>         14 uImage
              33 uEnv.txt
         3140088 uImage-3.2.9+
         3140296 uImage-3.2.11+

U-Boot#

U-Boot# run mmc_load_uimage_ext2
Loading file "/boot/uImage" from mmc device 0:2 (xxa2) 3140296 bytes read

U-Boot# md 0x80007fc0

80007fc0: 00000000 00000400 00000000 00000000    ................
80007fd0: 00000000 00000000 00000000 00000000    ................
80007fe0: 00000000 00000000 00000000 00000000    ................
80007ff0: 00000000 00000000 00000000 00000000    ................
80008000: 00000000 00000000 00000000 00000000    ................
80008010: 00000000 00000000 00000000 00000000    ................
80008020: 00000000 00000000 00000000 00000000    ................
80008030: 00000000 00000000 00000000 00000000    ................
80008040: 00000000 00000000 00000000 00000000    ................
80008050: 00000000 00000000 00000000 00000000    ................
80008060: 00000000 00000000 00000000 00000000    ................
80008070: 00000000 00000000 00000000 00000000    ................
80008080: 00000000 00000000 00000000 00000000    ................
80008090: 00000000 00000000 00000000 00000000    ................
800080a0: 00000000 00000000 00000000 00000000    ................
800080b0: 00000000 00000000 00000000 00000000    ................

U-Boot#

So it only loads zeroes into RAM :(

regards,

Koen

#3 lore raw

Op 1 apr. 2012, om 14:36 heeft Koen Kooi het volgende geschreven:

Quoted 62 lines

Op 30 mrt. 2012, om 19:04 heeft Koen Kooi het volgende geschreven:

Quoted 6 lines

---

Please test this patch on your am335x boards, I need to run out and buy a mini usb cable because I misplaced mine during traveling this week.

Untested, but I wanted to get it out before the weekend.

Something funny is going on:

U-Boot# mw 0x80007fc0 ffffffff 9999
U-Boot# md 0x80007fc0

80007fc0: ffffffff ffffffff ffffffff ffffffff    ................
80007fd0: ffffffff ffffffff ffffffff ffffffff    ................
80007fe0: ffffffff ffffffff ffffffff ffffffff    ................
80007ff0: ffffffff ffffffff ffffffff ffffffff    ................
80008000: ffffffff ffffffff ffffffff ffffffff    ................
80008010: ffffffff ffffffff ffffffff ffffffff    ................
80008020: ffffffff ffffffff ffffffff ffffffff    ................
80008030: ffffffff ffffffff ffffffff ffffffff    ................
80008040: ffffffff ffffffff ffffffff ffffffff    ................
80008050: ffffffff ffffffff ffffffff ffffffff    ................
80008060: ffffffff ffffffff ffffffff ffffffff    ................
80008070: ffffffff ffffffff ffffffff ffffffff    ................
80008080: ffffffff ffffffff ffffffff ffffffff    ................
80008090: ffffffff ffffffff ffffffff ffffffff    ................
800080a0: ffffffff ffffffff ffffffff ffffffff    ................
800080b0: ffffffff ffffffff ffffffff ffffffff    ................

U-Boot# ext2ls mmc 0:2 /boot
<DIR> 1024 .
<DIR> 1024 ..

        3135840 uImage-3.2.0+
<SYM>         14 uImage
             33 uEnv.txt
        3140088 uImage-3.2.9+
        3140296 uImage-3.2.11+

U-Boot#

U-Boot# run mmc_load_uimage_ext2
Loading file "/boot/uImage" from mmc device 0:2 (xxa2) 3140296 bytes read

U-Boot# md 0x80007fc0

80007fc0: 00000000 00000400 00000000 00000000    ................
80007fd0: 00000000 00000000 00000000 00000000    ................
80007fe0: 00000000 00000000 00000000 00000000    ................
80007ff0: 00000000 00000000 00000000 00000000    ................
80008000: 00000000 00000000 00000000 00000000    ................
80008010: 00000000 00000000 00000000 00000000    ................
80008020: 00000000 00000000 00000000 00000000    ................
80008030: 00000000 00000000 00000000 00000000    ................
80008040: 00000000 00000000 00000000 00000000    ................
80008050: 00000000 00000000 00000000 00000000    ................
80008060: 00000000 00000000 00000000 00000000    ................
80008070: 00000000 00000000 00000000 00000000    ................
80008080: 00000000 00000000 00000000 00000000    ................
80008090: 00000000 00000000 00000000 00000000    ................
800080a0: 00000000 00000000 00000000 00000000    ................
800080b0: 00000000 00000000 00000000 00000000    ................
Quoted 3 lines

U-Boot#

So it only loads zeroes into RAM :(

It does that with or without the speedup patch, so something else is going on.

regards,

Koen