Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
morph-sources-2.6.12-morph7 (realtime-preempt, updates)
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3, 4  
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
Dominique_71
Veteran
Veteran


Joined: 17 Aug 2005
Posts: 1500
Location: Switzerland (Romandie)

PostPosted: Wed Jan 25, 2006 6:14 pm    Post subject: Reply with quote

After reading /usr/src/linux/Documentation/sound/alsa/emu10k1-jack.txt and according my jack config as suggested, I am now able to run jack with a latency of 1.33msec at 48kHz and 0.667 msec at 96kHz. Its rock!

Here is some scripts I run at boot time:
/etc/init.d/realtime
Code:
#! /bin/sh
#
# This script loads and unloads the realtime kernel module
# Configuration can be put into /etc/default/realtime
#
# Author:   Guenter Geiger <geiger@debian.org>
#
#
# Version:   0.1
#

PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=realtime
DESC="Realtime Linux Security Module"

# Gracefully exit if the package has been removed.
if test ! -e "/lib/modules/`uname -r`/extra/realtime.ko"
then
  echo Loading $DESC: not found
  exit 0
fi

# Read config file if it is present.
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# The module has to be enabled
if test "$ENABLE" != "yes"
then
   echo Loading $DESC: disabled
   exit 0
fi


CAPLOADED=`lsmod | grep capability`

set -e

case "$1" in
  start)
        if [ "$CAPLOADED" != "" ]
   then
     echo Realtime Linux Security Module: Unloading capability LSM
     rmmod capability
        fi
   echo -n "Loading $DESC: $NAME"
   modprobe $NAME $PARAMETERS
   echo "."
   ;;
  stop)
   echo -n "Unloading $DESC: $NAME "
   modprobe -r $NAME
   echo "."
   ;;
  restart|force-reload)
   echo -n "Restarting $DESC: $NAME"
   modprobe -r $NAME
   sleep 1
   modprobe $NAME $PARAMETERS
   echo "."
   ;;
  *)
   N=/etc/init.d/$NAME
   # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
   echo "Usage: $N {start|stop|restart|force-reload}" >&2
   exit 1
   ;;
esac

exit 0

/etc/init.d/rtirq
Code:
#!/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/default/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 number.
#
function rtirq_exec_num ()
{
   ACTION=$1
   NAME=$2
   PRI2=$3
   IRQ=$4
   PID=`${RTIRQ_PIDOF} "IRQ ${IRQ}"`
   if [ $((${PID})) -gt 0 -a -z "`echo ${RTIRQ_TRAIL} | grep :${IRQ}:`" ]
   then
      PREPEND="Setting IRQ priorities: ${ACTION} [${NAME}] 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 name.
#
function rtirq_exec_name ()
{
   ACTION=$1
   NAME=$2
   PRI1=$3
   IRQS=`grep "${NAME}" /proc/interrupts | awk -F: '{print $1}'`
   for IRQ in ${IRQS}
   do
      rtirq_exec_num ${ACTION} ${NAME} ${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} ${PRI1} ${IRQ}
            PRI1=$((${PRI1} - 1))
         done
         ;;
      usb)
         rtirq_exec_name ${ACTION} "ohci_hcd" ${PRI0}
         rtirq_exec_name ${ACTION} "uhci_hcd" ${PRI0}
         rtirq_exec_name ${ACTION} "ehci_hcd" ${PRI0}
         ;;
      *)
         rtirq_exec_name ${ACTION} ${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, ":");
            if (match(IRQSplit[1], "^[[:blank:]]+[0-9]+$")) {
               gsub("^[[:blank:]|0-9]+|[/|0-9]+$" \
                  "|[^[:blank:]]+PIC[^[: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

/etc/default/realtime
Code:
# Configuration file for the realtime LSM module
# PARAMETERS can be one or more of:
#
# gid=xx      (allow realtime capabilities for gid xx only)
# any=1|0     (allow any user and process to have realtime)
# mlock=1|0   (allow/disallow mlocking)
# allcaps=1|0 (allow setpcap functionality (dangerous!))

# enable loading of module at startup
ENABLE=yes

# parameter settings for module
PARAMETERS="gid=18"

/etc/default/rtirq
Code:
#!/bin/sh
#
# Copyright (c) 2004-2005 rncbc aka Rui Nuno Capela.
# All rights reserved.
#
# /etc/default/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

_________________
[[[ To any NSA and FBI agents reading that text: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
Back to top
View user's profile Send private message
evermind
Guru
Guru


Joined: 10 Jan 2004
Posts: 322

PostPosted: Thu Feb 16, 2006 7:57 pm    Post subject: Reply with quote

Dominique_71 wrote:

/etc/init.d/rtirq

I added an ebuild to my pro_audio_music_portage_overlay for the rtirq-init-script
and adjusted it a bit to match the gentoo-init-style -- hope nothing broke

thx for the hint

original script was: mailinglist: PlanetCCRMA
Back to top
View user's profile Send private message
Dominique_71
Veteran
Veteran


Joined: 17 Aug 2005
Posts: 1500
Location: Switzerland (Romandie)

PostPosted: Sat Feb 18, 2006 3:37 pm    Post subject: Reply with quote

You are welcome.

The kernel development is going very fast, and the realtime-lsm module is now obsolete.
The future will be a PAM realtime kernel with rt-limit, but I believe at it is best to wait until the rt-limit has proved at it is as reliable as the realtime-lsm. :idea:

alsa and PAM
Rlimits-Aware PAM
_________________
[[[ To any NSA and FBI agents reading that text: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
Back to top
View user's profile Send private message
josh
Guru
Guru


Joined: 05 Feb 2003
Posts: 473
Location: Milky Way: Solar System: Earth: North America: USA: NY: Buffalo

PostPosted: Fri Mar 17, 2006 1:49 am    Post subject: Reply with quote

Just wanted to say that those init scripts are awesome!

I had to test it out of course. I did an 'emerge sync' and opened up firefox, openoffice, limewire and some other heavily hitters. The load went through the roof and the CPU usage for X went up to about 80 or 90 and the desktop became pretty unresponsive in general. But I could play a few songs and record in ardour without incident! And this is on my p3! I can't wait to see how many tracks I can stack on now.
_________________
-Josh
Back to top
View user's profile Send private message
Dominique_71
Veteran
Veteran


Joined: 17 Aug 2005
Posts: 1500
Location: Switzerland (Romandie)

PostPosted: Fri Apr 14, 2006 8:45 pm    Post subject: Reply with quote

The 2 files /etc/init.d/realtime and /etc/default/realtime are not needed on gentoo. It is enough to edit /etc/modules.autoload.d/kernel-2.6 <-- add realtime there

and /etc/modules.d/realtime
Code:
options realtime gid=18

We get no boot message, but the result is the same.

You will get the last file when emerging realtime-lsm, but not if you are installing this module with the rt-sources on evermind's audio-pro overlay. It is of course my favorite gentoo overlay and I recommand to install it.
_________________
[[[ To any NSA and FBI agents reading that text: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum