[Demudi-commits] r632 - rtirq/branches/upstream/20050914

Free Ekanayaka free-guest at costa.debian.org
Wed Feb 1 21:19:58 UTC 2006


Author: free-guest
Date: 2006-02-01 21:19:57 +0000 (Wed, 01 Feb 2006)
New Revision: 632

Added:
   rtirq/branches/upstream/20050914/rtirq.conf
   rtirq/branches/upstream/20050914/rtirq.sh
   rtirq/branches/upstream/20050914/rtirq.spec
Log:
Upstream

Added: rtirq/branches/upstream/20050914/rtirq.conf
===================================================================
--- rtirq/branches/upstream/20050914/rtirq.conf	2006-02-01 21:19:29 UTC (rev 631)
+++ rtirq/branches/upstream/20050914/rtirq.conf	2006-02-01 21:19:57 UTC (rev 632)
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# Copyright (c) 2004-2005 rncbc aka Rui Nuno Capela.
+# All rights reserved.
+#
+# /etc/sysconfig/rtirq
+#
+# Configuration for IRQ thread tunning,
+# for realtime-preempt enabled kernels,
+#
+
+# IRQ thread service names
+# (space separeted list, from higher to lower priority).
+RTIRQ_NAME_LIST="rtc snd usb i8042"
+
+# Highest priority. 
+RTIRQ_PRIO_HIGH=90
+
+# Priority decrease step.
+RTIRQ_PRIO_DECR=10
+
+# Whether to reset all IRQ threads to SCHED_OTHER.
+RTIRQ_RESET_ALL=0
+
+# On kernel configurations that support it,
+# which services should be NOT threaded 
+# (space separated list).
+RTIRQ_NON_THREADED="rtc snd"
+

Added: rtirq/branches/upstream/20050914/rtirq.sh
===================================================================
--- rtirq/branches/upstream/20050914/rtirq.sh	2006-02-01 21:19:29 UTC (rev 631)
+++ rtirq/branches/upstream/20050914/rtirq.sh	2006-02-01 21:19:57 UTC (rev 632)
@@ -0,0 +1,248 @@
+#!/bin/sh
+#
+# Copyright (c) 2004-2005 rncbc aka Rui Nuno Capela.
+# All rights reserved.
+#
+# /etc/init.d/rtirq
+#
+# Startup script for realtime-preempt enabled kernels.
+#
+# chkconfig: 35 81 19
+# description: Realtime IRQ thread tunning.
+#
+### BEGIN INIT INFO
+# Provides:          rtirq
+# Required-Start:    $syslog $local_fs
+# Should-Start: $time alsa alsasound hotplug
+# Required-Stop:     $syslog $local_fs
+# Should-Stop: $time alsa alsasound hotplug
+# Default-Start:     3 5
+# Default-Stop:      0 1 2 6
+# Short-Description: Realtime IRQ thread tunning.
+# Description:       Change the realtime scheduling policy
+#	and priority of relevant system driver IRQ handlers.
+### END INIT INFO
+#
+
+
+# Won't work without those binaries.
+for DIR in /sbin /usr/sbin /bin /usr/bin /usr/local/bin; do
+	[ -z "${RTIRQ_CHRT}"  -a -x ${DIR}/chrt  ] &&  RTIRQ_CHRT=${DIR}/chrt
+	[ -z "${RTIRQ_PIDOF}" -a -x ${DIR}/pidof ] && RTIRQ_PIDOF=${DIR}/pidof
+done
+
+# Check for missing binaries (stale symlinks should not happen)
+[ -n "${RTIRQ_CHRT}" -a -x ${RTIRQ_CHRT} ] || {
+	echo "`basename $0`: chrt: not installed."  
+	[ "$1" = "stop" ] && exit 0 || exit 5
+}
+
+[ -n "${RTIRQ_PIDOF}" -a -x ${RTIRQ_PIDOF} ] || {
+	echo "`basename $0`: pidof: not installed."  
+	[ "$1" = "stop" ] && exit 0 || exit 5
+}
+
+# Check for existence of needed config file and read it.
+RTIRQ_CONFIG=/etc/sysconfig/rtirq
+[ -r ${RTIRQ_CONFIG} ] || {
+	echo "`basename $0`: ${RTIRQ_CONFIG}: not found."
+	[ "${RTIRQ_ACTION}" = "stop" ] && exit 0 || exit 6
+}
+
+# Read configuration.
+. ${RTIRQ_CONFIG}
+
+# Colon delimited trail list of already assigned IRQ numbers,
+# preventind lower priority override due to shared IRQs.
+RTIRQ_TRAIL=":"
+
+# 
+# Reset policy of all IRQ threads out there. 
+#
+function rtirq_reset ()
+{
+	# PIDS=`ps -eo pid,class | egrep '(FF|RR)' | awk '{print $1}'`
+	PIDS=`ps -eo pid,comm | grep IRQ | awk '{print $1}'`
+	for PID in ${PIDS}
+	do
+		${RTIRQ_CHRT} --pid --other 0 ${PID}
+	done
+}
+
+#
+# IRQ thread handler policy prioritizer, by IRQ number.
+#
+function rtirq_exec_num ()
+{
+	ACTION=$1
+	NAME1=$2
+	NAME2=$3
+	PRI2=$4
+	IRQ=$5
+	# Check the services that are to be (un)threaded.
+	if [ -n "`echo :${RTIRQ_NON_THREADED}: | sed 's/ /:/g' | grep :${NAME1}:`" ]
+	then
+		PREPEND="`basename $0`: ${ACTION} [${NAME2}] irq=${IRQ}"
+		for THREADED in /proc/irq/${IRQ}/*/threaded
+		do
+			if [ -f "${THREADED}" ]
+			then
+				case ${ACTION} in
+				start)
+					echo "${PREPEND}: ${THREADED}: OFF."
+					echo 0 > "${THREADED}"
+					;;
+				stop)
+					echo "${PREPEND}: ${THREADED}: ON."
+					echo 1 > "${THREADED}"
+					;;
+				esac
+			fi
+		done
+	fi
+	# And now the proper threading prioritization...
+	PID=`${RTIRQ_PIDOF} "IRQ ${IRQ}"`
+	if [ $((${PID})) -gt 0 -a -z "`echo ${RTIRQ_TRAIL} | grep :${IRQ}:`" ]
+	then 
+		PREPEND="`basename $0`: ${ACTION} [${NAME2}] irq=${IRQ} pid=${PID}"
+		case ${ACTION} in
+		start)
+			PREPEND="${PREPEND} prio=${PRI2}"
+			if ${RTIRQ_CHRT} --pid --fifo ${PRI2} ${PID}
+			then
+				echo "${PREPEND}: OK."
+			else 
+				echo "${PREPEND}: FAILED."
+			fi
+			;;
+		stop)
+			if ${RTIRQ_CHRT} --pid --other 0 ${PID}
+			then
+				echo "${PREPEND}: OK."
+			else 
+				echo "${PREPEND}: FAILED."
+			fi
+			;;
+		status)
+			echo "${PREPEND}: " && ${RTIRQ_CHRT} --pid --verbose ${PID}
+			;;
+		*)
+			echo "${PREPEND}: ERROR."
+			;;
+		esac
+		RTIRQ_TRAIL=":${IRQ}${RTIRQ_TRAIL}"
+	fi
+}
+
+#
+# IRQ thread handler policy prioritizer, by service name.
+#
+function rtirq_exec_name ()
+{
+	ACTION=$1
+	NAME1=$2
+	NAME2=$3
+	PRI1=$4
+	IRQS=`grep "${NAME2}" /proc/interrupts | awk -F: '{print $1}'`
+	for IRQ in ${IRQS}
+	do
+		rtirq_exec_num ${ACTION} ${NAME1} ${NAME2} ${PRI1} ${IRQ}
+		PRI1=$((${PRI1} - 1))
+	done
+}
+
+
+#
+# Main executive.
+#
+function rtirq_exec ()
+{
+	ACTION=$1
+	# Check configured base priority.
+	PRI0=${RTIRQ_PRIO_HIGH}
+	[ $((${PRI0})) -gt 90 ] && PRI0=90
+	[ $((${PRI0})) -lt 10 ] && PRI0=10
+	# Check configured priority decrease step.
+	DECR=${RTIRQ_PRIO_DECR}
+	[ $((${DECR})) -gt 20 ] && DECR=20
+	[ $((${DECR})) -lt  1 ] && DECR=1
+	# Process all configured service names...
+	for NAME in ${RTIRQ_NAME_LIST}
+	do
+		case ${NAME} in
+		snd)
+			PRI1=${PRI0}
+			IRQS=`grep irq /proc/asound/cards | sed 's/.* irq \(.*\)/\1/'`
+			for IRQ in ${IRQS}
+			do
+				rtirq_exec_num ${ACTION} ${NAME} ${NAME} ${PRI1} ${IRQ}
+				PRI1=$((${PRI1} - 1))
+			done
+			;;
+		usb)
+			rtirq_exec_name ${ACTION} ${NAME} "ohci_hcd" ${PRI0}
+			rtirq_exec_name ${ACTION} ${NAME} "uhci_hcd" ${PRI0}
+			rtirq_exec_name ${ACTION} ${NAME} "ehci_hcd" ${PRI0}
+			;;
+		*)
+			rtirq_exec_name ${ACTION} ${NAME} ${NAME} ${PRI0}
+			;;  
+		esac
+		[ ${PRI0} -gt ${DECR} ] && PRI0=$((${PRI0} - ${DECR}))
+	done
+}
+
+
+#
+# Main procedure line.
+#
+case $1 in
+*start)
+	if [ "${RTIRQ_RESET_ALL}" = "yes" -o "${RTIRQ_RESET_ALL}" = "1" ]
+	then
+		rtirq_reset
+	fi
+	rtirq_exec start
+	;;
+stop)
+	if [ "${RTIRQ_RESET_ALL}" = "yes" -o "${RTIRQ_RESET_ALL}" = "1" ]
+	then
+		rtirq_reset
+	#else
+	#  rtirq_exec stop
+	fi
+	;;
+reset)
+	if [ "${RTIRQ_RESET_ALL}" = "yes" -o "${RTIRQ_RESET_ALL}" = "1" ]
+	then
+		rtirq_reset
+	else
+		rtirq_exec stop
+	fi
+	;;
+status)
+	echo
+	#rtirq_exec status
+	ps -eo pid,class,rtprio,ni,pri,pcpu,stat,comm --sort -rtprio \
+		| egrep '(^[[:blank:]]*PID|IRQ)' \
+		| awk 'BEGIN {
+			while (getline IRQLine < "/proc/interrupts") {
+				split(IRQLine, IRQSplit, ":[[:blank:]|0-9]+");
+				if (match(IRQSplit[1], "^[[:blank:]]*[0-9]+$")) {
+					gsub("[^[:blank:]]+PIC[^[:blank:]]*[[:blank:]]+" \
+						"|\\[[^\\]]+\\][[:blank:]]+", "", IRQSplit[2]);
+					IRQTable[IRQSplit[1] + 0] = IRQSplit[2];
+				}
+			}
+		}	{ print $0"\t"IRQTable[$9]; }'
+	echo
+	;;
+*)
+	echo
+	echo "  Usage: $0 {[re]start|stop|reset|status}"
+	echo
+	exit 1
+	;;
+esac
+
+exit 0


Property changes on: rtirq/branches/upstream/20050914/rtirq.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: rtirq/branches/upstream/20050914/rtirq.spec
===================================================================
--- rtirq/branches/upstream/20050914/rtirq.spec	2006-02-01 21:19:29 UTC (rev 631)
+++ rtirq/branches/upstream/20050914/rtirq.spec	2006-02-01 21:19:57 UTC (rev 632)
@@ -0,0 +1,81 @@
+%define name    rtirq
+%define version 20050914
+%define release 12
+
+Summary:	Realtime IRQ thread system tunning.
+Name:		%{name}
+Version:	%{version}
+Release:	%{release}
+Copyright:	GPL
+Packager:	rncbc
+Group:		System Environment/Base         
+Source0:	%{name}-%{version}.tar.gz
+BuildRoot:	/var/tmp/%{name}-%{version}-buildroot
+BuildArchitectures:	noarch
+Requires:	/bin/sh,schedutils
+Requires(post,preun):	/sbin/chkconfig
+
+%description
+Startup scripts for tunning the realtime scheduling policy and priority
+of relevant IRQ service threads, featured for a realtime-preempt enabled
+kernel configuration. 
+
+%prep
+
+%setup
+
+%build
+
+%install
+if [ -d $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT; fi
+install -vD rtirq.sh   -m 0755 $RPM_BUILD_ROOT/etc/init.d/rtirq
+install -vD rtirq.conf -m 0644 $RPM_BUILD_ROOT/etc/sysconfig/rtirq
+
+%post
+# Only run on install, not upgrade.
+if [ "$1" = "1" ]; then
+    chkconfig --add rtirq
+    chkconfig rtirq on
+fi
+
+%preun
+# Only run if this is the last instance to be removed.
+if [ "$1" = "0" ]; then
+    chkconfig rtirq off
+    chkconfig --del rtirq
+fi
+
+%clean
+if [ -d $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT; fi
+
+%files
+%defattr(-,root,root)
+%config /etc/sysconfig/rtirq
+/etc/init.d/rtirq
+
+%changelog
+* Wed Sep 14 2005 Rui Nuno Capela <rncbc at users.sourceforge.net>
+- Touched to 20050914 version.
+* Tue Aug 16 2005 Rui Nuno Capela <rncbc at users.sourceforge.net>
+- Fixed to 20050816 version.
+* Wed Jun 20 2005 Rui Nuno Capela <rncbc at users.sourceforge.net>
+- Up to 20050620 tinyfix version.
+* Wed Jun 8 2005 Rui Nuno Capela <rncbc at users.sourceforge.net>
+- Fixes on non threading IRQ service (thanks to Luis Garrido).
+- Bumped to 20050608 version.
+* Wed Jun 1 2005 Rui Nuno Capela <rncbc at users.sourceforge.net>
+- Missing info on status list was fixed for IRQs>99. 
+- Moved to 20050601 version.
+* Wed Apr 15 2005 Rui Nuno Capela <rncbc at users.sourceforge.net>
+- Non threading IRQ service list configuration option.
+- Moved to 20050415 version.
+* Wed Apr 8 2005 Rui Nuno Capela <rncbc at users.sourceforge.net>
+- IRQ handler refrence name included on status listing.
+- Prevent lower priority overriding due to shared IRQs.
+- Fixed to 20050408 version.
+* Thu Nov 12 2004 Rui Nuno Capela <rncbc at users.sourceforge.net>
+- Bumped to 20041112 version.
+* Thu Nov 8 2004 Rui Nuno Capela <rncbc at users.sourceforge.net>
+- Update for the new 20041108 version.
+* Thu Nov 4 2004 Rui Nuno Capela <rncbc at users.sourceforge.net>
+- Created initial rtirq.spec




More information about the Demudi-commits mailing list