Message ID | 1332945431-12441-1-git-send-email-u-boot@lakedaemon.net |
---|---|
State | Accepted |
Commit | 436da3cd233e7166b5ce9293dbd28092cf37bcc9 |
Headers | show |
On 03/28/2012 07:37 AM, Jason Cooper wrote: > 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<u-boot@lakedaemon.net> Tested-by: Eric Nelson <eric.nelson@boundarydevices.com> Tested on i.MX6 Sabre Lite board loading a file of ~900k: Without patch: MX6QSABRELITE U-Boot > time ext2load sata 0:1 12000000 /usr/lib/libperl.so.5.12.4 && crc32 12000000 $filesize Loading file "/usr/lib/libperl.so.5.12.4" from sata device 0:1 (hda1) 958032 bytes read time: 0.414 seconds, 414 ticks CRC32 for 12000000 ... 120e9e4f ==> 550deec9 With patch: MX6QSABRELITE U-Boot > time ext2load sata 0:1 12000000 /usr/lib/libperl.so.5.12.4 && crc32 12000000 $filesize Loading file "/usr/lib/libperl.so.5.12.4" from sata device 0:1 (hda1) 958032 bytes read time: 0.205 seconds, 205 ticks CRC32 for 12000000 ... 120e9e4f ==> 550deec9
* Jason Cooper wrote: > 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 <u-boot@lakedaemon.net> Before: Tegra2 (Medcom) # time ext2load mmc 0 0x17000000 /boot/uImage Loading file "/boot/uImage" from mmc device 0:1 (xxa1) 5609104 bytes read time: 4.638 seconds, 4638 ticks Tegra2 (Medcom) # crc32 0x17000000 559690 CRC32 for 17000000 ... 1755968f ==> 158788be After: Tegra2 (Medcom) # time ext2load mmc 0 0x17000000 /boot/uImage Loading file "/boot/uImage" from mmc device 0:1 (xxa1) 5609104 bytes read time: 0.317 seconds, 317 ticks Tegra2 (Medcom) # crc32 0x17000000 559690 CRC32 for 17000000 ... 1755968f ==> 158788be I can also successfully load the loaded uImage to a prompt, so: Tested-by: Thierry Reding <thierry.reding@avionic-design.de>
On Wed, Apr 25, 2012 at 06:17:48PM -0700, Eric Nelson wrote: > On 03/28/2012 07:37 AM, Jason Cooper wrote: > >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<u-boot@lakedaemon.net> > > Tested-by: Eric Nelson <eric.nelson@boundarydevices.com> Thanks for testing! I've copied your results into the commit and will be doing a pull request shortly. thx, Jason. > > Tested on i.MX6 Sabre Lite board loading a file of ~900k: > > Without patch: > > MX6QSABRELITE U-Boot > time ext2load sata 0:1 12000000 > /usr/lib/libperl.so.5.12.4 && crc32 12000000 $filesize > Loading file "/usr/lib/libperl.so.5.12.4" from sata device 0:1 (hda1) > 958032 bytes read > > time: 0.414 seconds, 414 ticks > CRC32 for 12000000 ... 120e9e4f ==> 550deec9 > > With patch: > MX6QSABRELITE U-Boot > time ext2load sata 0:1 12000000 > /usr/lib/libperl.so.5.12.4 && crc32 12000000 $filesize > Loading file "/usr/lib/libperl.so.5.12.4" from sata device 0:1 (hda1) > 958032 bytes read > > time: 0.205 seconds, 205 ticks > CRC32 for 12000000 ... 120e9e4f ==> 550deec9
On Thu, Apr 26, 2012 at 02:54:51PM +0200, Thierry Reding wrote: > * Jason Cooper wrote: > > 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 <u-boot@lakedaemon.net> > > Before: > > Tegra2 (Medcom) # time ext2load mmc 0 0x17000000 /boot/uImage > Loading file "/boot/uImage" from mmc device 0:1 (xxa1) > 5609104 bytes read > > time: 4.638 seconds, 4638 ticks > Tegra2 (Medcom) # crc32 0x17000000 559690 > CRC32 for 17000000 ... 1755968f ==> 158788be > > After: > > Tegra2 (Medcom) # time ext2load mmc 0 0x17000000 /boot/uImage > Loading file "/boot/uImage" from mmc device 0:1 (xxa1) > 5609104 bytes read > > time: 0.317 seconds, 317 ticks > Tegra2 (Medcom) # crc32 0x17000000 559690 > CRC32 for 17000000 ... 1755968f ==> 158788be > > I can also successfully load the loaded uImage to a prompt, so: > > Tested-by: Thierry Reding <thierry.reding@avionic-design.de> Thanks for testing! I've added your results to the commit message and will be doing a pull request shortly. thx, Jason.
Hi Jason, On 05/08/2012 08:43 AM, Jason Cooper wrote: > On Wed, Apr 25, 2012 at 06:17:48PM -0700, Eric Nelson wrote: >> On 03/28/2012 07:37 AM, Jason Cooper wrote: >>> 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<u-boot@lakedaemon.net> >> >> Tested-by: Eric Nelson<eric.nelson@boundarydevices.com> > > Thanks for testing! I've copied your results into the commit and will > be doing a pull request shortly. > No problem. Ironically, I'm working with an image this morning that loads the kernel from ext2 and I keep thinking my board is locked up because reads take so long. Regards, Eric
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); }
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 <u-boot@lakedaemon.net> --- fs/ext2/ext2fs.c | 26 ++++++++++++++++++++++++-- 1 files changed, 24 insertions(+), 2 deletions(-)