aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/realtime-suggestions105
1 files changed, 67 insertions, 38 deletions
diff --git a/bin/realtime-suggestions b/bin/realtime-suggestions
index cf5f599..fa0c82e 100755
--- a/bin/realtime-suggestions
+++ b/bin/realtime-suggestions
@@ -5,7 +5,10 @@ set -euo pipefail
warning="WARNING:"
change="CHANGE:"
info="INFO:"
-kernel_config="/proc/config.gz"
+
+kernel_release=""
+kernel_config=""
+
sysctl_ref="(see \`man 5 sysctl.conf\`, \`man 5 sysctl.d\` or \`man 8 sysctl\` for reference)"
check_root() {
@@ -22,6 +25,43 @@ check_kernel_name() {
fi
}
+get_kernel_config_location() {
+ local default_location="/proc/config.gz"
+ local boot_location="/boot/config-${kernel_release}"
+ if [ -r "${default_location}" ]; then
+ echo "${default_location}"
+ return
+ elif [ -r "${boot_location}" ]; then
+ echo "${boot_location}"
+ return
+ else
+ echo ""
+ return
+ fi
+}
+
+kernel_config_has() {
+ local config="$1"
+ local grep_cmd="zgrep"
+ if [[ "${kernel_config}" != *.gz ]]; then
+ grep_cmd="grep"
+ fi
+ if $grep_cmd -q "$config" "$kernel_config"; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+kernel_cmdline_has() {
+ local search="$1"
+ if ! grep -q "${search}" /proc/cmdline; then
+ return 1
+ else
+ return 0
+ fi
+}
+
check_virtualization() {
local virt_type=""
if command -v systemd-detect-virt >/dev/null 2>&1; then
@@ -124,56 +164,38 @@ check_cpu_governor() {
check_config_high_res_timers() {
local config="CONFIG_HIGH_RES_TIMERS=y"
local config_ref="(see \`man 7 time\` for reference)"
- if [ -e "${kernel_config}" ]; then
- if ! zgrep -q "$config" "$kernel_config"; then
- echo "$change CONFIG_HIGH_RES_TIMERS needs to be activated for your kernel $config_ref."
- fi
- else
- echo "$change $kernel_config could not be found or accessed."
+ if ! kernel_config_has "$config"; then
+ echo "$change CONFIG_HIGH_RES_TIMERS needs to be activated for your kernel $config_ref."
fi
}
check_config_no_hz() {
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
- for config in "${configs[@]}"; do
- if ! zgrep -q "$config" "$kernel_config"; then
- echo "$change $config needs to be set for your kernel for 'dynamic ticks' support $config_ref."
- fi
- done
- else
- echo "$change $kernel_config could not be found or accessed."
- fi
+ for config in "${configs[@]}"; do
+ if ! kernel_config_has "$config"; then
+ echo "$change $config needs to be set for your kernel for 'dynamic ticks' support $config_ref."
+ fi
+ done
}
check_config_preempt_rt() {
- local config1="CONFIG_PREEMPT_RT=y"
- local config2="CONFIG_PREEMPT_RT_FULL=y"
+ local configs=( 'CONFIG_PREEMPT_RT=y' 'CONFIG_PREEMPT_RT_FULL=y' )
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 "$change The PREEMPT_RT patch set is not available on your kernel $config_ref."
- fi
- else
- echo "$change $kernel_config could not be found or accessed."
+ if ! kernel_config_has "${configs[0]}" && ! kernel_config_has "${configs[1]}"; then
+ echo "$change The PREEMPT_RT patch set (${configs[*]}) is not available on your kernel $config_ref."
fi
}
check_config_irq_forced_threading() {
- local config1="CONFIG_PREEMPT=y"
- local config2="CONFIG_IRQ_FORCED_THREADING=y"
+ local configs=( 'CONFIG_IRQ_FORCED_THREADING=y' 'CONFIG_PREEMPT=y' )
local config_ref="(see https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html for reference)"
- 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 "$change Without $config1 on your kernel, you can still use the threadirqs kernel parameter $config_ref."
- fi
+ if ! kernel_config_has "${configs[0]}"; then
+ if kernel_config_has "${configs[1]}" && ! kernel_cmdline_has "threadirqs"; then
+ echo "$change Without ${configs[0]} but with ${configs[1]} support on your kernel, you can still use the threadirqs kernel parameter $config_ref."
else
- echo "$change Use a kernel with $config2 $config_ref."
+ echo "$change Your kernel neither supports ${configs[0]} nor ${configs[1]}."
fi
- else
- echo "$change $kernel_config could not be found or accessed."
fi
}
@@ -228,6 +250,17 @@ check_for_useful_tools() {
check_kernel_name
check_root
check_virtualization
+kernel_release=$(uname -r)
+kernel_config=$(get_kernel_config_location)
+if [ -n "${kernel_config}" ]; then
+ check_config_high_res_timers
+ check_config_no_hz
+ check_config_preempt_rt
+ check_config_irq_forced_threading
+else
+ echo "$warning The kernel config could not be found or accessed (e.g. /proc/config.gz or below /boot/config-*)."
+fi
+
check_filesystems
check_groups
check_ulimits
@@ -236,10 +269,6 @@ check_legacy_timers
check_vm_swappiness
check_cpu_governor
check_cpu_dma_latency
-check_config_high_res_timers
-check_config_no_hz
-check_config_preempt_rt
-check_config_irq_forced_threading
check_coupled_interrupts
check_irqbalance
check_for_useful_tools