IP : 18.116.88.34Hostname : host45.registrar-servers.comKernel : Linux host45.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64Disable Function : None :) OS : Linux
PATH:
/
home/
../
lib/
.build-id/
fa/
../
b3/
../
../
sysusers.d/
../
tuned/
functions/
/
# # This is library of helper functions that can be used in scripts in tuned profiles. # # API provided by this library is under heavy development and could be changed anytime #
# if there is no kernel command line elevator settings, apply the elevator if [ "$1" -a "$SYS_BLOCK_SDX" ]; then for i in $SYS_BLOCK_SDX; do se_dev="`echo \"$i\" | sed 's|/sys/block/\([^/]\+\)/queue/scheduler|\1|'`" $1 "elevator_${se_dev}" "$i" "$3" done fi }
# SATA Aggressive Link Power Management # usage: set_disk_alpm policy set_disk_alpm() { policy=$1
for host in /sys/class/scsi_host/*; do if [ -f $host/ahci_port_cmd ]; then port_cmd=`cat $host/ahci_port_cmd`; if [ $((0x$port_cmd & 0x240000)) = 0 -a -f $host/link_power_management_policy ]; then echo $policy >$host/link_power_management_policy; else echo "max_performance" >$host/link_power_management_policy; fi fi done }
# usage: set_disk_apm level set_disk_apm() { level=$1 for disk in $DISKS_DEV; do hdparm -B $level $disk &>/dev/null done }
# usage: set_disk_spindown level set_disk_spindown() { level=$1 for disk in $DISKS_DEV; do hdparm -S $level $disk &>/dev/null done }
# usage: multiply_disk_readahead by multiply_disk_readahead() { by=$1
# float multiplication not supported in bash # bc might not be installed, python is available for sure
for disk in $DISKS_SYS; do control="${disk}/queue/read_ahead_kb" old=$(cat $control) new=$(echo "print int($old*$by)" | python)
set_disk_scheduler_quantum() { value=$1 rm -f "$DISK_QUANTUM_SAVE" for disk in $DISKS_SYS; do control="${disk}/queue/iosched/quantum" echo "echo $(cat $control) > $control" >> "$DISK_QUANTUM_SAVE" 2>/dev/null (echo $value > $control) &2>/dev/null done }
restore_disk_scheduler_quantum() { if [ -r "$DISK_QUANTUM_SAVE" ]; then /bin/bash "$DISK_QUANTUM_SAVE" &>/dev/null rm -f "$DISK_QUANTUM_SAVE" fi }
# # CPU tuning #
CPUSPEED_SAVE_FILE="${STORAGE}/cpuspeed${STORAGE_SUFFIX}" CPUSPEED_ORIG_GOV="${STORAGE}/cpuspeed-governor-%s${STORAGE_SUFFIX}" CPUSPEED_STARTED="${STORAGE}/cpuspeed-started" CPUSPEED_CFG="/etc/sysconfig/cpuspeed" CPUSPEED_INIT="/etc/rc.d/init.d/cpuspeed" # do not use cpuspeed CPUSPEED_USE="0" CPUS="$(ls -d1 /sys/devices/system/cpu/cpu* | sed 's;^.*/;;' | grep "cpu[0-9]\+")"
# set CPU governor setting and store the old settings # usage: set_cpu_governor governor set_cpu_governor() { governor=$1
# always patch cpuspeed configuration if exists, if it doesn't exist and is enabled, # explicitly disable it with hint if [ -e $CPUSPEED_INIT ]; then if [ ! -e $CPUSPEED_SAVE_FILE -a -e $CPUSPEED_CFG ]; then cp -p $CPUSPEED_CFG $CPUSPEED_SAVE_FILE sed -e 's/^GOVERNOR=.*/GOVERNOR='$governor'/g' $CPUSPEED_SAVE_FILE > $CPUSPEED_CFG fi else if [ "$CPUSPEED_USE" = "1" ]; then echo >&2 echo "Suggestion: install 'cpuspeed' package to get best tuning results." >&2 echo "Falling back to sysfs control." >&2 echo >&2 fi
CPUSPEED_USE="0" fi
if [ "$CPUSPEED_USE" = "1" ]; then service cpuspeed status &> /dev/null [ $? -eq 3 ] && touch $CPUSPEED_STARTED || rm -f $CPUSPEED_STARTED
service cpuspeed restart &> /dev/null
# direct change using sysfs elif [ -e /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ]; then
for cpu in $CPUS; do gov_file=/sys/devices/system/cpu/$cpu/cpufreq/scaling_governor save_file=$(printf $CPUSPEED_ORIG_GOV $cpu) rm -f $save_file if [ -e $gov_file ]; then cat $gov_file > $save_file echo $governor > $gov_file fi done fi }
# re-enable previous CPU governor settings # usage: restore_cpu_governor restore_cpu_governor() { if [ -e $CPUSPEED_INIT ]; then if [ -e $CPUSPEED_SAVE_FILE ]; then cp -fp $CPUSPEED_SAVE_FILE $CPUSPEED_CFG rm -f $CPUSPEED_SAVE_FILE fi
if [ "$CPUSPEED_USE" = "1" ]; then if [ -e $CPUSPEED_STARTED ]; then service cpuspeed stop &> /dev/null else service cpuspeed restart &> /dev/null fi fi if [ -e $CPUSPEED_STARTED ]; then rm -f $CPUSPEED_STARTED fi else CPUSPEED_USE="0" fi
if [ "$CPUSPEED_USE" != "1" -a -e /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ]; then for cpu in $CPUS; do cpufreq_dir=/sys/devices/system/cpu/$cpu/cpufreq save_file=$(printf $CPUSPEED_ORIG_GOV $cpu)
if [ -e $cpufreq_dir/scaling_governor ]; then if [ -e $save_file ]; then cat $save_file > $cpufreq_dir/scaling_governor rm -f $save_file else echo userspace > $cpufreq_dir/scaling_governor cat $cpufreq_dir/cpuinfo_max_freq > $cpufreq_dir/scaling_setspeed fi fi done fi }
enable_transparent_hugepages() { if [ -e $THP_ENABLE ]; then cut -f2 -d'[' $THP_ENABLE | cut -f1 -d']' > $THP_SAVE (echo always > $THP_ENABLE) &> /dev/null fi }
restore_transparent_hugepages() { if [ -e $THP_SAVE ]; then (echo $(cat $THP_SAVE) > $THP_ENABLE) &> /dev/null rm -f $THP_SAVE fi }
# # WIFI tuning #
# usage: _wifi_set_power_level level _wifi_set_power_level() { # 0 auto, PM enabled # 1-5 least savings and lowest latency - most savings and highest latency # 6 disable power savings level=$1
# do not report errors on systems with no wireless [ -e /proc/net/wireless ] || return 0
# apply the settings using iwpriv ifaces=$(cat /proc/net/wireless | grep -v '|' | sed 's@^ *\([^:]*\):.*@\1@') for iface in $ifaces; do iwpriv $iface set_power $level done
# some adapters may rely on sysfs for i in /sys/bus/pci/devices/*/power_level; do (echo $level > $i) &> /dev/null done }
irqbalance_banned_cpus_clear() { sed -i '/^IRQBALANCE_BANNED_CPUS=/d' /etc/sysconfig/irqbalance || return if [ ${1:-restart} = restart ]; then systemctl try-restart irqbalance fi }
irqbalance_banned_cpus_setup() { irqbalance_banned_cpus_clear norestart if [ -n "$1" ]; then echo "IRQBALANCE_BANNED_CPUS=$1" >> /etc/sysconfig/irqbalance fi systemctl try-restart irqbalance }
# # HARDWARE SPECIFIC tuning #
# Asus EEE with Intel Atom _eee_fsb_control() { value=$1 if [ -e /sys/devices/platform/eeepc/she ]; then echo $value > /sys/devices/platform/eeepc/she elif [ -e /sys/devices/platform/eeepc/cpufv ]; then echo $value > /sys/devices/platform/eeepc/cpufv elif [ -e /sys/devices/platform/eeepc-wmi/cpufv ]; then echo $value > /sys/devices/platform/eeepc-wmi/cpufv fi }
disable_ksm() { if [ ! -f $KSM_MASK_FILE ]; then # Always create $KSM_MASK_FILE, since we don't want to # run any systemctl commands during boot if ! touch $KSM_MASK_FILE; then die "failed to create $KSM_MASK_FILE" fi # Do not run any systemctl commands if $KSM_SERVICES units do not exist systemctl cat -- $KSM_SERVICES &> /dev/null || return 0 systemctl --now --quiet mask $KSM_SERVICES # Unmerge all shared pages test -f $KSM_RUN_PATH && echo 2 > $KSM_RUN_PATH fi }
# Should only be called when full_rollback == true enable_ksm() { if [ -f $KSM_MASK_FILE ]; then # Do not run any systemctl commands if $KSM_SERVICES units do not exist systemctl cat -- $KSM_SERVICES &> /dev/null || return 0 if systemctl --quiet unmask $KSM_SERVICES; then rm -f $KSM_MASK_FILE fi fi }
die() { echo "$@" >&2 exit 1 }
# # ACTION PROCESSING #
error_not_implemented() { echo "tuned: script function '$1' is not implemented." >&2 }
# implicit actions, will be used if not provided by profile script: # # * start must be implemented # * stop must be implemented
start() { error_not_implemented start return 16 }
stop() { error_not_implemented stop return 16 }
# # main processing #
process() { ARG="$1" shift case "$ARG" in start) start "$@" RETVAL=$? ;; stop) stop "$@" RETVAL=$? ;; verify) if declare -f verify &> /dev/null; then verify "$@" else : fi RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|verify}" RETVAL=2 ;; esac