|
|
|
@ -3,68 +3,68 @@
|
|
|
|
|
|
|
|
|
|
# Safely apply sysctl adjustment
|
|
|
|
|
ctl() {
|
|
|
|
|
# Fetch the current key value
|
|
|
|
|
local curval=`sysctl -e -n "$1"`
|
|
|
|
|
|
|
|
|
|
# Bail out if sysctl key does not exist
|
|
|
|
|
if [[ -z "$curval" ]]
|
|
|
|
|
then
|
|
|
|
|
echo "[!] Key $1 does not exist. Skipping."
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Bail out if sysctl is already set
|
|
|
|
|
if [[ "$curval" == "$2" ]]
|
|
|
|
|
then
|
|
|
|
|
echo "[*] Key $1 is already set to $2. Skipping."
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Set the new value
|
|
|
|
|
sysctl -w "$1"="$2" &> /dev/null
|
|
|
|
|
|
|
|
|
|
# Bail out if write fails
|
|
|
|
|
if [[ $? -ne 0 ]]
|
|
|
|
|
then
|
|
|
|
|
echo "[!] Failed to write $2 to $1. Skipping."
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Print new state
|
|
|
|
|
echo "[*] $1: $curval --> $2"
|
|
|
|
|
# Fetch the current key value
|
|
|
|
|
local curval=`sysctl -e -n "$1"`
|
|
|
|
|
|
|
|
|
|
# Bail out if sysctl key does not exist
|
|
|
|
|
if [[ -z "$curval" ]]
|
|
|
|
|
then
|
|
|
|
|
echo "[!] Key $1 does not exist. Skipping."
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Bail out if sysctl is already set
|
|
|
|
|
if [[ "$curval" == "$2" ]]
|
|
|
|
|
then
|
|
|
|
|
echo "[*] Key $1 is already set to $2. Skipping."
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Set the new value
|
|
|
|
|
sysctl -w "$1"="$2" &> /dev/null
|
|
|
|
|
|
|
|
|
|
# Bail out if write fails
|
|
|
|
|
if [[ $? -ne 0 ]]
|
|
|
|
|
then
|
|
|
|
|
echo "[!] Failed to write $2 to $1. Skipping."
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Print new state
|
|
|
|
|
echo "[*] $1: $curval --> $2"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Safely write value to file
|
|
|
|
|
write() {
|
|
|
|
|
# Bail out if file does not exist
|
|
|
|
|
if [[ ! -f "$1" ]]
|
|
|
|
|
then
|
|
|
|
|
echo "[!] File $1 does not exist. Skipping."
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Fetch the current key value
|
|
|
|
|
local curval=`cat "$1"`
|
|
|
|
|
|
|
|
|
|
# Bail out if value is already set
|
|
|
|
|
if [[ "$curval" == "$2" ]]
|
|
|
|
|
then
|
|
|
|
|
echo "[*] File $1 is already set to $2. Skipping."
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Write the new value
|
|
|
|
|
echo "$2" > "$1" &> /dev/null
|
|
|
|
|
|
|
|
|
|
# Bail out if write fails
|
|
|
|
|
if [[ $? -ne 0 ]]
|
|
|
|
|
then
|
|
|
|
|
echo "[!] Failed to write $2 to $1. Skipping."
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Print new state
|
|
|
|
|
echo "[*] $1: $curval --> $2"
|
|
|
|
|
# Bail out if file does not exist
|
|
|
|
|
if [[ ! -f "$1" ]]
|
|
|
|
|
then
|
|
|
|
|
echo "[!] File $1 does not exist. Skipping."
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Fetch the current key value
|
|
|
|
|
local curval=`cat "$1"`
|
|
|
|
|
|
|
|
|
|
# Bail out if value is already set
|
|
|
|
|
if [[ "$curval" == "$2" ]]
|
|
|
|
|
then
|
|
|
|
|
echo "[*] File $1 is already set to $2. Skipping."
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Write the new value
|
|
|
|
|
echo "$2" > "$1" &> /dev/null
|
|
|
|
|
|
|
|
|
|
# Bail out if write fails
|
|
|
|
|
if [[ $? -ne 0 ]]
|
|
|
|
|
then
|
|
|
|
|
echo "[!] Failed to write $2 to $1. Skipping."
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Print new state
|
|
|
|
|
echo "[*] $1: $curval --> $2"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Print device information prior to execution
|
|
|
|
@ -89,7 +89,7 @@ echo "[*] ------------------------------"
|
|
|
|
|
echo "[*] Waiting for 60s of uptime."
|
|
|
|
|
while [[ `cat /proc/uptime | awk '{print $1}' | awk -F. '{print $1}'` -lt 60 ]]
|
|
|
|
|
do
|
|
|
|
|
sleep 1
|
|
|
|
|
sleep 1
|
|
|
|
|
done
|
|
|
|
|
echo "[*] Done waiting."
|
|
|
|
|
|
|
|
|
@ -139,61 +139,61 @@ ctl vm.watermark_scale_factor 100
|
|
|
|
|
# Scheduler features
|
|
|
|
|
if [[ -f "/sys/kernel/debug/sched_features" ]]
|
|
|
|
|
then
|
|
|
|
|
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
|
|
|
|
|
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 "${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 "${cpu}scaling_governor" interactive
|
|
|
|
|
[[ "$avail_govs" == *"schedutil"* ]] && write "${cpu}scaling_governor" schedutil
|
|
|
|
|
|
|
|
|
|
# Interactive-specific tweaks
|
|
|
|
|
if [[ -d "${cpu}interactive" ]]
|
|
|
|
|
then
|
|
|
|
|
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 "${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
|
|
|
|
|
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 "${cpu}scaling_governor" interactive
|
|
|
|
|
[[ "$avail_govs" == *"schedutil"* ]] && write "${cpu}scaling_governor" schedutil
|
|
|
|
|
|
|
|
|
|
# Interactive-specific tweaks
|
|
|
|
|
if [[ -d "${cpu}interactive" ]]
|
|
|
|
|
then
|
|
|
|
|
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 "${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 "/sys/module/cpu_boost/parameters/input_boost_freq" 1200000
|
|
|
|
|
write "/sys/module/cpu_boost/parameters/input_boost_ms" 250
|
|
|
|
|
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 /dev/stune/top-app/schedtune.prefer_idle 1
|
|
|
|
|
write /dev/stune/top-app/schedtune.prefer_idle 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# I/O
|
|
|
|
|
for queue in /sys/block/*/queue/
|
|
|
|
|
do
|
|
|
|
|
write "${queue}iostats" 0
|
|
|
|
|
write "${queue}read_ahead_kb" 0
|
|
|
|
|
write "${queue}nr_requests" 512
|
|
|
|
|
write "${queue}scheduler" noop
|
|
|
|
|
write "${queue}scheduler" none
|
|
|
|
|
write "${queue}iostats" 0
|
|
|
|
|
write "${queue}read_ahead_kb" 0
|
|
|
|
|
write "${queue}nr_requests" 512
|
|
|
|
|
write "${queue}scheduler" noop
|
|
|
|
|
write "${queue}scheduler" none
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# ZRAM
|
|
|
|
|