Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Jan 2010 19:00:08 GMT
From:      Miroslav Lachman <000.fbsd@quip.cz>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: conf/142434: [patch] Add cpuset(1) support to rc.subr
Message-ID:  <201001071900.o07J088e073769@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR conf/142434; it has been noted by GNATS.

From: Miroslav Lachman <000.fbsd@quip.cz>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/142434: [patch] Add cpuset(1) support to rc.subr
Date: Thu, 07 Jan 2010 19:58:46 +0100

 This is a multi-part message in MIME format.
 --------------000406030203050904060109
 Content-Type: text/plain; charset=ISO-8859-2; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Attached patch is for 7.2-RELEASE
 
 --------------000406030203050904060109
 Content-Type: text/plain;
  name="cpuset_rc.subr_72.patch.txt"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="cpuset_rc.subr_72.patch.txt"
 
 --- /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
 
 --------------000406030203050904060109--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001071900.o07J088e073769>