staging.inyokaproject.org

Governor fest einstellen

Status: Ungelöst | Ubuntu-Version: Ubuntu MATE 22.04 (Jammy Jellyfish)
Antworten |

Egon1971

Anmeldungsdatum:
5. Dezember 2007

Beiträge: 73

Hallo

Ich würde gern den Governor für die Prozessortaktung fest auf Conservative einstellen, so dass die Einstellung auch einen Neustart überlebt.

Hat jemand eine Idee, das umzusetzen?

dingsbums

Anmeldungsdatum:
13. November 2010

Beiträge: 3337

Einen passenden Befehl dazu hast du vermutlich schon. Falls nicht, hilft bestimmt https://stevescargall.com/2020/02/12/how-to-set-linux-cpu-scaling-governor-to-max-performance/ weiter.

Für jeden Neustart kannst du das dann aktivieren (entweder/oder) .

trollsportverein

Avatar von trollsportverein

Anmeldungsdatum:
21. Oktober 2010

Beiträge: 2627

Ganz einfach über die cpufrequtils. In /etc/init.d/cpufrequtils bei GOVERNOR="<gewünschte_Einstellung>" eintragen.

Egon1971

(Themenstarter)

Anmeldungsdatum:
5. Dezember 2007

Beiträge: 73

trollsportverein schrieb:

Ganz einfach über die cpufrequtils. In /etc/init.d/cpufrequtils bei GOVERNOR="<gewünschte_Einstellung>" eintragen.

Das hat bedingt geklappt.

Den Governor auswählen kann ich bereits über das Mate-Panel. Beim Laptop wurde der Eintrag in der /etc/init.d/cpufrequtils übernommen und der geünschte Governor wird beim Systemstart gesetzt. Bei einem PC, der hat allerdings nur Governor's Powersave und Performance, klappt es auch. Bei PC 2 wird bei Systemstart immer Ondemand statt Conservative geladen.

#!/bin/sh
### BEGIN INIT INFO
# Provides:       cpufrequtils
# Required-Start: $remote_fs loadcpufreq
# Required-Stop:
# Default-Start:  2 3 4 5
# Default-Stop:
# Short-Description: set CPUFreq kernel parameters
# Description: utilities to deal with CPUFreq Linux 
#	kernel support
### END INIT INFO
# 

DESC="CPUFreq Utilities"

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
CPUFREQ_SET=/usr/bin/cpufreq-set
CPUFREQ_INFO=/usr/bin/cpufreq-info
CPUFREQ_OPTIONS=""

# use lsb-base
. /lib/lsb/init-functions

# Which governor to use. Must be one of the governors listed in:
#   cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
#
# and which limits to set. Both MIN_SPEED and MAX_SPEED must be values
# listed in:
#   cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
# a value of 0 for any of the two variables will disabling the use of 
# that limit variable.
#
# WARNING: the correct kernel module must already be loaded or compiled in.
# 
# Set ENABLE to "true" to let the script run at boot time.
# 
# eg:	ENABLE="true"
#	GOVERNOR="ondemand"
#	MAX_SPEED=1000
#	MIN_SPEED=500

ENABLE="true"
GOVERNOR="conservative"
MAX_SPEED="0"
MIN_SPEED="0"

check_governor_avail() {
	info="/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors"
	if [ -f $info ] && grep -q "\<$GOVERNOR\>" $info ; then
		return 0;
	fi
	return 1;
}

[ -x $CPUFREQ_SET ] || exit 0

if [ -f /etc/default/cpufrequtils ] ; then
	. /etc/default/cpufrequtils
fi

# if not enabled then exit gracefully
[ "$ENABLE" = "true" ] || exit 0

if [ -n "$MAX_SPEED" ] && [ $MAX_SPEED != "0" ] ; then
	CPUFREQ_OPTIONS="$CPUFREQ_OPTIONS --max $MAX_SPEED"
fi

if [ -n "$MIN_SPEED" ] && [ $MIN_SPEED != "0" ] ; then
	CPUFREQ_OPTIONS="$CPUFREQ_OPTIONS --min $MIN_SPEED"
fi

if [ -n "$GOVERNOR" ] ; then
	CPUFREQ_OPTIONS="$CPUFREQ_OPTIONS --governor $GOVERNOR"
fi

CPUS=$(cat /proc/stat|sed -ne 's/^cpu\([[:digit:]]\+\).*/\1/p')
RETVAL=0
case "$1" in
	start|force-reload|restart|reload)
		log_action_begin_msg "$DESC: Setting $GOVERNOR CPUFreq governor"
		if check_governor_avail ; then
			for cpu in $CPUS ; do
				log_action_cont_msg "CPU${cpu}"
				$CPUFREQ_SET --cpu $cpu $CPUFREQ_OPTIONS 2>&1 > /dev/null || \
					RETVAL=$?
			done
			log_action_end_msg $RETVAL ""
		else
			log_action_cont_msg "disabled, governor not available"
			log_action_end_msg $RETVAL
		fi
		;;
	stop)
		;;
	*)
		echo "Usage: $0 {start|stop|restart|reload|force-reload}"
		exit 1
esac

exit 0

Manuell kann ich Conservative auswählen und sehe auch, wie die CPU dadurch entlastet wird, nur eben, beim Neustart ist wieder Ondemand aktiv.

Antworten |