Home | History | Annotate | Download | only in ext4
      1 #!/bin/bash
      2 
      3 PERF="rand_emmc_perf"
      4 
      5 if [ ! -r "$PERF" ]
      6 then
      7   echo "Cannot read $PERF test binary"
      8 fi
      9 
     10 if ! adb shell true >/dev/null 2>&1
     11 then
     12   echo "No device detected over adb"
     13 fi
     14 
     15 HARDWARE=`adb shell getprop ro.hardware | tr -d "\r"`
     16 
     17 case "$HARDWARE" in
     18   tuna | steelhead)
     19     CPUFREQ="/sys/devices/system/cpu/cpu0/cpufreq"
     20     CACHE="/dev/block/platform/omap/omap_hsmmc.0/by-name/cache"
     21     MMCDEV="mmcblk0"
     22     ;;
     23 
     24   stingray | wingray)
     25     CPUFREQ="/sys/devices/system/cpu/cpu0/cpufreq"
     26     CACHE="/dev/block/platform/sdhci-tegra.3/by-name/cache"
     27     MMCDEV="mmcblk0"
     28     ;;
     29 
     30   herring)
     31     echo "This test will wipe the userdata partition on $HARDWARE devices."
     32     read -p "Do you want to proceed? " ANSWER
     33 
     34     if [ "$ANSWER" != "yes" ]
     35     then
     36       echo "aborting test"
     37       exit 1
     38     fi
     39 
     40     CPUFREQ="/sys/devices/system/cpu/cpu0/cpufreq"
     41     CACHE="/dev/block/platform/s3c-sdhci.0/by-name/userdata"
     42     MMCDEV="mmcblk0"
     43     ;;
     44 
     45   grouper)
     46     CPUFREQ="/sys/devices/system/cpu/cpu0/cpufreq"
     47     CACHE="/dev/block/platform/sdhci-tegra.3/by-name/CAC"
     48     MMCDEV="mmcblk0"
     49     ;;
     50 
     51   manta)
     52     CPUFREQ="/sys/devices/system/cpu/cpu0/cpufreq"
     53     CACHE="/dev/block/platform/dw_mmc.0/by-name/cache"
     54     MMCDEV="mmcblk0"
     55     ;;
     56 
     57   *)
     58     echo "Unknown hardware $HARDWARE.  Exiting."
     59     exit 1
     60 esac
     61 
     62 # prepare the device
     63 adb root
     64 adb wait-for-device
     65 adb push "$PERF" /dev
     66 adb shell stop
     67 adb shell stop sdcard
     68 adb shell stop ril-daemon
     69 adb shell stop media
     70 adb shell stop drm
     71 adb shell stop keystore
     72 adb shell stop tf_daemon
     73 adb shell stop bluetoothd
     74 adb shell stop hciattach
     75 adb shell stop p2p_supplicant
     76 adb shell stop wpa_supplicant
     77 adb shell stop mobicore
     78 adb shell umount /sdcard >/dev/null 2>&1
     79 adb shell umount /mnt/shell/sdcard0 >/dev/null 2>&1
     80 adb shell umount /data >/dev/null 2>&1
     81 adb shell umount /cache >/dev/null 2>&1
     82 # Add more services here that other devices need to stop.
     83 # So far, this list is sufficient for:
     84 #   Prime
     85 
     86 # At this point, the device is quiescent, need to crank up the cpu speed,
     87 # then run tests
     88 adb shell "cat $CPUFREQ/cpuinfo_max_freq > $CPUFREQ/scaling_max_freq"
     89 adb shell "cat $CPUFREQ/cpuinfo_max_freq > $CPUFREQ/scaling_min_freq"
     90 
     91 # Start the tests
     92 
     93 # Sequential read test
     94 for I in 1 2 3
     95 do
     96   adb shell "echo 3 > /proc/sys/vm/drop_caches"
     97   echo "Sequential read test $I"
     98   adb shell dd if="$CACHE" of=/dev/null bs=1048576 count=200
     99 done
    100 
    101 # Sequential write test
    102 for I in 1 2 3
    103 do
    104   echo "Sequential write test $I"
    105   adb shell dd if=/dev/zero of="$CACHE" bs=1048576 count=200
    106 done
    107 
    108 # Random read tests require that we read from a much larger range of offsets
    109 # into the emmc chip than the write test.  If we only read though 100 Megabytes
    110 # (and with a read-ahead of 128K), we quickly fill the buffer cache with 100
    111 # Megabytes of data, and subsequent reads are nearly instantaneous.  Since
    112 # reading is non-destructive, and we've never shipped a device with less than
    113 # 8 Gbytes, for this test we read from the raw emmc device, and randomly seek
    114 # in the first 6 Gbytes.  That is way more memory than any device we currently
    115 # have and it should keep the cache from being poluted with entries from
    116 # previous random reads.
    117 #
    118 # Also, test with the read-ahead set very low at 4K, and at the default
    119 
    120 # Random read test, 4K read-ahead
    121 ORIG_READAHEAD=`adb shell cat /sys/block/$MMCDEV/queue/read_ahead_kb | tr -d "\r"`
    122 adb shell "echo 4 > /sys/block/$MMCDEV/queue/read_ahead_kb"
    123 for I in 1 2 3
    124 do
    125   adb shell "echo 3 > /proc/sys/vm/drop_caches"
    126   echo "Random read (4K read-ahead) test $I"
    127   adb shell /dev/"$PERF" -r 6000 "/dev/block/$MMCDEV"
    128 done
    129 
    130 # Random read test, default read-ahead
    131 adb shell "echo $ORIG_READAHEAD > /sys/block/$MMCDEV/queue/read_ahead_kb"
    132 for I in 1 2 3
    133 do
    134   adb shell "echo 3 > /proc/sys/vm/drop_caches"
    135   echo "Random read (default read-ahead of ${ORIG_READAHEAD}K) test $I"
    136   adb shell /dev/"$PERF" -r 6000 "/dev/block/$MMCDEV"
    137 done
    138 
    139 # Random write test
    140 for I in 1 2 3
    141 do
    142   echo "Random write test $I"
    143   adb shell /dev/"$PERF" -w 100 "$CACHE"
    144 done
    145 
    146 # Random write test with O_SYNC
    147 for I in 1 2 3
    148 do
    149   echo "Random write with o_sync test $I"
    150   adb shell /dev/"$PERF" -w -o 100 "$CACHE"
    151 done
    152 
    153 # Make a new empty /cache filesystem
    154 adb shell make_ext4fs "$CACHE"
    155 
    156