MINI SHELL

Server : Apache/2.2.2 (Fedora)
System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686
User : apache ( 48)
PHP Version : 5.2.9
Disable Function : NONE
Directory :  /proc/self/root/etc/init.d/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/etc/init.d/irqbalance
#! /bin/sh
#
# irqbalance       Start/Stop irq balancing daemon
#
# chkconfig: 2345 13 87
# description: The irqbalance daemon will distribute interrupts across  \
#              the cpus on a multiprocessor system with the purpose of \
#              spreading the load. \
# processname: irqbalance


# This is an interactive program, we need the current locale

# Source function library.
. /etc/init.d/functions

#internal functions
set_isolcpu_affinity_mask() {

#the isolcpu line in the kenrel is of the format:
#[<cpunum>[-cpunum],]+
	local mask
	local tmp_mask;
	local range
	local range_high
	local range_low
	local space_list
	local cpus
	local chunk_mask
	local temp_mask

	grep isolcpus /proc/cmdline > /dev/null
	if [ $? != 0 ]
	then
		# no isolcpus line
		IRQ_AFFINITY_MASK=
		return
	fi

	# get a space separated list of ranges
	space_list=`sed -e's/\(^.*isolcpus=\)\([^ ]* *\)\(.*$\)/\2/' -e's/,/ /g' /proc/cmdline`

	mask=0

	for range in $space_list
	do
		# Get the Range
		range_low=`echo $range | awk -F- '{print $1}'`	
		range_high=`echo $range | awk -F- '{print $2}'`	

		#
		# If the High Range is not included
		# its the same as te low range
		#
		if [ -z "$range_high" ]
		then
			range_high=$range_low
		fi

		cpus=`dc -e"$range_high $range_low - p"`

		tmp_mask=0
		#
		# Build the number of 1's we need into the mask
		#
		for i in `seq 0 1 $cpus`
		do
			tmp_mask=`dc -e"2 $i ^ $tmp_mask + p"`
		done

		#
		# And Shift the mask up to where it belongs
		#
		tmp_mask=`dc -e"2 $range_low ^ $tmp_mask * p"`

		#
		# Lastly, or the mask into the result mask with
		# an add operation
		#
		mask=`dc -e"$mask $tmp_mask + p"`
	done

	#
	# Convert the mask to a hex value
	#
	mask=`dc -e"10 i 16 o $mask p"`

	#
	# Now divide up the mask with commas since Arjan apparently didn't 
	# feel the need to make this easy.
	#
	chunk_mask=""
	temp_mask=$mask
	while [ -n "$temp_mask" ]
	do
		new_chunk=`echo $temp_mask | cut -b1-8`
		temp_mask=`echo $temp_mask | cut -b9-`
		chunk_mask="$chunk_mask,$new_chunk"
	done

	# now strip the leading comma
	chunk_mask=`echo $chunk_mask | sed -e's/,//'`

	#
	# Now Assign the mask value to the IRQ_AFFINITY_MASK
	#
	IRQ_AFFINITY_MASK=$chunk_mask 
		
}


# Check that we're a priviledged user
[ `id -u` = 0 ] || exit 0


prog="irqbalance"

# Check that networking is up.
if [ "$NETWORKING" = "no" ]
then
	exit 0
fi

[ -f /usr/sbin/irqbalance ] || exit 0

# fetch configuration if it exists
# ONESHOT=yes says to wait for a minute, then look at the interrupt
# load and balance it once; after balancing exit and do not change
# it again.
# The default is to keep rebalancing once every 10 seconds.
ONESHOT=
[ -f /etc/sysconfig/irqbalance ] && . /etc/sysconfig/irqbalance
case "$ONESHOT" in
	y*|Y*|on) ONESHOT=--oneshot ;;
	*) ONESHOT= ;;
esac

#
# Check to see if our IRQ_AFFINITY_MASK needs to be computed from 
# the isolcpus command line options
#
if [ "$FOLLOW_ISOLCPUS" == "yes" ]
then
	set_isolcpu_affinity_mask
fi

RETVAL=0

start() {
        if [ -n "$ONESHOT" -a -f /var/lock/irqbalance ]; then
                exit 0
        fi
        echo -n $"Starting $prog: "
	if [ -n "$IRQ_AFFINITY_MASK" ];
	then
		export IRQBALANCE_BANNED_CPUS=$IRQ_AFFINITY_MASK
	fi 	
        daemon irqbalance $ONESHOT $IRQ_AFFINITY
        RETVAL=$?
        echo
        if [ $RETVAL -eq 0 ]; then
                if [ -n "$ONESHOT" ]; then
                        touch /var/lock/subsys/irqbalance
                else
                        touch /var/lock/irqbalance
                fi
        fi
        return $RETVAL
}


stop() {
        echo -n $"Stopping $prog: "
        killproc irqbalance
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/irqbalance
	return $RETVAL
}

restart() {
	stop
	start
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	status irqbalance
	;;
  restart|reload)
	restart
	;;
  condrestart)
	[ -f /var/lock/subsys/irqbalance ] && restart || :
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
	exit 1
	;;
esac

exit $?

Anon7 - 2021