File add-sampling_down_factor.patch of Package pm-profiler

Add "sampling_down_factor" tuning, available for "ondemand" and "conservative" governors.


--- pm-profiler-0.1_20111222/tools/enable-profile.orig	2020-11-01 01:51:19.050840643 +0100
+++ pm-profiler-0.1_20111222/tools/enable-profile	2020-11-01 01:58:16.760731693 +0100
@@ -94,6 +94,15 @@ function cpufreq_sampling_rate {
     fi
 }
 
+function cpufreq_sampling_down_factor {
+    # kernel 3.1 onwards has some cpufreq params at a new toplevel location
+    if [ -f /sys/devices/system/cpu/cpu0/cpufreq/$Governor/sampling_down_factor ]; then
+        echo $CPUFREQ_SAMPLING_DOWN_FACTOR >/sys/devices/system/cpu/cpu0/cpufreq/$Governor/sampling_down_factor;
+    elif [ -f /sys/devices/system/cpu/cpufreq/$Governor/sampling_down_factor ]; then
+        echo $CPUFREQ_SAMPLING_DOWN_FACTOR >/sys/devices/system/cpu/cpufreq/$Governor/sampling_down_factor;
+    fi
+}
+
 function cpufreq_ondemand_powersave_bias {
     # kernel 3.1 onwards has some cpufreq params at a new toplevel location
     if [ -f /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias ]; then
@@ -149,15 +158,18 @@ 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"
+    [ -n "$CPUFREQ_ONDEMAND_SAMPLING_DOWN_FACTOR" ] && CPUFREQ_SAMPLING_DOWN_FACTOR="$CPUFREQ_ONDEMAND_SAMPLING_DOWN_FACTOR"
     ;;
   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"
+    [ -n "$CPUFREQ_CONSERVATIVE_SAMPLING_DOWN_FACTOR" ] && CPUFREQ_SAMPLING_DOWN_FACTOR="$CPUFREQ_CONSERVATIVE_SAMPLING_DOWN_FACTOR"
     ;;
 esac
 [ -n "$CPUFREQ_MINIMIZE_SCALING_MAX_FREQ" ] && cpufreq_minimize_scaling_max_freq
 [ -n "$CPUFREQ_UP_THRESHOLD" ] && cpufreq_up_threshold
 [ -n "$CPUFREQ_SAMPLING_RATE" ] && cpufreq_sampling_rate
+[ -n "$CPUFREQ_SAMPLING_DOWN_FACTOR" ] && cpufreq_sampling_down_factor
 [ -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:51:19.050840643 +0100
+++ pm-profiler-0.1_20111222/tools/get-current-settings	2020-11-01 02:00:12.811479518 +0100
@@ -56,6 +56,26 @@ function get_cpufreq_sampling_rate {
     echo $Option"="$Value
 }
 
+function get_cpufreq_sampling_down_factor {
+    Option="CPUFREQ_SAMPLING_DOWN_FACTOR"
+
+    if [ -f /sys/devices/system/cpu/cpu0/cpufreq/$Governor/sampling_down_factor ]; then
+      Value=`cat /sys/devices/system/cpu/cpu0/cpufreq/$Governor/sampling_down_factor`
+      for I in /sys/devices/system/cpu/cpu[[:digit:]]*; do
+        if [ -d $I/cpufreq/$Governor ]; then
+            if [ `cat $I/cpufreq/$Governor/sampling_down_factor` != $Value ]; then
+                echo "Warning: different values: "$Option >&2
+            fi
+        else
+            echo "Warning: different governor on "$I >&2
+        fi
+      done
+    else
+      Value=`cat /sys/devices/system/cpu/cpufreq/$Governor/sampling_down_factor`
+    fi
+    echo $Option"="$Value
+}
+
 function get_cpufreq_ondemand_powersave_bias {
     Option="CPUFREQ_ONDEMAND_POWERSAVE_BIAS"
 
@@ -139,11 +159,13 @@ if [ -d /sys/devices/system/cpu/cpu0/cpu
       ondemand)
         get_cpufreq_sampling_rate
         get_cpufreq_up_threshold
+        get_cpufreq_sampling_down_factor
         get_cpufreq_ondemand_powersave_bias
         ;;
       conservative)
         get_cpufreq_sampling_rate
         get_cpufreq_up_threshold
+        get_cpufreq_sampling_down_factor
         ;;
     esac
     exit 0
--- pm-profiler-0.1_20111222/doc/config.template.orig	2020-11-01 01:51:19.050840643 +0100
+++ pm-profiler-0.1_20111222/doc/config.template	2020-11-01 02:02:23.798580932 +0100
@@ -67,6 +67,18 @@ CPUFREQ_CONSERVATIVE_SAMPLING_RATE=""
 #
 CPUFREQ_ONDEMAND_POWERSAVE_BIAS=""
 
+# Multiplier to slow down governor tick (applied to "sampling_rate")
+# when CPU load is above "up_threshold".
+# Frequency fluctuations in some bursty workloads may be avoided this way.
+# Default value is 1.
+# Has option alias CPUFREQ_SAMPLING_DOWN_FACTOR.
+#
+# File: /sys/devices/system/cpu/cpu*/cpufreq/ondemand/sampling_down_factor
+# File: /sys/devices/system/cpu/cpufreq/{ondemand,conservative}/sampling_down_factor (kernel >= 3.1)
+#
+CPUFREQ_ONDEMAND_SAMPLING_DOWN_FACTOR=""
+CPUFREQ_CONSERVATIVE_SAMPLING_DOWN_FACTOR=""
+
 # Set whether to enable or disable the SATA Aggressive Link Power Management
 # Reference: http://www.lesswatts.org/tips/disks.php
 # Attention: This will disable hotplug capabilities
openSUSE Build Service is sponsored by