Rather than starting a new thread about jitter mitigation, I'm just going to add it here.
First, I'm keeping in mind that Peter Wallace said "
The jitter is basically unimportant with a 7C81 unless its so bad you
get real time errors at the normal servo thread rate
."
I'm also treating the Raspberry Pi + 7C81 as a dedicated controller, not a PC. By that I mean I'm not going to be doing anything on the Pi except LinuxCNC. I may turn on WIFI to update packages, or use email to transfer a file. But I plan to even turn off WIFI before I launch LinuxCNC.
I ran several tests to see which combination of settings offered the most optimized jitter. I ran two Glxgears for all tests as I though that was reasonable, and ran the tests for long periods of time unless they looked bad early on.
I thought that turning off all unused services would decrease Jitter. So I turned off 9 of the 23 services, such as CUPS, Bluetooth, etc. To my surprise this did not decrease jitter.
Screen blank increased jitter a bit, so I turned that off. It doesn't make much sense anyway on a CNC controller.
These are the settings I added to the line already in /boot/firmware/cmdline.txt:
skew_tick=1 kthread_cpus=0-2 irqaffinity=0-2 rcu_nocb_poll rcu_nocbs=3 nohz=on nohz_full=3 isolcpus=3
I tried a few others that some people recommended on various blogs. Nothing else I tried had any noticeable positive impact on jitter, and some noticeably slowed down the responsiveness of the Pi.
Turning off timer_migration did reduce jitter. What I read said that you could make this setting permanent by adding it to the boot command line, or setting it in either of two different system files. Oddly none of that worked. So I setup a cron job to disable it at boot, and that works.
Add the following line:
@reboot sudo sysctl kernel.timer_migration=0
The other thing that helped reduce jitter was changing the scheduling policy to real-time and increasing the priority. I decided to create a shell script to launch latency-histogram, and eventually linuxcnc, which changes these things on the process.
#!/bin/bash
#
# Run with the SCHED_RR real-time policy at the highest priority level (99)
# Uses chrt to switch the process policy and priority immediately after launch.
#
# Gene Weber - January 2025
#
# "The difference between SCHED_FIFO and SCHED_RR is that among tasks with the same priority,
# SCHED_RR performs a round-robin with a certain timeslice; SCHED_FIFO, instead, needs the task
# to explicitly yield the processor." -Claudio
priority=99
# Truncate $1 (the command) to 15 characters starting at 0.
command=${1:0:15}
# Execute the command line provided to rrt as a background task.
`$@` &
# Get the process ID of the command.
PID=`pgrep $command`
# Change the real-time policy to SCHED_FIFO with a priority of $priority.
sudo chrt -r -p $priority $PID
I named it rrt (run real-time). So to launch latency-histogram it's simply:
rrt latency-histogram --nobase --sbins 1000
All spawned sub-processes inherit the policy and priority. So if linuxcnc is launched with rrt:
all of the processes that are part of LinuxCNC have the policy of SCHED_RR and priority of 99. I used Round Robin scheduling to make sure no LinuxCNC process "starves" another.
I don't know if this will work in the end, but I'm going to give it a try. Nothing ventured, nothing gained.
Implementing all of these, here is the jitter histogram. Good enough.