[PlanetCCRMA] rt session permissions

Simon Lewis simon.lewis at slnet-online.de
Thu May 23 12:48:47 PDT 2013


As a prologue, there is tons of advice on the internet for configuring 
audio on linux, but it's like wiki and life in general, 95% rubbish and 
the truth is hidden in the other 5%.

Never-the-less, occasionally a neat little tweak comes along that 
actually works. It would be useful to gather these tweaks in a single 
package that can be cleanly installed, upgraded and removed over the 
package management and where the necessary services are automatically 
stated on booting the system.

Fernando has already started this with "planetccrma-rt-permissions 
<http://ccrma.stanford.edu/planetccrma/mirror/fedora/linux/planetccrma/18/x86_64/repoview/planetccrma-rt-permissions.html>. 
I've added a few more and included a corresponding rpm spec file .

I'm just a user and not a programmer and I am sure you know other and 
probably better ways of doing this. But on my two systems it works, it 
is here and is now. At least Quickscan from Brendan Jones' 
"realTimeConfigQuickScan" package gives lots of green ticks.

Any suggestions for more tricks and better ways of doing things are welcome

Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ccrma-mail.stanford.edu/pipermail/planetccrma/attachments/20130523/4be43357/attachment.html 
-------------- next part --------------
# There are very few applications left that directly use the /dev/rtc and 
# /dev/hpet device nodes. Most applications use the high resolution timer that 
# is provided by the kernel. So basically using the settings described below 
# has become somewhat obsoleted.
#
# MIDI sequencers and such will benefit from being able to use hardware 
# timers like the real-time clock (/dev/rtc) or the High Precision Event 
# Timer (/dev/hpet).

KERNEL=="rtc0", GROUP="jackuser", MODE="0660"
KERNEL=="hpet", GROUP="jackuser", MODE="0660"
-------------- next part --------------
# There are references on the net on adjusting the fs.inotify.max_user_watches 
# value also for enhanced performance. But it remains very unclear where these 
# references come from and if adjusting this value actually does anything at all. 
 
fs.inotify.max_user_watches = 524288
-------------- next part --------------
# There's no consensus on what values to use here!
# 
# Most sources mention a minimal value of at least 1024 or even 2048 and 
# a maximal setting of 8192. 
# 
# The max user freq setting for hpet can be set in /etc/sysctl.conf . 
# 
# The setting for rtc0 can be set with an echo command at boot-time with 
# either a start-up script or adding a line to /etc/rc.local.  

dev.hpet.max-user-freq=3072 
-------------- next part --------------
#
# /etc/udev/rules.d/60-schedulers.rules
#

# set deadline scheduler for non-rotating disks
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"

# set cfq scheduler for rotating disks
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="cfq"
-------------- next part --------------
# This setting changes the so-called swappiness of your system, or in other 
# words, the moment when your system starts to use its swap partition  

vm.swappiness = 10
vm.vfs_cache_pressure=50

-------------- next part --------------
# allow users in the jack-user group access to high realtime scheduling and 
# memory locking
#
# fc <= 17 : @jackuser - rtprio 70
# fc <= 17 : @jackuser - memlock 4194304

@jackuser - rtprio 99
@jackuser - memlock unlimited

-------------- next part --------------
A non-text attachment was scrubbed...
Name: rtc0.sh
Type: application/x-shellscript
Size: 191 bytes
Desc: not available
Url : http://ccrma-mail.stanford.edu/pipermail/planetccrma/attachments/20130523/4be43357/attachment.bin 
-------------- next part --------------
#!/bin/bash
#
# Set realtime and memory locking permissions when sessions change state
#
# (C)2011 Fernando Lopez-Lezcano
#

# gets called with a single argument:
#
#  session_added
#  session_removed
#  session_active_changed
#
EVENT="${1}"

# ignore uids lower than this one
LOWUID=500

# max rt priority allowed
MAXPRIO=70
# max memory that can be locked
MAXMEM=4194304

if [ $CK_SESSION_USER_UID -lt $LOWUID ] ; then
    exit 0
fi

# only for local sessions
if [ "$CK_SESSION_IS_LOCAL" = "true" ] ; then
    if [ "${EVENT}" = "session_added" ] ; then
        ulimit -r ${MAXPRIO}
        ulimit -l ${MAXMEM}
    elif [ "${EVENT}" = "session_removed" ] ; then
        ulimit -r 0
        ulimit -l 0
    elif [ "${EVENT}" = "session_active_changed" ] ; then
        # take care of a session that changes state
        if [ "${CK_SESSION_IS_ACTIVE}" = "true" ] ; then
    	    ulimit -r ${MAXPRIO}
	    ulimit -l ${MAXMEM}
	else
    	    ulimit -r 0
	    ulimit -l 0
        fi
    else
        # unrecognized argument, should be an error
        exit 0
    fi
fi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rt-permissions-session.spec
Type: text/x-rpm-spec
Size: 3881 bytes
Desc: not available
Url : http://ccrma-mail.stanford.edu/pipermail/planetccrma/attachments/20130523/4be43357/attachment-0001.bin 


More information about the PlanetCCRMA mailing list