aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Tollerton <rich.tollerton@ni.com>2014-12-08 17:13:35 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-12-19 17:54:14 +0000
commite8ea6a29ed3ab9892a3bc7ee8249f10688c0af29 (patch)
treec890649b03de4f96116dc1bfe1a0ca806ba88d11
parent107e7fa2b2cc2e06addb83518c03b3ab769fed6f (diff)
downloadopenembedded-core-contrib-e8ea6a29ed3ab9892a3bc7ee8249f10688c0af29.tar.gz
udev-cache: replace readfiles() with cmp
Currently, udev-cache system configurations are compared as shell string variables, read into memory with the readfiles() function. This is more complex, and significantly (27-41%) slower, than comparing them using `cmp`. (Performance was verified on both Cortex-A9 and Intel Nehalem systems.) So just use cmp. This requires a few other small changes: exclude /proc/atags from CMP_FILE_LIST if it doesn't exist to avoid errors in `cat` and `cmp`. `cmp -q` doesn't exist in busybox, so instead, redirect output to /dev/null. Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
-rw-r--r--meta/recipes-core/udev/udev/init29
-rw-r--r--meta/recipes-core/udev/udev/udev-cache17
2 files changed, 10 insertions, 36 deletions
diff --git a/meta/recipes-core/udev/udev/init b/meta/recipes-core/udev/udev/init
index d26cbfca96..ee7967063a 100644
--- a/meta/recipes-core/udev/udev/init
+++ b/meta/recipes-core/udev/udev/init
@@ -20,17 +20,6 @@ SYSCONF_TMP="/dev/shm/udev.cache"
[ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
[ -f /etc/default/rcS ] && . /etc/default/rcS
-readfiles () {
- READDATA=""
- for filename in $@; do
- if [ -r $filename ]; then
- while read line; do
- READDATA="$READDATA$line"
- done < $filename
- fi
- done
-}
-
kill_udevd () {
pid=`pidof -x udevd`
[ -n "$pid" ] && kill $pid
@@ -63,14 +52,12 @@ case "$1" in
# Cache handling.
# A list of files which are used as a criteria to judge whether the udev cache could be reused.
- CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices /proc/atags"
+ CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices"
+ [ -f /proc/atags ] && CMP_FILE_LIST="$CMP_FILE_LIST /proc/atags"
if [ "$DEVCACHE" != "" ]; then
if [ -e $DEVCACHE ]; then
- readfiles $CMP_FILE_LIST
- NEWDATA="$READDATA"
- readfiles "$SYSCONF_CACHED"
- OLDDATA="$READDATA"
- if [ "$OLDDATA" = "$NEWDATA" ]; then
+ cat -- "$CMP_FILE_LIST" > "$SYSCONF_TMP"
+ if cmp $SYSCONF_CACHED $SYSCONF_TMP >/dev/null; then
tar xmf $DEVCACHE -C / -m
not_first_boot=1
[ "$VERBOSE" != "no" ] && echo "udev: using cache file $DEVCACHE"
@@ -80,17 +67,15 @@ case "$1" in
if [ "$VERBOSE" != "no" ]; then
echo "udev: udev cache not used"
echo "udev: we use $CMP_FILE_LIST as criteria to judge whether the cache /dev could be resued"
- echo "udev: olddata: $OLDDATA"
- echo "udev: newdata: $NEWDATA"
+ echo "udev: cached sysconf: $SYSCONF_CACHED"
+ echo "udev: current sysconf: $SYSCONF_TMP"
fi
- echo "$NEWDATA" > "$SYSCONF_TMP"
fi
else
if [ "$ROOTFS_READ_ONLY" != "yes" ]; then
# If rootfs is not read-only, it's possible that a new udev cache would be generated;
# otherwise, we do not bother to read files.
- readfiles $CMP_FILE_LIST
- echo "$READDATA" > "$SYSCONF_TMP"
+ cat -- "$CMP_FILE_LIST" > "$SYSCONF_TMP"
fi
fi
fi
diff --git a/meta/recipes-core/udev/udev/udev-cache b/meta/recipes-core/udev/udev/udev-cache
index a1410f5579..e0e1c39488 100644
--- a/meta/recipes-core/udev/udev/udev-cache
+++ b/meta/recipes-core/udev/udev/udev-cache
@@ -21,20 +21,10 @@ SYSCONF_CACHED="/etc/udev/cache.data"
SYSCONF_TMP="/dev/shm/udev.cache"
# A list of files which are used as a criteria to judge whether the udev cache could be reused.
-CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices /proc/atags"
+CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices"
+[ -f /proc/atags ] && CMP_FILE_LIST="$CMP_FILE_LIST /proc/atags"
[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
-readfiles () {
- READDATA=""
- for filename in $@; do
- if [ -r $filename ]; then
- while read line; do
- READDATA="$READDATA$line"
- done < $filename
- fi
- done
-}
-
if [ "$ROOTFS_READ_ONLY" = "yes" ]; then
[ "$VERBOSE" != "no" ] && echo "udev-cache: read-only rootfs, skip generating udev-cache"
exit 0
@@ -43,8 +33,7 @@ fi
if [ "$DEVCACHE" != "" -a -e "$SYSCONF_TMP" ]; then
echo "Populating dev cache"
udevadm control --stop-exec-queue
- readfiles $CMP_FILE_LIST
- echo "$READDATA" > "$SYSCONF_TMP"
+ cat -- $CMP_FILE_LIST > "$SYSCONF_TMP"
find /dev -xdev \( -type b -o -type c -o -type l \) | cut -c 2- \
| xargs tar cf "${DEVCACHE_TMP}" -T-
gzip < "${DEVCACHE_TMP}" > "$DEVCACHE"