From 554adccf11f2ba2947ed221307ddd703c0889967 Mon Sep 17 00:00:00 2001 From: Leonardo Graboski Veiga Date: Thu, 23 Mar 2017 14:44:19 +0100 Subject: apalis/colibri-imx6/t30/tk1: read ahead cache configuration Configure the read_ahead cache size to optimal value, for the mmcblk devices (eMMC and SD card). The cache values are module specific, tests were run on the pre-built image (BSP V2.7 Beta 1). The measurement of read speed for a range of cache sizes (16kB to 256MB) was made using hdparm -t. Signed-off-by: Leonardo Graboski Veiga Acked-by: Marcel Ziswiler --- recipes-core/udev/files/hotplug.rules | 2 ++ recipes-core/udev/files/hotplug.sh | 48 +++++++++++++++++++++++++++++ recipes-core/udev/udev-extraconf_%.bbappend | 12 ++++++++ 3 files changed, 62 insertions(+) create mode 100644 recipes-core/udev/files/hotplug.rules create mode 100644 recipes-core/udev/files/hotplug.sh diff --git a/recipes-core/udev/files/hotplug.rules b/recipes-core/udev/files/hotplug.rules new file mode 100644 index 0000000..a36a47d --- /dev/null +++ b/recipes-core/udev/files/hotplug.rules @@ -0,0 +1,2 @@ +# SD card hotplug configuration of read_ahead cache size +KERNEL=="mmcblk?", ACTION=="add" RUN+="/etc/udev/scripts/hotplug.sh" diff --git a/recipes-core/udev/files/hotplug.sh b/recipes-core/udev/files/hotplug.sh new file mode 100644 index 0000000..b34c2a3 --- /dev/null +++ b/recipes-core/udev/files/hotplug.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# +# Called from udev +# +# Set the read_ahead cache size of SD card on hotplug + +SYSNAME=$(uname -n) +DISKNUM=$(echo $DEVNAME | sed -e 's/\(^.*\)\(.$\)/\2/') +DISKNAME=$(echo $DEVNAME | sed 's/.*\///g;s/p.*//g') +CORES=$(cat /proc/cpuinfo | grep processor | wc -l) + +set_read_ahead_size () { + if [ $DISKNUM == "0" ]; then #eMMC + echo $1 > /sys/block/$DISKNAME/queue/read_ahead_kb + else #SD card + echo $2 > /sys/block/$DISKNAME/queue/read_ahead_kb + fi +} + +if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && [ "$DEVTYPE" = "disk" ]; then + #Set read_ahead cache of mmcblk? SD card + if test -e /sys/block/$DISKNAME/queue/read_ahead_kb + then + if [ $SYSNAME == "colibri-imx6" ]; then + if [ $CORES -eq 1 ]; then #imx6s + set_read_ahead_size 512 512 + else #imx6dl + set_read_ahead_size 1024 512 + fi + elif [ $SYSNAME == "colibri-t30" ]; then + set_read_ahead_size 2048 1024 + elif [ $SYSNAME == "apalis-imx6" ]; then + if [ $CORES -eq 2 ]; then #imx6d + set_read_ahead_size 1024 512 + else #imx6q + set_read_ahead_size 1024 512 + fi + elif [ $SYSNAME == "apalis-t30" ]; then + set_read_ahead_size 4096 1024 + elif [ $SYSNAME == "apalis-tk1" ]; then + set_read_ahead_size 4096 1024 + else + logger "sd_hotplug.sh" "System name not compatible" + fi + else + logger "sd_hotplug" "No read_ahead_kb configuration file found" + fi +fi diff --git a/recipes-core/udev/udev-extraconf_%.bbappend b/recipes-core/udev/udev-extraconf_%.bbappend index e9cf79a..7b03d77 100644 --- a/recipes-core/udev/udev-extraconf_%.bbappend +++ b/recipes-core/udev/udev-extraconf_%.bbappend @@ -1 +1,13 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/files/:" + +SRC_URI_append = " file://hotplug.rules \ + file://hotplug.sh \ +" + +do_install_append() { + install -d ${D}${sysconfdir}/udev/rules.d + install -m 0644 ${WORKDIR}/hotplug.rules ${D}${sysconfdir}/udev/rules.d/hotplug.rules + + install -d ${D}${sysconfdir}/udev/scripts/ + install -m 0755 ${WORKDIR}/hotplug.sh ${D}${sysconfdir}/udev/scripts/hotplug.sh +} -- cgit v1.2.3