diff options
author | Richard Tollerton <rich.tollerton@ni.com> | 2014-12-08 17:13:35 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-12-19 18:08:01 +0000 |
commit | 7f8634cc90bd09a5052dc4cf465c61003e3d05cd (patch) | |
tree | 4904ae289d860e5c1d68374ab87689d97026a215 /meta/recipes-core/udev | |
parent | 24a159e16962477b105eeb144515fd16ddb3cdd0 (diff) | |
download | poky-7f8634cc90bd09a5052dc4cf465c61003e3d05cd.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.
(From OE-Core rev: e8ea6a29ed3ab9892a3bc7ee8249f10688c0af29)
Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/udev')
-rw-r--r-- | meta/recipes-core/udev/udev/init | 29 | ||||
-rw-r--r-- | meta/recipes-core/udev/udev/udev-cache | 17 |
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" | |||
20 | [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf | 20 | [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf |
21 | [ -f /etc/default/rcS ] && . /etc/default/rcS | 21 | [ -f /etc/default/rcS ] && . /etc/default/rcS |
22 | 22 | ||
23 | readfiles () { | ||
24 | READDATA="" | ||
25 | for filename in $@; do | ||
26 | if [ -r $filename ]; then | ||
27 | while read line; do | ||
28 | READDATA="$READDATA$line" | ||
29 | done < $filename | ||
30 | fi | ||
31 | done | ||
32 | } | ||
33 | |||
34 | kill_udevd () { | 23 | kill_udevd () { |
35 | pid=`pidof -x udevd` | 24 | pid=`pidof -x udevd` |
36 | [ -n "$pid" ] && kill $pid | 25 | [ -n "$pid" ] && kill $pid |
@@ -63,14 +52,12 @@ case "$1" in | |||
63 | 52 | ||
64 | # Cache handling. | 53 | # Cache handling. |
65 | # A list of files which are used as a criteria to judge whether the udev cache could be reused. | 54 | # A list of files which are used as a criteria to judge whether the udev cache could be reused. |
66 | CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices /proc/atags" | 55 | CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices" |
56 | [ -f /proc/atags ] && CMP_FILE_LIST="$CMP_FILE_LIST /proc/atags" | ||
67 | if [ "$DEVCACHE" != "" ]; then | 57 | if [ "$DEVCACHE" != "" ]; then |
68 | if [ -e $DEVCACHE ]; then | 58 | if [ -e $DEVCACHE ]; then |
69 | readfiles $CMP_FILE_LIST | 59 | cat -- "$CMP_FILE_LIST" > "$SYSCONF_TMP" |
70 | NEWDATA="$READDATA" | 60 | if cmp $SYSCONF_CACHED $SYSCONF_TMP >/dev/null; then |
71 | readfiles "$SYSCONF_CACHED" | ||
72 | OLDDATA="$READDATA" | ||
73 | if [ "$OLDDATA" = "$NEWDATA" ]; then | ||
74 | tar xmf $DEVCACHE -C / -m | 61 | tar xmf $DEVCACHE -C / -m |
75 | not_first_boot=1 | 62 | not_first_boot=1 |
76 | [ "$VERBOSE" != "no" ] && echo "udev: using cache file $DEVCACHE" | 63 | [ "$VERBOSE" != "no" ] && echo "udev: using cache file $DEVCACHE" |
@@ -80,17 +67,15 @@ case "$1" in | |||
80 | if [ "$VERBOSE" != "no" ]; then | 67 | if [ "$VERBOSE" != "no" ]; then |
81 | echo "udev: udev cache not used" | 68 | echo "udev: udev cache not used" |
82 | echo "udev: we use $CMP_FILE_LIST as criteria to judge whether the cache /dev could be resued" | 69 | echo "udev: we use $CMP_FILE_LIST as criteria to judge whether the cache /dev could be resued" |
83 | echo "udev: olddata: $OLDDATA" | 70 | echo "udev: cached sysconf: $SYSCONF_CACHED" |
84 | echo "udev: newdata: $NEWDATA" | 71 | echo "udev: current sysconf: $SYSCONF_TMP" |
85 | fi | 72 | fi |
86 | echo "$NEWDATA" > "$SYSCONF_TMP" | ||
87 | fi | 73 | fi |
88 | else | 74 | else |
89 | if [ "$ROOTFS_READ_ONLY" != "yes" ]; then | 75 | if [ "$ROOTFS_READ_ONLY" != "yes" ]; then |
90 | # If rootfs is not read-only, it's possible that a new udev cache would be generated; | 76 | # If rootfs is not read-only, it's possible that a new udev cache would be generated; |
91 | # otherwise, we do not bother to read files. | 77 | # otherwise, we do not bother to read files. |
92 | readfiles $CMP_FILE_LIST | 78 | cat -- "$CMP_FILE_LIST" > "$SYSCONF_TMP" |
93 | echo "$READDATA" > "$SYSCONF_TMP" | ||
94 | fi | 79 | fi |
95 | fi | 80 | fi |
96 | fi | 81 | 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" | |||
21 | SYSCONF_TMP="/dev/shm/udev.cache" | 21 | SYSCONF_TMP="/dev/shm/udev.cache" |
22 | 22 | ||
23 | # A list of files which are used as a criteria to judge whether the udev cache could be reused. | 23 | # A list of files which are used as a criteria to judge whether the udev cache could be reused. |
24 | CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices /proc/atags" | 24 | CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices" |
25 | [ -f /proc/atags ] && CMP_FILE_LIST="$CMP_FILE_LIST /proc/atags" | ||
25 | [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache | 26 | [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache |
26 | 27 | ||
27 | readfiles () { | ||
28 | READDATA="" | ||
29 | for filename in $@; do | ||
30 | if [ -r $filename ]; then | ||
31 | while read line; do | ||
32 | READDATA="$READDATA$line" | ||
33 | done < $filename | ||
34 | fi | ||
35 | done | ||
36 | } | ||
37 | |||
38 | if [ "$ROOTFS_READ_ONLY" = "yes" ]; then | 28 | if [ "$ROOTFS_READ_ONLY" = "yes" ]; then |
39 | [ "$VERBOSE" != "no" ] && echo "udev-cache: read-only rootfs, skip generating udev-cache" | 29 | [ "$VERBOSE" != "no" ] && echo "udev-cache: read-only rootfs, skip generating udev-cache" |
40 | exit 0 | 30 | exit 0 |
@@ -43,8 +33,7 @@ fi | |||
43 | if [ "$DEVCACHE" != "" -a -e "$SYSCONF_TMP" ]; then | 33 | if [ "$DEVCACHE" != "" -a -e "$SYSCONF_TMP" ]; then |
44 | echo "Populating dev cache" | 34 | echo "Populating dev cache" |
45 | udevadm control --stop-exec-queue | 35 | udevadm control --stop-exec-queue |
46 | readfiles $CMP_FILE_LIST | 36 | cat -- $CMP_FILE_LIST > "$SYSCONF_TMP" |
47 | echo "$READDATA" > "$SYSCONF_TMP" | ||
48 | find /dev -xdev \( -type b -o -type c -o -type l \) | cut -c 2- \ | 37 | find /dev -xdev \( -type b -o -type c -o -type l \) | cut -c 2- \ |
49 | | xargs tar cf "${DEVCACHE_TMP}" -T- | 38 | | xargs tar cf "${DEVCACHE_TMP}" -T- |
50 | gzip < "${DEVCACHE_TMP}" > "$DEVCACHE" | 39 | gzip < "${DEVCACHE_TMP}" > "$DEVCACHE" |