builds and runs on intel-x86 and rpi4 with acceptable realtime performance

This commit is contained in:
vaughn committed 2026-09-25 17:29:14 -04:00
1 parent 2bce6fa556
commit 3faf544f0b
120 files changed
+6317 -1

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+71
View File
@@ -0,0 +1,71 @@
#!/bin/bash
#### BEGIN INIT INFO
# PROVIDES: realtime environment setup
# Required-Start:
# Required-Stop:
# Default-Start: S
# Short-Description: Isolate RT Cores
### END INIT INFO
#total number of physical cores
#N_TOT=$(( $(lscpu | awk '/^Socket\(s\)/{ print $2 }') * $(lscpu | awk '/^Core\(s\) per socket/{ print $4 }') ))
#requested number of realtime cores
#N_RT_REQ=1
#if [ "$#" >= "1" ]; then
# N_RT_REQ=$1
#fi
REALTIME_RESTART_THRESHOLD=1
RESTART_FILE="/var/tmp/realtime_setup_restarts"
GRUB_FILE="/boot/EFI/BOOT/grub.cfg"
GRUB_LINUX_CFG="/etc/grub.d/10_linux"
touch /var/tmp/realtime_setup_restarts
num_restarts=$(cat "$RESTART_FILE" | tr -dc '0-9')
curProfile=$(tuned-adm active | grep "realtime")
#TODO use tuned-adm verify instead, as active profile doesn't mean it has all parameters set correctly
if [[ -z "$num_restarts" ]] || [[ ! -z "$curProfile" ]]; then
num_restarts=0
echo "0" > $RESTART_FILE
fi
if [[ -z "$curProfile" ]] && (( $num_restarts <= $REALTIME_RESTART_THRESHOLD )); then
#TODO actually check grub file and only overwrite if it is not generated by grub-mkconfig
echo "updating GRUB file: $GRUB_FILE"
sed -i 's/GRUB_DISABLE_LINUX_PARTUUID=true/GRUB_DISABLE_LINUX_PARTUUID=false/g' $GRUB_LINUX_CFG
grub-mkconfig > $GRUB_FILE
sed -i '/\tload_video/d' $GRUB_FILE
sed -i '/gzio/d' $GRUB_FILE
sed -i '/echo/d' $GRUB_FILE
tuned-adm profile realtime
num_restarts=$((num_restarts+1))
echo "$num_restarts" > $RESTART_FILE
systemctl reboot --message="applied realtime profile; rebooting"
fi
if (( $num_restarts > $REALTIME_RESTART_THRESHOLD )); then
echo "unable to set real-time Tuned profile after $num_restarts system restarts"
return 1
fi
echo 0 > /sys/devices/system/machinecheck/machinecheck0/check_interval
#TODO the following should really adjust dynamically based on the actual cores allocated by tuned
pqos -R
pqos -e 'l2:0=0x0f;l2:1=0xf0'
pqos -a 'llc:0=0,1;llc:2=2,3'
for i in $(cat /proc/interrupts | grep '^ *[0-9]*[0-9]:' | awk {'print $1'} | sed 's/:$//');
do
if [ "$i" = "0" ]; then
continue
fi
if [ "$i" = "2" ]; then
continue
fi
echo 1 > /proc/irq/$i/smp_affinity
done
for i in $(pgrep rcu);
do
flags=$(cut -f 9 -d ' ' /proc/$i/stat)
if [ ! $((flags & 0x04000000)) ]; then
taskset -pc 0 $i > /dev/null
fi
done
+8
View File
@@ -0,0 +1,8 @@
[Unit]
Description=Initialize RT Cores
[Service]
ExecStart=/bin/bash /usr/bin/rt-setup
[Install]
WantedBy=multi-user.target