--- /etc/rc.subr.orig 2009-05-28 17:17:57.000000000 +0200 +++ /etc/rc.subr 2010-01-07 18:27:27.000000000 +0100 @@ -58,6 +58,7 @@ IDCMD="if [ -x $ID ]; then $ID -un; fi" PS="/bin/ps -ww" JID=`$PS -p $$ -o jid=` +CPUSET="/usr/bin/cpuset" case ${OSTYPE} in FreeBSD) @@ -421,6 +422,9 @@ # ${name}_chdir n Directory to cd to before running ${command} # (if not using ${name}_chroot). # +# ${name}_cpuset n A list of CPUs to run ${command} on. +# Requires /usr to be mounted. +# # ${name}_flags n Arguments to call ${command} with. # NOTE: $flags from the parent environment # can be used to override this. @@ -572,6 +576,17 @@ _pidcmd= _procname=${procname:-${command}} + eval _cpuset=\$${name}_cpuset + # fix for background-fsck problem / check if value start with number + case "$_cpuset" in + [0-9]*) ;; + *) _cpuset="" ;; + esac + _cpusetcmd= + if [ -n "$_cpuset" -a -x $CPUSET ]; then + _cpusetcmd="$CPUSET -l $_cpuset" + fi + # setup pid check command if [ -n "$_procname" ]; then if [ -n "$pidfile" ]; then @@ -629,7 +644,7 @@ if [ -n "$_cmd" ]; then _run_rc_precmd || return 1 - _run_rc_doit "$_cmd $rc_extra_args" || return 1 + _run_rc_doit "$_cpusetcmd $_cmd $rc_extra_args" || return 1 _run_rc_postcmd return $_return fi @@ -640,6 +655,11 @@ _run_rc_precmd || return 1 if [ -n "$rc_pid" ]; then echo "${name} is running as pid $rc_pid." + # for cpuset debug only, not committable (cut) + if [ -n "$_cpuset" -a -x $CPUSET ]; then + echo -n "on CPU(s)" + $CPUSET -g -p "$rc_pid" | cut -s -d: -f 2 + fi else echo "${name} is not running." return 1 @@ -665,13 +685,13 @@ echo "Starting ${name}." if [ -n "$_chroot" ]; then _doit="\ -${_nice:+nice -n $_nice }\ +${_nice:+nice -n $_nice } $_cpusetcmd\ chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\ $_chroot $command $rc_flags $command_args" else _doit="\ ${_chdir:+cd $_chdir && }\ -$command $rc_flags $command_args" +$_cpusetcmd $command $rc_flags $command_args" if [ -n "$_user" ]; then _doit="su -m $_user -c 'sh -c \"$_doit\"'" fi