Hi Jaroslav,
I wrote the following patch and a profile to set sampling_down_factor.
- The knob for sampling_down_factor only appears after the governor is changed to either
ondemand or conservative.
It appears in/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor for ondemand
It appears in
/sys/devices/system/cpu/cpufreq/conservative/sampling_down_factor for
conservative. It is necessary that the governor requested in the profile
be set before setting/getting sampling_down_factor.
With this patch it fails to set the sampling_down_factor, as the tuned has not switched to new governor.
I did some experiments by adding the following debug logs :
@command_set("sampling_down_factor")
def _set_sampling_down_factor(self,sampling_down_factor,sim):
cpufreq_sys_dir = "/sys/devices/system/cpu/cpufreq/"
data = self._cmd.read_file("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor").strip()
log.info("gov is %s" %data)
log.info("%s : %s"% ("ondemand",str(os.path.exists(cpufreq_sys_dir + "ondemand"))))
log.info("%s : %s"% ("conservative",str(os.path.exists(cpufreq_sys_dir + "conservative"))))
...
I ran a test which did the following :
systemctl stop tuned
sleep 5
systemctl start tuned
sleep 2
tuned-adm profile balanced
sleep 2
echo "sampling_down_factor:" `cat /sys/devices/system/cpu/cpufreq/*/sampling_down_factor`
tuned-adm profile balanced-hpc
Here are the logs which i see after that :
2016-06-12 03:43:58,672 INFO tuned.plugins.plugin_cpu: setting new cpu latency 1000
2016-06-12 03:43:58,673 INFO tuned.daemon.daemon: static tuning from profile 'balanced' applied
2016-06-12 03:44:00,641 INFO tuned.daemon.daemon: stopping tunning
2016-06-12 03:44:00,724 INFO tuned.profiles.loader: loading profile: balanced-hpc
2016-06-12 03:44:00,724 INFO tuned.daemon.daemon: starting tuning
...
2016-06-12 03:44:00,759 INFO tuned.plugins.plugin_cpu: sampling_down_factor is None
2016-06-12 03:44:00,759 INFO tuned.plugins.plugin_cpu: gov is performance
2016-06-12 03:44:00,759 INFO tuned.plugins.plugin_cpu: ondemand : False
2016-06-12 03:44:00,760 INFO tuned.plugins.plugin_cpu: conservative : False
2016-06-12 03:44:00,760 INFO tuned.plugins.plugin_cpu: sampling_down_factor is set to 100
2016-06-12 03:44:00,841 INFO tuned.plugins.plugin_cpu: setting new cpu latency 1000
2016-06-12 03:44:00,841 INFO tuned.daemon.daemon: static tuning from profile 'balanced-hpc' applied
Hope i am not doing something silly here.
But, Does I was switching to default profile before setting it to requested one ?
Is there a way to ensure governor setting precedes this command ?
Is there a way tuned could set different governors to different cpus?
Known problems:
If both conservative and ondemand are being used on different cpus , sometimes i couldn't set sampling_down_rate.
I will figure out why it is happening.
balanced-hpc/tuned.conf
-------------
#
# tuned configuration
#
[cpu]
governor=ondemand
energy_perf_bias=normal
sampling_down_factor=100
[audio]
timeout=10
[video]
radeon_powersave=auto
[disk]
# Comma separated list of devices, all devices if commented out.
# devices=sda
alpm=medium_power
-----
diff --git a/tuned/plugins/plugin_cpu.py b/tuned/plugins/plugin_cpu.py
index 80d878a..412fcfe 100644
--- a/tuned/plugins/plugin_cpu.py
+++ b/tuned/plugins/plugin_cpu.py
@@ -48,6 +48,7 @@ class CPULatencyPlugin(base.Plugin):
"latency_high" : 1000,
"force_latency" : None,
"governor" : None,
+ "sampling_down_factor": None,
"energy_perf_bias" : None,
"min_perf_pct" : None,
"max_perf_pct" : None,
@@ -239,6 +240,32 @@ class CPULatencyPlugin(base.Plugin):
return governor
+ @command_set("sampling_down_factor")
+ def _set_sampling_down_factor(self,sampling_down_factor,sim):
+ cpufreq_sys_dir = "/sys/devices/system/cpu/cpufreq/"
+ governors = ["ondemand", "conservative"]
+ #If both ondemand and conservative governors are in use we set
for both.
+ for gov in governors :
+ if os.path.exists(cpufreq_sys_dir + gov) :
+ sys_dir_path = cpufreq_sys_dir + gov
+ self._cmd.write_to_file(sys_dir_path +
"/sampling_down_factor", str(sampling_down_factor))
+ log.info("sampling_down_factor is set to %s" %
sampling_down_factor)
+ return sampling_down_factor
+
+ @command_get("sampling_down_factor")
+ def _get_sampling_down_factor(self):
+ sampling_down_factor = None
+ cpufreq_sys_dir = "/sys/devices/system/cpu/cpufreq/"
+ governors = ["ondemand", "conservative"]
+ #If both ondemand and conservative governors are in use, both
should
+ #have same sampling_down_factor.
+ for gov in governors :
+ if os.path.exists(cpufreq_sys_dir + gov) :
+ sys_dir_path = cpufreq_sys_dir + gov
+ factor = self._cmd.read_file(sys_dir_path +
"/sampling_down_factor").strip()
+ log.info("sampling_down_factor is %s" % sampling_down_factor)
+ return str(sampling_down_factor)
+
@command_set("energy_perf_bias", per_device=True)
def _set_energy_perf_bias(self, energy_perf_bias, device, sim):
if not self._is_cpu_online(device):
--
Regards
Akshay Adiga