cpufreqctl: don't try writing to non-existent files (#533)

When you give "nosmt" to your kernel, you still get directories under
/sys that correspond to inactive hyperthreads, but there's nothing
writable inside those directories, which causes auto-cpufreq to
generate lots of logspam.
This commit is contained in:
Michael Livshin 2023-07-01 10:36:25 +03:00 committed by GitHub
parent c34e3e7fbd
commit c67e290cc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -100,6 +100,12 @@ function driver () {
cat $FLROOT/cpu0/cpufreq/scaling_driver
}
function write_value () {
if [ -w $FLNM ]; then
echo $VALUE > $FLNM
fi
}
function set_driver () {
DRIVER=`driver`
case $DRIVER in
@ -136,7 +142,7 @@ function set_governor () {
while [ $i -ne $cpucount ]
do
FLNM="$FLROOT/cpu"$i"/cpufreq/scaling_governor"
echo $VALUE > $FLNM
write_value
i=`expr $i + 1`
done
else
@ -178,7 +184,7 @@ function set_frequency () {
while [ $i -ne $cpucount ]
do
FLNM="$FLROOT/cpu"$i"/cpufreq/scaling_setspeed"
echo $VALUE > $FLNM
write_value
i=`expr $i + 1`
done
else
@ -201,7 +207,7 @@ function set_frequency_min () {
while [ $i -ne $cpucount ]
do
FLNM="$FLROOT/cpu"$i"/cpufreq/scaling_min_freq"
echo $VALUE > $FLNM
write_value
i=`expr $i + 1`
done
else
@ -224,7 +230,7 @@ function set_frequency_max () {
while [ $i -ne $cpucount ]
do
FLNM="$FLROOT/cpu"$i"/cpufreq/scaling_max_freq"
echo $VALUE > $FLNM
write_value
i=`expr $i + 1`
done
else
@ -276,7 +282,7 @@ function set_energy_performance_preference () {
while [ $i -ne $cpucount ]
do
FLNM="$FLROOT/cpu"$i"/cpufreq/energy_performance_preference"
echo $VALUE > $FLNM
write_value
i=`expr $i + 1`
done
else