|
|
|
@ -37,34 +37,34 @@ ctl() {
|
|
|
|
|
# Safely write value to file
|
|
|
|
|
write() {
|
|
|
|
|
# Bail out if file does not exist
|
|
|
|
|
if [[ ! -f "$2" ]]
|
|
|
|
|
if [[ ! -f "$1" ]]
|
|
|
|
|
then
|
|
|
|
|
echo "[!] File $1 does not exist. Skipping."
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Fetch the current key value
|
|
|
|
|
local curval=`cat "$2"`
|
|
|
|
|
local curval=`cat "$1"`
|
|
|
|
|
|
|
|
|
|
# Bail out if value is already set
|
|
|
|
|
if [[ "$curval" == "$1" ]]
|
|
|
|
|
if [[ "$curval" == "$2" ]]
|
|
|
|
|
then
|
|
|
|
|
echo "[*] File $2 is already set to $1. Skipping."
|
|
|
|
|
echo "[*] File $1 is already set to $2. Skipping."
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Write the new value
|
|
|
|
|
echo "$1" > "$2"
|
|
|
|
|
echo "$2" > "$1"
|
|
|
|
|
|
|
|
|
|
# Bail out if write fails
|
|
|
|
|
if [[ $? -ne 0 ]]
|
|
|
|
|
then
|
|
|
|
|
echo "[!] Failed to write $1 to $2. Skipping."
|
|
|
|
|
echo "[!] Failed to write $2 to $1. Skipping."
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Print new state
|
|
|
|
|
echo "[*] $2: $curval --> $1"
|
|
|
|
|
echo "[*] $1: $curval --> $2"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Wait 60s into boot before applying changes
|
|
|
|
@ -77,7 +77,7 @@ echo "[*] Done waiting."
|
|
|
|
|
|
|
|
|
|
# Kernel
|
|
|
|
|
ctl kernel.perf_cpu_time_max_percent 5
|
|
|
|
|
write "off" /proc/sys/kernel/printk_devkmsg
|
|
|
|
|
write /proc/sys/kernel/printk_devkmsg off
|
|
|
|
|
ctl kernel.randomize_va_space 0
|
|
|
|
|
ctl kernel.sched_autogroup_enabled 1
|
|
|
|
|
ctl kernel.sched_child_runs_first 1
|
|
|
|
@ -122,63 +122,63 @@ ctl vm.watermark_scale_factor 100
|
|
|
|
|
# Scheduler features
|
|
|
|
|
if [[ -f "/sys/kernel/debug/sched_features" ]]
|
|
|
|
|
then
|
|
|
|
|
write "NO_GENTLE_FAIR_SLEEPERS" /sys/kernel/debug/sched_features
|
|
|
|
|
write "NEXT_BUDDY" /sys/kernel/debug/sched_features
|
|
|
|
|
write "NO_STRICT_SKIP_BUDDY" /sys/kernel/debug/sched_features
|
|
|
|
|
write "NO_NONTASK_CAPACITY" /sys/kernel/debug/sched_features
|
|
|
|
|
write "TTWU_QUEUE" /sys/kernel/debug/sched_features
|
|
|
|
|
write /sys/kernel/debug/sched_features NO_GENTLE_FAIR_SLEEPER
|
|
|
|
|
write /sys/kernel/debug/sched_features NEXT_BUDDY
|
|
|
|
|
write /sys/kernel/debug/sched_features NO_STRICT_SKIP_BUDDY
|
|
|
|
|
write /sys/kernel/debug/sched_features NO_NONTASK_CAPACITY
|
|
|
|
|
write /sys/kernel/debug/sched_features TTWU_QUEUE
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# CPU
|
|
|
|
|
for cpu in /sys/devices/system/cpu/cpu*/cpufreq/
|
|
|
|
|
do
|
|
|
|
|
write `cat "${cpu}cpuinfo_min_freq"` "${cpu}scaling_min_freq"
|
|
|
|
|
write `cat "${cpu}cpuinfo_max_freq"` "${cpu}scaling_max_freq"
|
|
|
|
|
write "${cpu}scaling_min_freq" `cat "${cpu}cpuinfo_min_freq"`
|
|
|
|
|
write "${cpu}scaling_max_freq" `cat "${cpu}cpuinfo_max_freq"`
|
|
|
|
|
|
|
|
|
|
avail_govs=`cat "${cpu}scaling_available_governors"`
|
|
|
|
|
[[ "$avail_govs" == *"interactive"* ]] && write "interactive" "${cpu}scaling_governor"
|
|
|
|
|
[[ "$avail_govs" == *"schedutil"* ]] && write "schedutil" "${cpu}scaling_governor"
|
|
|
|
|
[[ "$avail_govs" == *"interactive"* ]] && write "${cpu}scaling_governor" interactive
|
|
|
|
|
[[ "$avail_govs" == *"schedutil"* ]] && write "${cpu}scaling_governor" schedutil
|
|
|
|
|
|
|
|
|
|
# Interactive-specific tweaks
|
|
|
|
|
if [[ -d "${cpu}interactive" ]]
|
|
|
|
|
then
|
|
|
|
|
write 80 "${cpu}interactive/go_hispeed_load"
|
|
|
|
|
write `cat "${cpu}cpuinfo_max_freq"` "${cpu}interactive/hispeed_freq"
|
|
|
|
|
write "${cpu}interactive/go_hispeed_load" 80
|
|
|
|
|
write "${cpu}interactive/hispeed_freq" `cat "${cpu}cpuinfo_max_freq"`
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Schedutil-specific tweaks
|
|
|
|
|
if [[ -d "${cpu}schedutil" ]]
|
|
|
|
|
then
|
|
|
|
|
write 0 "${cpu}schedutil/up_rate_limit_us"
|
|
|
|
|
write 0 "${cpu}schedutil/down_rate_limit_us"
|
|
|
|
|
write 80 "${cpu}schedutil/hispeed_load"
|
|
|
|
|
write `cat "${cpu}cpuinfo_max_freq"` "${cpu}schedutil/hispeed_freq"
|
|
|
|
|
write "${cpu}schedutil/up_rate_limit_us" 0
|
|
|
|
|
write "${cpu}schedutil/down_rate_limit_us" 0
|
|
|
|
|
write "${cpu}schedutil/hispeed_load" 80
|
|
|
|
|
write "${cpu}schedutil/hispeed_freq" `cat "${cpu}cpuinfo_max_freq"`
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# CAF CPU boost
|
|
|
|
|
if [[ -d "/sys/module/cpu_boost" ]]
|
|
|
|
|
then
|
|
|
|
|
write 1200000 "/sys/module/cpu_boost/parameters/input_boost_freq"
|
|
|
|
|
write 250 "/sys/module/cpu_boost/parameters/input_boost_ms"
|
|
|
|
|
write "/sys/module/cpu_boost/parameters/input_boost_freq" 1200000
|
|
|
|
|
write "/sys/module/cpu_boost/parameters/input_boost_ms" 250
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Stune
|
|
|
|
|
if [[ -d "/dev/stune" ]]
|
|
|
|
|
then
|
|
|
|
|
write 1 /dev/stune/top-app/schedtune.prefer_idle
|
|
|
|
|
write /dev/stune/top-app/schedtune.prefer_idle 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# I/O
|
|
|
|
|
for queue in /sys/block/*/queue/
|
|
|
|
|
do
|
|
|
|
|
write 0 "${queue}iostats"
|
|
|
|
|
write 0 "${queue}read_ahead_kb"
|
|
|
|
|
write 512 "${queue}nr_requests"
|
|
|
|
|
write "${queue}iostats" 0
|
|
|
|
|
write "${queue}read_ahead_kb" 0
|
|
|
|
|
write "${queue}nr_requests" 512
|
|
|
|
|
|
|
|
|
|
avail_scheds=`cat "${queue}scheduler"`
|
|
|
|
|
[[ "$avail_scheds" == *"noop"* ]] && write "noop" "${queue}scheduler"
|
|
|
|
|
[[ "$avail_scheds" == *"none"* ]] && write "none" "${queue}scheduler"
|
|
|
|
|
[[ "$avail_scheds" == *"noop"* ]] && write "${queue}scheduler" noop
|
|
|
|
|
[[ "$avail_scheds" == *"none"* ]] && write "${queue}scheduler" none
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo "[*] Done."
|