diff options
-rwxr-xr-x | bin/realtime-suggestions | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/bin/realtime-suggestions b/bin/realtime-suggestions index 2852476..632825a 100755 --- a/bin/realtime-suggestions +++ b/bin/realtime-suggestions @@ -2,7 +2,7 @@ set -euo pipefail -warning="WARNING:" +change="CHANGE:" info="INFO:" kernel_config="/proc/config.gz" sysctl_ref="(see \`man 5 sysctl.conf\`, \`man 5 sysctl.d\` or \`man 8 sysctl\` for reference)" @@ -30,7 +30,7 @@ check_filesystems() { options="${mount_point_data[5]}" if [[ "$where" != /boot* ]]; then if [[ "$options" != *relatime* ]] && [[ "$options" != *noatime* ]]; then - echo "$warning $what mounted on $where (type $type) should use the relatime mount option for performance." + echo "$change $what mounted on $where (type $type) should use the relatime mount option for performance." fi if [[ "$type" == *fuse* ]] || [[ "$type" == *reiserfs* ]] || [[ "$type" == *vfat* ]]; then echo "$info $what mounted on $where (type $type) is not a good filesystem for large files or realtime use." @@ -43,7 +43,7 @@ check_groups() { local groups="" groups=$(groups) if [[ "$groups" != *audio* ]]; then - echo "$warning Add your user to the audio group. It's used for access to audio devices on most distros." + echo "$change Add your user to the audio group. It's used for access to audio devices on most distros." fi if [[ "$groups" != *realtime* ]]; then echo "$info Some distributions use the realtime group for elevated resource limits." @@ -53,13 +53,13 @@ check_groups() { check_ulimits() { local limits_ref="(see \`man limits.conf\` for reference)" if [[ "$(ulimit -t)" != "unlimited" ]]; then - echo "$warning The CPU limit for your user is not unlimited $limits_ref." + echo "$change The CPU limit for your user is not unlimited $limits_ref." fi if [[ "$(ulimit -l)" != "unlimited" ]]; then - echo "$warning The locked-in-memory limit for your user is not unlimited $limits_ref." + echo "$change The locked-in-memory limit for your user is not unlimited $limits_ref." fi if [ "$(ulimit -r)" -le 50 ]; then - echo "$warning The maximum rt priority for your user ($(ulimit -r)) is very low. Consider increasing it up to 98 $limits_ref." + echo "$change The maximum rt priority for your user ($(ulimit -r)) is very low. Consider increasing it up to 98 $limits_ref." fi } @@ -67,7 +67,7 @@ check_vm_swappiness() { local minimum=10 local proc_file="/proc/sys/vm/swappiness" if [ "$(cat "$proc_file")" -gt $minimum ]; then - echo "$warning Consider decreasing 'vm.swappiness<=$minimum' to prevent early write to swap $sysctl_ref." + echo "$info Consider decreasing 'vm.swappiness<=$minimum' to prevent early write to swap $sysctl_ref." fi } @@ -75,7 +75,7 @@ check_max_user_watches() { local minimum=524288 local proc_file="/proc/sys/fs/inotify/max_user_watches" if [ "$(cat "$proc_file")" -lt $minimum ]; then - echo "$warning Consider increasing 'fs.inotify.max_user_watches>$minimum' - the maximum amount of files inotify can watch $sysctl_ref" + echo "$change Consider increasing 'fs.inotify.max_user_watches>$minimum' - the maximum amount of files inotify can watch $sysctl_ref" fi } @@ -89,7 +89,7 @@ check_cpu_governor() { policy_no="$(echo "$governor_file"| cut -d'/' -f7)" cpu_no="${policy_no//policy}" if [[ "$governor" != "performance" ]]; then - echo "$warning CPU $cpu_no has governor $governor set. Set it to 'performance' $cpupower_ref." + echo "$change CPU $cpu_no has governor $governor set. Set it to 'performance' $cpupower_ref." fi done } @@ -99,26 +99,24 @@ check_config_high_res_timers() { local config_ref="(see \`man 7 time\` for reference)" if [ -e "${kernel_config}" ]; then if ! zgrep -q "$config" "$kernel_config"; then - echo "$warning CONFIG_HIGH_RES_TIMERS needs to be activated for your kernel $config_ref." + echo "$change CONFIG_HIGH_RES_TIMERS needs to be activated for your kernel $config_ref." fi else - echo "$warning $kernel_config could not be found or accessed." + echo "$change $kernel_config could not be found or accessed." fi } check_config_no_hz() { - local config1="CONFIG_NO_HZ_IDLE=y" - local config2="CONFIG_NO_HZ=y" + local configs=( 'CONFIG_NO_HZ_COMMON=y' 'CONFIG_NO_HZ_FULL=y' 'CONFIG_NO_HZ=y') local config_ref="(see https://elinux.org/Kernel_Timer_Systems#Dynamic_ticks for reference)" if [ -e "${kernel_config}" ]; then - if ! zgrep -q "$config1" "$kernel_config"; then - echo "$warning $config1 needs to be set for your kernel for 'dynamic ticks' support $config_ref." - fi - if ! zgrep -q "$config2" "$kernel_config"; then - echo "$warning $config2 needs to be set for your kernel for 'dynamic ticks' support $config_ref." - fi + for config in "${configs[@]}"; do + if ! zgrep -q "$config" "$kernel_config"; then + echo "$change $config1 needs to be set for your kernel for 'dynamic ticks' support $config_ref." + fi + done else - echo "$warning $kernel_config could not be found or accessed." + echo "$change $kernel_config could not be found or accessed." fi } @@ -128,10 +126,10 @@ check_config_preempt_rt() { local config_ref="(see https://wiki.linuxfoundation.org/realtime for reference)" if [ -e "${kernel_config}" ]; then if ! zgrep -q "$config1" "$kernel_config" && ! zgrep -q "$config2" "$kernel_config"; then - echo "$warning The PREEMPT_RT patch set is not available on your kernel $config_ref." + echo "$change The PREEMPT_RT patch set is not available on your kernel $config_ref." fi else - echo "$warning $kernel_config could not be found or accessed." + echo "$change $kernel_config could not be found or accessed." fi } @@ -142,13 +140,13 @@ check_config_irq_forced_threading() { if [ -e "${kernel_config}" ]; then if zgrep -q "$config2" "$kernel_config"; then if ! zgrep -q "$config1" "$kernel_config" && ! grep -q "threadirqs" /proc/cmdline; then - echo "$warning Without $config1 on your kernel, you can still use the threadirqs kernel parameter $config_ref." + echo "$change Without $config1 on your kernel, you can still use the threadirqs kernel parameter $config_ref." fi else - echo "$warning Use a kernel with $config2 $config_ref." + echo "$change Use a kernel with $config2 $config_ref." fi else - echo "$warning $kernel_config could not be found or accessed." + echo "$change $kernel_config could not be found or accessed." fi } @@ -167,7 +165,7 @@ check_legacy_timers() { check_cpu_dma_latency() { local dev_file="/dev/cpu_dma_latency" if [ ! -w "$dev_file" ]; then - echo "$warning $dev_file needs to be writable by your user to prevent deep CPU sleep states." + echo "$change $dev_file needs to be writable by your user to prevent deep CPU sleep states." fi } @@ -180,14 +178,14 @@ check_coupled_interrupts() { for interrupt_line in "${interrupts[@]}"; do interrupt_number="$(echo "$interrupt_line"| cut -d':' -f1)" if [[ "$interrupt_line" == *"$interrupt_delim"* ]]; then - echo "$warning IRQ$interrupt_number has coupled interrupts $interrupt_ref." + echo "$change IRQ$interrupt_number has coupled interrupts $interrupt_ref." fi done } check_irqbalance() { if pgrep -i irqbalance >/dev/null 2>&1; then - echo "$warning The irqbalance service is running on your system. It might interfere, so consider disabling it." + echo "$change The irqbalance service is running on your system. It might interfere, so consider disabling it." fi } |