File improvements-for-conservative.patch of Package pm-profiler

"up_threshold" and "sampling_rate" are available both for "ondemand" and "conservative".
Adjust code to use them in both governors. Fix retrieval function for "sampling_rate" to report
meaningful parameter name (CPUFREQ_SAMPLING_RATE instead of CPUFREQ_UP_CPUFREQ_SAMPLING_RATE).


--- pm-profiler-0.1_20111222/tools/enable-profile.orig	2020-11-01 01:18:34.700359882 +0100
+++ pm-profiler-0.1_20111222/tools/enable-profile	2020-11-01 01:10:49.301356863 +0100
@@ -32,6 +32,12 @@ if [ "$?" != "0" ]; then
     exit $ERROR_INVALID_PROFILE
 fi
 
+function get_cpufreq_governor {
+    Option="CPUFREQ_GOVERNOR"
+    Governor=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`
+    echo $Option"="$Governor
+}
+
 function cpufreq_governor {
     for I in /sys/devices/system/cpu/cpu[[:digit:]]*/cpufreq; do
         Driver=`cat $I/scaling_driver`
@@ -70,21 +76,21 @@ function cpufreq_minimize_scaling_max_fr
     done
 }
 
-function cpufreq_ondemand_up_threshold {
+function cpufreq_up_threshold {
     # kernel 3.1 onwards has some cpufreq params at a new toplevel location
-    if [ -f /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold ]; then
-	echo $CPUFREQ_ONDEMAND_UP_THRESHOLD > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
-    elif [ -f /sys/devices/system/cpu/cpufreq/ondemand/up_threshold ]; then
-	echo $CPUFREQ_ONDEMAND_UP_THRESHOLD > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
+    if [ -f /sys/devices/system/cpu/cpu0/cpufreq/$Governor/up_threshold ]; then
+	echo $CPUFREQ_UP_THRESHOLD > /sys/devices/system/cpu/cpu0/cpufreq/$Governor/up_threshold
+    elif [ -f /sys/devices/system/cpu/cpufreq/$Governor/up_threshold ]; then
+	echo $CPUFREQ_UP_THRESHOLD > /sys/devices/system/cpu/cpufreq/$Governor/up_threshold
     fi
 }
 
-function cpufreq_ondemand_sampling_rate {
+function cpufreq_sampling_rate {
     # kernel 3.1 onwards has some cpufreq params at a new toplevel location
-    if [ -f /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate ]; then
-	echo $CPUFREQ_ONDEMAND_SAMPLING_RATE >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate;
-    elif [ -f /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate ]; then
-	echo $CPUFREQ_ONDEMAND_SAMPLING_RATE >/sys/devices/system/cpu/cpufreq/ondemand/sampling_rate;
+    if [ -f /sys/devices/system/cpu/cpu0/cpufreq/$Governor/sampling_rate ]; then
+	echo $CPUFREQ_SAMPLING_RATE >/sys/devices/system/cpu/cpu0/cpufreq/$Governor/sampling_rate;
+    elif [ -f /sys/devices/system/cpu/cpufreq/$Governor/sampling_rate ]; then
+	echo $CPUFREQ_SAMPLING_RATE >/sys/devices/system/cpu/cpufreq/$Governor/sampling_rate;
     fi
 }
 
@@ -133,10 +139,25 @@ function read_ahead_kb {
 # in case scaling_max_freq has been reduced, reset value to avoid surprises
 cpufreq_reset_scaling_max_freq
 
-[ -n "$CPUFREQ_GOVERNOR" ] && cpufreq_governor
+if [ -n "$CPUFREQ_GOVERNOR" ]; then
+    cpufreq_governor
+else
+    get_cpufreq_governor
+fi
+
+case "$Governor" in
+  ondemand)
+    [ -n "$CPUFREQ_ONDEMAND_UP_THRESHOLD" ] && CPUFREQ_UP_THRESHOLD="$CPUFREQ_ONDEMAND_UP_THRESHOLD"
+    [ -n "$CPUFREQ_ONDEMAND_SAMPLING_RATE" ] && CPUFREQ_SAMPLING_RATE="$CPUFREQ_ONDEMAND_SAMPLING_RATE"
+    ;;
+  conservative)
+    [ -n "$CPUFREQ_CONSERVATIVE_UP_THRESHOLD" ] && CPUFREQ_UP_THRESHOLD="$CPUFREQ_CONSERVATIVE_UP_THRESHOLD"
+    [ -n "$CPUFREQ_CONSERVATIVE_SAMPLING_RATE" ] && CPUFREQ_SAMPLING_RATE="$CPUFREQ_CONSERVATIVE_SAMPLING_RATE"
+    ;;
+esac
 [ -n "$CPUFREQ_MINIMIZE_SCALING_MAX_FREQ" ] && cpufreq_minimize_scaling_max_freq
-[ -n "$CPUFREQ_ONDEMAND_UP_THRESHOLD" ] && cpufreq_ondemand_up_threshold
-[ -n "$CPUFREQ_ONDEMAND_SAMPLING_RATE" ] && cpufreq_ondemand_sampling_rate
+[ -n "$CPUFREQ_UP_THRESHOLD" ] && cpufreq_up_threshold
+[ -n "$CPUFREQ_SAMPLING_RATE" ] && cpufreq_sampling_rate
 [ -n "$CPUFREQ_ONDEMAND_POWERSAVE_BIAS" ] && cpufreq_ondemand_powersave_bias
 [ -n "$CPUFREQ_SCHED_MC_POWER_SAVINGS" ] && cpufreq_sched_mc_power_savings
 [ -n "$SATA_ALPM" ] && sata_alpm
--- pm-profiler-0.1_20111222/tools/get-current-settings.orig	2020-11-01 01:18:22.376068570 +0100
+++ pm-profiler-0.1_20111222/tools/get-current-settings	2020-11-01 01:13:06.696606224 +0100
@@ -15,7 +15,7 @@ function get_cpufreq_governor {
     echo $Option"="$Governor
 }
 
-function get_cpufreq_ondemand_up_threshold {
+function get_cpufreq_up_threshold {
     Option="CPUFREQ_UP_THRESHOLD"
 
     if [ -f /sys/devices/system/cpu/cpu0/cpufreq/$Governor/up_threshold ]; then
@@ -36,8 +36,8 @@ function get_cpufreq_ondemand_up_thresho
     echo $Option"="$Value
 }
 
-function get_cpufreq_ondemand_sampling_rate {
-    Option="CPUFREQ_UP_CPUFREQ_SAMPLING_RATE"
+function get_cpufreq_sampling_rate {
+    Option="CPUFREQ_SAMPLING_RATE"
 
     if [ -f /sys/devices/system/cpu/cpu0/cpufreq/$Governor/sampling_rate ]; then
       Value=`cat /sys/devices/system/cpu/cpu0/cpufreq/$Governor/sampling_rate`
@@ -135,13 +135,17 @@ get_read_ahead_kb
 
 if [ -d /sys/devices/system/cpu/cpu0/cpufreq ]; then
     get_cpufreq_governor
-    if [ $Governor == conservative -o $Governor == ondemand ]; then
-	get_cpufreq_ondemand_sampling_rate
-	get_cpufreq_ondemand_up_threshold
-        if [ $Governor == ondemand ]; then
-	    get_cpufreq_ondemand_powersave_bias
-        fi
-    fi
+    case "$Governor" in
+      ondemand)
+        get_cpufreq_sampling_rate
+        get_cpufreq_up_threshold
+        get_cpufreq_ondemand_powersave_bias
+        ;;
+      conservative)
+        get_cpufreq_sampling_rate
+        get_cpufreq_up_threshold
+        ;;
+    esac
     exit 0
 else
     echo "Error: unable to read settings." \
--- pm-profiler-0.1_20111222/doc/config.template.orig	2020-11-01 01:18:34.700359882 +0100
+++ pm-profiler-0.1_20111222/doc/config.template	2020-11-01 01:40:18.611190256 +0100
@@ -36,27 +36,34 @@ CPUFREQ_SCHED_MC_POWER_SAVINGS=""
 
 # Defines the time the CPU has to be busy in order to switch up
 # frequencies. This setting does only make sense in conjunction with the
-# ondemand governor
+# ondemand or conservative governor.
+# Has option alias CPUFREQ_UP_THRESHOLD.
 #
-# Kernel documenatation: cpu-freq/governors.txt
+# Kernel documentation: admin-guide/pm/cpufreq.rst
 #
 # File: /sys/devices/system/cpu/cpu*/cpufreq/ondemand/up_threshold
+# File: /sys/devices/system/cpu/cpufreq/{ondemand,conservative}/up_threshold (kernel >= 3.1)
 #
 CPUFREQ_ONDEMAND_UP_THRESHOLD=""
+CPUFREQ_CONSERVATIVE_UP_THRESHOLD=""
 
 # Generally the kernel sets default values for the sampling rate. For slower
 # operations, set higher sampling range values.
 # This option is rather for hardware optimization then for powersaving.
+# Has option alias CPUFREQ_SAMPLING_RATE.
 #
 # File: /sys/devices/system/cpu/cpu*/cpufreq/ondemand/sampling_rate
+# File: /sys/devices/system/cpu/cpufreq/{ondemand,conservative}/sampling_rate (kernel >= 3.1)
 #
 CPUFREQ_ONDEMAND_SAMPLING_RATE=""
+CPUFREQ_CONSERVATIVE_SAMPLING_RATE=""
 
 # This will lower the target CPU frequency by a specified percent.
 # powersave_bias is in units of 0.1%, so it has an effective range of 1
 # through 1000, resulting in 0.1% to 100% impact.
 #
 # File: /sys/devices/system/cpu/cpu*/cpufreq/ondemand/powersave_bias
+# File: /sys/devices/system/cpu/cpufreq/ondemand/powersave_bias (kernel >= 3.1)
 #
 CPUFREQ_ONDEMAND_POWERSAVE_BIAS=""
 
openSUSE Build Service is sponsored by