[arch-dev-public] [PATCH] rc.sysinit: background hwclock calls
hwclock calls appear to block somewhere between 1 and 2 seconds when we have back-to-back calls. My theory (without looking at the code) is that hwclock has to synchronize to the 1 second intervals of the hardware clock, so it can sometimes take up to a second to complete. To get around this unpleasant behavior, we can background the calls at point X in the boot sequence, and then later at point Y in the script (when we absolutely need the clock actions to be complete), we wait on the subprocess. This allows the rest of the boot sequence, after both hwclock code blocks, to continue until the point where we wait on the subprocess. Signed-off-by: Dan McGee <dan@archlinux.org> --- For reference, but didn't want to include them in the patch as they will probably disappear: Before on the Eee: http://www.toofishes.net/uploads/bootchart-2.png After: http://www.toofishes.net/uploads/bootchart-3.png Note that there is no longer a huge section of time where the CPU is going unused; this was the second hwclock block before. Also note that rc.multi starts at ~8.5 secs where as before it was ~11 secs. -Dan rc.sysinit | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/rc.sysinit b/rc.sysinit index 0c934c7..524b2cd 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -36,6 +36,7 @@ else fi HWCLOCK_PARAMS="--hctosys" +clock_pid="" if [ "$HARDWARECLOCK" = "UTC" ]; then HWCLOCK_PARAMS="$HWCLOCK_PARAMS --utc" elif [ "$HARDWARECLOCK" = "localtime" ]; then @@ -57,7 +58,10 @@ if [ -n "$HWCLOCK_PARAMS" ]; then # Set clock early to fix some bugs with filesystem checks # Clock is set again later to match rc.conf if [ -f /etc/localtime ]; then + ( /sbin/hwclock $HWCLOCK_PARAMS --noadjfile + ) & + clock_pid=$! fi fi @@ -111,6 +115,11 @@ if [ -d /sys/class/net/lo ]; then fi fi +# preliminary hwclock setting needs to be done at this point +if [ -n "$clock_pid" ]; then + wait $clock_pid +fi + # If necessary, find md devices and manually assemble RAID arrays if [ -f /etc/mdadm.conf -a "$(/bin/grep ^ARRAY /etc/mdadm.conf 2>/dev/null)" ]; then status "Activating RAID arrays" /sbin/mdadm --assemble --scan @@ -282,8 +291,11 @@ if [ "$TIMEZONE" != "" -a -e "/usr/share/zoneinfo/$TIMEZONE" ]; then fi if [ -n "$HWCLOCK_PARAMS" ]; then + ( /sbin/hwclock --adjust #Adjust for system drift /sbin/hwclock $HWCLOCK_PARAMS + ) & + clock_pid=$! fi stat_done @@ -396,7 +408,12 @@ fi /bin/dmesg >| /var/log/dmesg.log +# final hwclock setting needs to be done at this point +if [ -n "$clock_pid" ]; then + wait $clock_pid +fi + run_hook sysinit_end # End of file -# vim: set ts=2 noet: +# vim: set ts=2 sw=2 noet: -- 1.6.5.2
participants (1)
-
Dan McGee