diff --git a/files/image_config/warmboot-finalizer/finalize-warmboot.sh b/files/image_config/warmboot-finalizer/finalize-warmboot.sh index b01832a6c7b8..492ad4792e86 100755 --- a/files/image_config/warmboot-finalizer/finalize-warmboot.sh +++ b/files/image_config/warmboot-finalizer/finalize-warmboot.sh @@ -2,6 +2,9 @@ VERBOSE=no +# read SONiC immutable variables +[ -f /etc/sonic/sonic-environment ] && . /etc/sonic/sonic-environment + # Define components that needs to reconcile during warm # boot: # The key is the name of the service that the components belong to. @@ -101,16 +104,34 @@ function check_list() echo ${RET_LIST} } +function set_cpufreq_governor() { + local -r governor="$1" + echo "$governor" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor 1> /dev/null \ + && debug "Set CPUFreq scaling governor to $governor" \ + || debug "Failed to set CPUFreq scaling governor to $governor" +} + +function finalize_common() { + local -r asic_type=${ASIC_TYPE:-`sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type`} + + if [[ "$asic_type" == "mellanox" ]]; then + # Read default governor from kernel config + local -r default_governor=$(cat "/boot/config-$(uname -r)" | grep -E 'CONFIG_CPU_FREQ_DEFAULT_GOV_.*=y' | sed -E 's/CONFIG_CPU_FREQ_DEFAULT_GOV_(.*)=y/\1/') + set_cpufreq_governor "$default_governor" + fi +} function finalize_warm_boot() { debug "Finalizing warmboot..." + finalize_common sudo config warm_restart disable } function finalize_fast_reboot() { debug "Finalizing fast-reboot..." + finalize_common sonic-db-cli STATE_DB hset "FAST_RESTART_ENABLE_TABLE|system" "enable" "false" &>/dev/null sonic-db-cli CONFIG_DB DEL "WARM_RESTART|teamd" &>/dev/null }