前言
前面进行了RAM性能和压力测试,EMMC存储也是影响综合性能的关键因素,因为嵌入式系统需要频繁进行文件操作,文件系统是在EMMC存储上的。这一篇就进行emmc性能测试。
手册中使用的time 与 dd 双命令进行测试,我们就换个方式使用fio测试。
开发板带了8GB的eMMC,可以查看信息如下
速率为HS400
某一个EMMC手册给出的典型速率值为
root@myd-jx8mma7:~# dmesg | grep mmc
[ 0.000000] Kernel command line: console=ttymxc1,115200 root=/dev/mmcblk2p2 rootwait rw
[ 1.791557] sdhci-esdhc-imx 30b40000.mmc: voltage-ranges unspecified
[ 1.791707] sdhci-esdhc-imx 30b50000.mmc: voltage-ranges unspecified
[ 1.798918] sdhci-esdhc-imx 30b60000.mmc: voltage-ranges unspecified
[ 1.829574] mmc0: SDHCI controller on 30b40000.mmc [30b40000.mmc] using ADMA
[ 1.852841] mmc2: SDHCI controller on 30b60000.mmc [30b60000.mmc] using ADMA
[ 1.943370] mmc2: new HS400 Enhanced strobe MMC card at address 0001
[ 1.951094] mmcblk2: mmc2:0001 8GTF4R 7.28 GiB
[ 1.955890] mmcblk2boot0: mmc2:0001 8GTF4R partition 1 4.00 MiB
[ 1.962122] mmcblk2boot1: mmc2:0001 8GTF4R partition 2 4.00 MiB
[ 1.968244] mmcblk2rpmb: mmc2:0001 8GTF4R partition 3 512 KiB, chardev (509:0)
[ 1.984610] mmcblk2: p1 p2
[ 4.143623] sdhci-esdhc-imx 30b50000.mmc: voltage-ranges unspecified
[ 4.150048] sdhci-esdhc-imx 30b50000.mmc: Got CD GPIO
[ 4.194111] mmc1: SDHCI controller on 30b50000.mmc [30b50000.mmc] using ADMA
[ 4.309074] EXT4-fs (mmcblk2p2): recovery complete
[ 4.314711] EXT4-fs (mmcblk2p2): mounted filesystem with ordered data mode. Opts: (null)
[ 5.843477] EXT4-fs (mmcblk2p2): re-mounted. Opts: (null)
root@myd-jx8mma7:~#
EMMC测试
git clone git://git.kernel.dk/fio.git
cd fio/
export ARCH=aarch64
export CROSS_COMPILE=aarch64-linux-gnu-
make
将可执行文件fio导出到win下
cp fio /mnt/d
导入到开发板,添加可执行权限
chmod + fio
查看分区信息
root@myd-jx8mma7:~# fdisk -l
Disk /dev/mtdblock0: 32 MiB, 33554432 bytes, 65536 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mmcblk2: 7.28 GiB, 7818182656 bytes, 15269888 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa85bd32d
Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 * 16384 186775 170392 83.2M c W95 FAT32 (LBA)
/dev/mmcblk2p2 196608 9725815 9529208 4.5G 83 Linux
root@myd-jx8mma7:~#
/dev/mmcblk2p1 :用来存放 kernel 和 dtb 文件
Ø/dev/mmcblk2p2 :用于存放文件系统
这里/dev/mmcblk2p1 起始在 20480 块开始,前面还保存着 bootloader 和分区表 信息。
查看分区挂载文件系统情况
root@myd-jx8mma7:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 4.4G 2.7G 1.5G 66% /
devtmpfs 647M 4.0K 647M 1% /dev
tmpfs 970M 0 970M 0% /dev/shm
tmpfs 388M 9.1M 379M 3% /run
tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
tmpfs 970M 4.0K 970M 1% /tmp
tmpfs 970M 152K 970M 1% /var/volatile
/dev/mmcblk2p1 84M 39M 45M 46% /run/media/mmcblk2p1
tmpfs 194M 8.0K 194M 1% /run/user/0
root@myd-jx8mma7:~#
/dev/root : 根文件系统,挂载到根目录下。 Ø
tmpfs : 内存虚拟文件系统,挂载到不同的目录下。
Ødevtmpfs :用于系统创建 dev Ø
/dev/mmcblk2p1:用来存放 kernel 和 dtb 文件,默认挂载在 /run/media/mmcblk2p1 目录
新建emmc.ini文件内容如下
[global]
ioengine=psync
direct=1
invalidate=1
iodepth=1
time_based
runtime=60
ramp_time=10
[read-1024k-seq]
stonewall
rw=read
bs=1024k
filename=/home/root/tmpfile
filesize=1024mb
[write-1024k-seq]
stonewall
rw=write
bs=1024k
filename=/home/root/tmpfile
filesize=1024mb
运行测试
fio emmc.ini
打印如下
root@myd-jx8mma7:~# fio emmc.ini
read-1024k-seq: (g=0): rw=read, bs=(R) 1024KiB-1024KiB, (W) 1024KiB-1024KiB, (T) 1024KiB-1024KiB, ioengine=psync, iodepth=1
write-1024k-seq: (g=1): rw=write, bs=(R) 1024KiB-1024KiB, (W) 1024KiB-1024KiB, (T) 1024KiB-1024KiB, ioengine=psync, iodepth=1
fio-3.26
Starting 2 processes
read-1024k-seq: Laying out IO file (1 file / 1024MiB)
Jobs: 1 (f=1): [_(1),W(1)][100.0%][w=55.0MiB/s][w=55 IOPS][eta 00m:00s]
read-1024k-seq: (groupid=0, jobs=1): err= 0: pid=866: Fri Jan 1 03:03:03 2066
read: IOPS=275, BW=275MiB/s (289MB/s)(16.1GiB/60003msec)
clat (usec): min=3189, max=9462, avg=3625.88, stdev=355.59
lat (usec): min=3190, max=9463, avg=3626.39, stdev=355.61
clat percentiles (usec):
| 1.00th=[ 3261], 5.00th=[ 3261], 10.00th=[ 3261], 20.00th=[ 3294],
| 30.00th=[ 3326], 40.00th=[ 3556], 50.00th=[ 3589], 60.00th=[ 3720],
| 70.00th=[ 3884], 80.00th=[ 3884], 90.00th=[ 3916], 95.00th=[ 3982],
| 99.00th=[ 4555], 99.50th=[ 4621], 99.90th=[ 7701], 99.95th=[ 8848],
| 99.99th=[ 9372]
bw ( KiB/s): min=272384, max=305763, per=100.00%, avg=282201.97, stdev=7537.69, samples=119
iops : min= 266, max= 298, avg=275.31, stdev= 7.35, samples=119
lat (msec) : 4=95.22%, 10=4.78%
cpu : usr=0.27%, sys=3.73%, ctx=49639, majf=0, minf=60
IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued rwts: total=16520,0,0,0 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=1
write-1024k-seq: (groupid=1, jobs=1): err= 0: pid=872: Fri Jan 1 03:03:03 2066
write: IOPS=54, BW=54.3MiB/s (57.0MB/s)(3261MiB/60019msec); 0 zone resets
clat (usec): min=16198, max=28688, avg=18251.91, stdev=1396.11
lat (usec): min=16337, max=28827, avg=18388.15, stdev=1396.01
clat percentiles (usec):
| 1.00th=[16909], 5.00th=[17433], 10.00th=[17433], 20.00th=[17695],
| 30.00th=[17695], 40.00th=[17957], 50.00th=[17957], 60.00th=[18220],
| 70.00th=[18220], 80.00th=[18220], 90.00th=[18482], 95.00th=[19530],
| 99.00th=[25035], 99.50th=[26084], 99.90th=[27919], 99.95th=[28181],
| 99.99th=[28705]
bw ( KiB/s): min=53354, max=57458, per=100.00%, avg=55706.32, stdev=961.32, samples=120
iops : min= 52, max= 56, avg=54.33, stdev= 0.95, samples=120
lat (msec) : 20=95.25%, 50=4.75%
cpu : usr=0.97%, sys=0.99%, ctx=9774, majf=0, minf=61
IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued rwts: total=0,3261,0,0 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=1
Run status group 0 (all jobs):
READ: bw=275MiB/s (289MB/s), 275MiB/s-275MiB/s (289MB/s-289MB/s), io=16.1GiB (17.3GB), run=60003-60003msec
Run status group 1 (all jobs):
WRITE: bw=54.3MiB/s (57.0MB/s), 54.3MiB/s-54.3MiB/s (57.0MB/s-57.0MB/s), io=3261MiB (3419MB), run=60019-60019msec
Disk stats (read/write):
mmcblk2: ios=38566/7638, merge=0/14, ticks=102947/103810, in_queue=206902, util=99.92%
root@myd-jx8mma7:~#
读速率
275MiB/s
写速率
bw=54.3MiB/s
比手册里测试的数据大一点点,达到了EMMC HS400的接近理想速率。
U盘测试
插入盘查看信息如下
root@myd-jx8mma7:~# fdisk -l
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 1695744 7669823 5974080 2.8G 7 HPFS/NTFS/exFAT
root@myd-jx8mma7:~#
修改emmc测试的emmc.ini的filename为/dev/sda1进行U盘读写测试
注意测试时将USB格式化为fat32,否则linux下不识别ntfs。
mkdir /mnt/usb
mount /dev/sda1 /mnt/usb
usb.ini内容如下
[global]
ioengine=psync
direct=1
invalidate=1
iodepth=1
time_based
runtime=60
ramp_time=10
[read-1024k-seq]
stonewall
rw=read
bs=1024k
filename=/mnt/usb/tmpfile
filesize=100mb
[write-1024k-seq]
stonewall
rw=write
bs=1024k
filename=/mnt/usb/tmpfile
filesize=100mb
运行
fio usb.ini
结果如下
root@myd-jx8mma7:~# fio usb.ini
read-1024k-seq: (g=0): rw=read, bs=(R) 1024KiB-1024KiB, (W) 1024KiB-1024KiB, (T) 1024KiB-1024KiB, ioengine=psync, iodepth=1
write-1024k-seq: (g=1): rw=write, bs=(R) 1024KiB-1024KiB, (W) 1024KiB-1024KiB, (T) 1024KiB-1024KiB, ioengine=psync, iodepth=1
fio-3.26
Starting 2 processes
read-1024k-seq: Laying out IO file (1 file / 100MiB)
Jobs: 1 (f=1): [_(1),W(1)][100.0%][w=4100KiB/s][w=4 IOPS][eta 00m:00s]
read-1024k-seq: (groupid=0, jobs=1): err= 0: pid=656: Fri Jan 1 03:26:07 2066
read: IOPS=16, BW=16.9MiB/s (17.7MB/s)(1012MiB/60028msec)
clat (usec): min=52004, max=70309, avg=59294.91, stdev=4307.79
lat (usec): min=52005, max=70311, avg=59296.51, stdev=4307.84
clat percentiles (usec):
| 1.00th=[52691], 5.00th=[53216], 10.00th=[53216], 20.00th=[54264],
| 30.00th=[57410], 40.00th=[58983], 50.00th=[59507], 60.00th=[60031],
| 70.00th=[60556], 80.00th=[62653], 90.00th=[66323], 95.00th=[66847],
| 99.00th=[67634], 99.50th=[68682], 99.90th=[69731], 99.95th=[70779],
| 99.99th=[70779]
bw ( KiB/s): min=14307, max=20521, per=100.00%, avg=17275.85, stdev=1348.08, samples=119
iops : min= 13, max= 20, avg=16.83, stdev= 1.34, samples=119
lat (msec) : 100=100.00%
cpu : usr=0.18%, sys=1.26%, ctx=15190, majf=0, minf=60
IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued rwts: total=1012,0,0,0 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=1
write-1024k-seq: (groupid=1, jobs=1): err= 0: pid=657: Fri Jan 1 03:26:07 2066
write: IOPS=5, BW=5866KiB/s (6007kB/s)(345MiB/60227msec); 0 zone resets
clat (msec): min=71, max=2358, avg=174.41, stdev=299.30
lat (msec): min=71, max=2358, avg=174.55, stdev=299.30
clat percentiles (msec):
| 1.00th=[ 72], 5.00th=[ 72], 10.00th=[ 72], 20.00th=[ 72],
| 30.00th=[ 73], 40.00th=[ 73], 50.00th=[ 74], 60.00th=[ 75],
| 70.00th=[ 78], 80.00th=[ 89], 90.00th=[ 986], 95.00th=[ 995],
| 99.00th=[ 1003], 99.50th=[ 1150], 99.90th=[ 2366], 99.95th=[ 2366],
| 99.99th=[ 2366]
bw ( KiB/s): min= 2043, max=14364, per=100.00%, avg=8489.27, stdev=4293.58, samples=83
iops : min= 1, max= 14, avg= 8.11, stdev= 4.19, samples=83
lat (msec) : 100=89.28%, 250=0.58%, 1000=8.41%, 2000=1.45%, >=2000=0.29%
cpu : usr=0.20%, sys=0.39%, ctx=5175, majf=0, minf=61
IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued rwts: total=0,345,0,0 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=1
Run status group 0 (all jobs):
READ: bw=16.9MiB/s (17.7MB/s), 16.9MiB/s-16.9MiB/s (17.7MB/s-17.7MB/s), io=1012MiB (1061MB), run=60028-60028msec
Run status group 1 (all jobs):
WRITE: bw=5866KiB/s (6007kB/s), 5866KiB/s-5866KiB/s (6007kB/s-6007kB/s), io=345MiB (362MB), run=60227-60227msec
Disk stats (read/write):
sda: ios=10530/3525, merge=0/0, ticks=133715/132193, in_queue=265908, util=99.39%
root@myd-jx8mma7:~#
读16.9MiB/s
写5866KiB/s
总结
通过以上测试可以看出EMMC性能不错,基本接近了EMMC的理想性能。USB访问U盘,和U盘本身有关,不太好对比,仅作参考。