Problems with make -j
Benjamin Lutz
benlutz at datacomm.ch
Wed Jul 27 14:39:20 GMT 2005
Hello,
As a pet project I've started to change /etc/rc so it uses make(1) to
execute the scripts in /etc/rc.d instead of executing them one after the
other like the standard /etc/rc does. The goal of the project is to speed
up boot time by executing rc.d scripts in parallel.
Now, if I don't specify a -j parameter this works just fine. I've written
a script that generates a Makefile with all the rc.d dependencies in it,
and using that the system boots just fine.
As soon as I add a -j parameter to make, even -j 1, things break though.
Scripts (eg, rc.subr) are being spewed to the screen several times, and
execution hangs at /etc/rc.d/adjkerntz (I think). I can pipe all this to
a log file with > make.log 2>&1. By the time make gets to adjkerntz and I
ctrl-c it, the logfile is slightly above 3MB.
Can anyone tell me why make behaves like this? If I had to guess I'd say
something's happening to the file descriptors, or something that make
needs for -j to work has not been set up. Btw, I have set up a memory
disk in /etc/tmp that make can use for -j (and I've patched make to use
that patch).
Here's what I use in /etc/rc now:
===== SNIPPET START =====
RC_MAKE="1"
if [ -z "$RC_MAKE" ]; then
skip="-s nostart"
[ `/sbin/sysctl -n security.jail.jailed` -eq 1 ] && \
skip="$skip -s nojail"
files=`rcorder ${skip} /etc/rc.d/* 2>/dev/null`
for _rc_elem in ${files}; do
run_rc_script ${_rc_elem} ${_boot}
done
else
skip="-DSKIP -DNOSTART"
[ `/sbin/sysctl -n security.jail.jailed` -eq 1 ] && \
skip="$skip -DNOJAIL"
/sbin/mdmfs -M -S -o sync -s 5m md0 /etc/tmp
/bin/rc_make -i -f /etc/Makefile ${skip} PARAM=${_boot}
/sbin/umount /dev/md0
/sbin/mdconfig -d -u md0
fi
===== SNIPPET END =====
Here's two example targets from the /etc/Makefile:
===== SNIPPET START =====
abi! LOGIN archdep
.ifdef !KEEP || NOJAIL
.ifdef !SKIP || (!NOJAIL)
. /etc/rc.subr && run_rc_script /etc/rc.d/abi ${PARAM}
.endif
.endif
accounting! mountcritremote
.ifdef !KEEP || NOJAIL
.ifdef !SKIP || (!NOJAIL)
. /etc/rc.subr && run_rc_script /etc/rc.d/accounting ${PARAM}
.endif
.endif
===== SNIPPET END =====
This currently works. As soon as I add "-j 1" or "-j 2" to the rc_make
call above, I get the behaviour described above.
Note that rc_make is standard make(1) except that TMPPAT has been changed
from /tmp to /etc/tmp.
Cheers
Benjamin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20050727/bab6eb04/attachment.bin
More information about the freebsd-questions
mailing list