1
0
Fork 0
Commit graph

71 commits

Author SHA1 Message Date
Jaroslav Škarvada
46207f479b
Fixed crash when running inside container
Fixes #267

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2020-06-04 11:56:21 +02:00
Jaroslav Škarvada
120bb69d3f
latency: support None value
This allows writing e.g.:
[cpu]
force_latency=cstate.name:XYZ|None

In this case if C-state with name XYZ doesn't exist force_latency
will be evaluated to 'None' and nothing will be set and no
error will be reported. If '|None' is omitted, error will be
reported.

Another example:
[cpu]
force_latency=None

Here, it will also set nothing and no error will be reported.

When 'None' is encountered it stops parsing the latency, so writing
'None|1' will also result in no latency set. Both 'none' and 'None' can
be used interchangeably with the same effect.

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2019-11-29 01:25:59 +01:00
Ondřej Lysoněk
43375e6bbe cpu: Update checking if EPB is supported
Update checking if EPB is supported so that it works with recent
versions of the x86_energy_perf_policy tool. Newer versions of
x86_energy_perf_policy, unlike older versions, exit with a zero exit
code even if the CPU doesn't support EPB. Newer versions of the tool
give no ouput on stdout if EPB is not supported, so check for that.

In the future, we might like to determine if EPB is supported by
searching /proc/cpuinfo for specific CPU flags. However the solution
described in the previous paragraph should work just fine for now.

Resolves: rhbz#1690929

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-11-22 14:29:36 +01:00
Ondřej Lysoněk
a30d13687c cpu: Expand variables in all commands
Variables in force_latency, min_perf_pct, max_perf_pct and no_turbo
options were not being expanded. Fix it.

Fixes #203

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-10-30 08:56:49 +01:00
Jaroslav Škarvada
e40b50a498
Used C-states in latency specification
For sap-hana and virtual-host profiles used state3 (i.e. usually C3)
C-state in latency specification instead of the hardcoded value 70 us,
i.e.:
force_latency=cstate.id:3|70

Also dropped obsoleted TODO note from the plugin_cpu.

Related: rhbz#1737628

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2019-08-16 18:13:02 +02:00
Jaroslav Škarvada
0ec40e0360
plugin_cpu: latency can be now specified as cstate
Maximal latency can be now specified multiple ways:
- directly in usec (this is the same as before), e.g. for 10 us:
  force_latency = 10
- as an ID of maximal cstate allowed, e.g. for the kernel state1:
  force_latency = cstate.id:1
- as a name (case sensitive) of maximal cstate allowed, e.g. for the state named C1:
  force_latency = cstate.name:C1

It is also possible to specify multiple fallback values separated by '|', e.g.:
  force_latency = cstate.name:C6|cstate.id:4|10

This will try to obtain latency of cstate named C6, if it fails (e.g.
there is no such cstate), it will try kernel state4 and if it also fails
it finally fallbacks to 10 us.

This commit also changes force_latency settings of latency-performance
profile to:
  force_latency=cstate.id:1|1

I.e. it tries kernel state1 and fallbacks to 1 us.

Resolves: rhbz#1737628

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2019-08-14 16:34:17 +02:00
Jaroslav Škarvada
eb451f3e65
Merge pull request #167 from olysonek/hotplug-races
Fix hotplug-related races and other issues
2019-03-07 17:36:37 +01:00
Ondřej Lysoněk
a9f2b27d30 Rework device handling to avoid races caused by hotplug
This patch fixes (at least) the following race conditions:
1. If a device is attached while iterating assigned devices, the
   MonitorObserver thread can attempt to insert the newly attached
   device to the assigned_devices set while the set is being iterated,
   which results in the following exception:
   RuntimeError: Set changed size during iteration
2. Some devices can be missed when applying a tuning - devices are enumerated
   (i.e., Plugin._init_devices() gets called) before udev device monitoring is
   started (hotplug.Plugin._hardware_events_init() gets called), so devices
   that appear between these two actions are not tuned.
3. Device monitoring is stopped too late, which can result in some tunings
   not being unapplied after stopping a profile. This can happen for devices
   that get added during profile rollback after unit_manager.stop_tuning()
   gets called, but before unit_manager.destroy_all() gets called.
4. It can happen that tuning is applied twice for a device if it is added
   during profile activation, e.g. after unit_manager.create() is called in
   Daemon._thread_code(), but before unit_manager.start_tuning() is called.
   Apart from unnecessarily applying the tuning twice, it can result in
   overwriting saved original settings for the device and hence our inability
   to properly roll back our changes to the settings.
5. The observer thread can attempt to use load_monitor before it's created
   in Plugin._instance_init(), which can result in AttributeError.

Hopefully it doesn't introduce new race conditions :).

The fix is to:
1. rearrange the sequence of certain actions,
2. separate Instance.devices to two separate sets: processed_devices
   and assigned_devices.

   processed_devices are never iterated when the MonitorObserver thread
   is running (*), so the first problem described above cannot happen.
   The set is used to store devices, which have already been tuned.

   The assigned_devices set is now the set of devices that are going
   to be tuned. The set can only be accessed by the main thread.

   (*) Except when verifying tuning - this is fixed in a follow-up patch

I tried to separate the changes into more digestable patches, but I
couldn't figure out how.

Resolves: rhbz#1592743

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-03-06 19:52:07 +01:00
Ondřej Lysoněk
52873fa9c8 cpu: Support specifying fallback CPU scaling governors
The 'governor' option of the 'cpu' plugin now supports specifying
multiple governors. The governors are separated using '|' (the '|'
character is meant to represent a logical 'or' operator; we already use
the same syntax for the 'energy_perf_bias' option). Tuned will set
the first governor that is available on the system.

For example, with the following profile, Tuned will set the 'ondemand'
governor, if it's available. If it's not available, but the 'powersave'
governor is available, 'powersave' will be set. If neither of them are
available, the governor will not be changed.

[cpu]
governor=ondemand|powersave

Resolves: rhbz#1679205

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-03-06 11:41:21 +01:00
Thomas Renninger
29022a0edf Differ archs and x86 CPU vendors in plugin_cpu
This avoids wrong warning about a missing intel tool (x86_energy_perf_bias)

Remember arch and x86 CPU vendor to allow arch/vendor specific CPU tunings
in the future
2019-01-25 12:19:26 +01:00
Ondřej Lysoněk
07159dfb0a cpu: Support specifying alternative EPB values
Support specifying alternative Energy Performance Bias values.
The values are separated using the '|' character. For example,
if you have the following in your profile:

[cpu]
energy_perf_bias=powersave|power

then tuned will try to set EPB to 'powersave', and if that fails,
it will try to set it to 'power'.

Resolves: rhbz#1508468

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2018-05-14 09:45:54 +02:00
Ondřej Lysoněk
3104141ff6 cpu: Fix verification of EPB on Linux 4.13+
Fix verification of Energy Performance Bias on Linux 4.13+.
In Linux 4.13, the value strings accepted by the x86_energy_perf_policy
program changed.

Resolves: rhbz#1508468

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2018-05-14 09:45:48 +02:00
Ondřej Lysoněk
e3ed58e160 Fix calling methods of parent classes
This fixes Pylint errors such as the following:
tuned/logs.py:39: [E1003(bad-super-call), TunedLogger.__init__] \
Bad first argument 'self.__class__' given to super()

This prevents infinite recursion errors, see
https://stackoverflow.com/a/18208725

This does introduce name duplication, but when we drop python2 support
in the future, we can use super() without arguments.
2018-01-14 15:13:27 +01:00
Jaroslav Škarvada
f563c7d756
An attempt to port Tuned to python3 and keeping it python2 compatible
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2017-12-21 10:20:13 +01:00
Ondřej Lysoněk
ff6f69f604 Don't log errors about missing files on verify with ignore_missing set
Take the ignore_missing parameter into account in @command_get methods
so that error messages are not logged for missing files.

In some @command_get methods the ignore_missing parameter is not used,
because e.g. it is not applicable or the parameter is handled elsewhere
in the code.

Resolves: rhbz#1451435

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2017-08-28 14:45:29 +02:00
Ondřej Lysoněk
acc1427a4f cpu: Don't log error in execute() if EPB is not supported
Don't log error in commands.execute() if MSR_IA32_ENERGY_PERF_BIAS
is not supported. A message with level WARN is already logged
afterwards:

WARNING  tuned.plugins.plugin_cpu: your CPU doesn't support
         MSR_IA32_ENERGY_PERF_BIAS, ignoring CPU energy performance bias

Resolves: rhbz#1443182

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2017-08-21 12:34:27 +02:00
Jaroslav Škarvada
df9aa2f5c4
With systemd don't do full rollback on shutdown / reboot
With systemd full rollback is done if Tuned is terminated by user or profile
is changed. It is not done if Tuned is terminated due to system
shutdown / reboot. Without systemd full rollback is done only if profile
is changed.

Renamed profile_switch parameter to full_rollback where appropriate.

Also fixed various checks for command not found.

Resolves: rhbz#1421286

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2017-04-01 12:36:43 +02:00
Ondřej Lysoněk
f14ae65bd2 Implement udev-based device matching
A new option 'devices_udev_regex' can be used in profile
configuration to specify devices to which a plugin instance
should be applied.

The option can contain a python regular expression, as specified
in https://docs.python.org/2/library/re.html#regular-expression-syntax.
The expression is effectively matched against the output of
udevadm info --query=property -n <device_path>

If the option 'devices_udev_regex' is specified, the 'devices' option
is ignored. If it is not specified, then the matching is done the same
way as previously, i.e. against 'devices'.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2017-02-28 17:39:07 +01:00
Ondřej Lysoněk
a38b6eee99 Remove the '_devices' attribute in plugins
The _device attribute should always be the same as the union of
_assigned_devices and _free_devices, therefore it's redundant.
Its existence in my opinion brings only confusion and a potential
source of inconsistencies.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2017-02-27 14:54:46 +01:00
Jaroslav Škarvada
6bf3afa9d3 plugin_cpu: added support for sampling_down_factor and removed cpupower
The sampling rate determines how frequently the governor checks to tune the
CPU. The sampling_down_factor is a tunable that multiplies the sampling rate
when the CPU is at its highest clock frequency thereby delaying load
evaluation and improving performance. Allowed values for
sampling_down_factor are 1 to 100000.

Usage:

[cpu]
sampling_down_factor = 1

Recommended setting for jitter reduction:
sampling_down_factor = 100

Original idea of adding support for this knob to Tuned came from
Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>

This patch also removes cpupower support from Tuned. It seems
that cpupower tool changes it's output format time to time, and parsing
it in Tuned becomes harder and harder. Morever the current parser in Tuned
didn't handle the recent cpupower correctly. It's much easier to just query
sysfs than supporting multiple versions of cpupower.

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2016-06-23 11:24:41 +02:00
Jaroslav Škarvada
a2b0741eac pm_qos: fixed exception if PM_QoS is not available
Resolves: rhbz#1296137

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2016-01-06 14:14:19 +01:00
Jaroslav Škarvada
d7cdf56108 plugin_cpu: save and restore only changed intel pstate attributes
There is no need to save and restore intel pstate attributes which aren't
changed by tuned profile.

Resolves: rhbz#1252156

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2015-08-21 14:38:17 +02:00
Jaroslav Škarvada
90e9a93c73 plugin_cpu: do not show error if cpupower or x86_energy_perf_policy are missing
Now only warning is displayed similarly to the hdparm behavior.

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2015-08-17 15:09:08 +02:00
Jaroslav Škarvada
b882627a07 plugin_cpu: added check whether CPU has scaling governor/driver
If there is no scaling governor/driver, the CPU is silently skipped when setting
governor.

Related: rhbz#1212836

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2015-06-10 14:29:43 +02:00
Jaroslav Škarvada
a6f4fca71d functions: added CPU list to hex mask and vice versa conversions
Added following functions:

cpulist2hex - converts CPU list to hexadecimal mask, takes arbitrary number of
              arguments, each argument can also contain "compact values",
              e.g.: "${f:cpulist2hex:0-3,4:5-6}".

hex2cpulist - converts hexadecimal mask to CPU list, takes one argument,
              the hexadecimal mask.

cpus_online - checks whether CPUs from the list (which is formatted the same
              way as with cpulist2hex) are online, returns only those which
              are online.

Example:

[variables]
cpus = ${f:hex2cpulist:0x0000001f}
online = ${f:cpus_online:${cpus}}

Related: rhbz#1225135

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2015-06-05 19:12:52 +02:00
Jaroslav Škarvada
516dc1c168 plugin_cpu: skip offline CPUs
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2015-05-28 18:44:00 +02:00
Jaroslav Škarvada
60f9e1e217 plugins: made class methods from get_config_options* methods
They were intended to be class methods and that's why there
were defined with the 'cls' parameter, but they actually
weren't class methods.

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2015-05-26 14:24:07 +02:00
Jaroslav Škarvada
6940d280b6 tuned: added verify command
The verify command verifies whether the current system settings matches
activated profile. It also writes all settings from the active profile
with the current / expected values to the log. It is good for checking
what is exactly set and what changed during the run.

Currently custom commands and plugin_scheduler are not supported.

Resolves: rhbz#1150047
Fixes: #34

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2015-05-18 18:55:01 +02:00
Jaroslav Škarvada
da99153f99 plugin_cpu: energy_perf_policy converted to human readable strings
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2015-05-18 18:45:31 +02:00
Jaroslav Škarvada
5b8a2d2e8e plugins: added bootloader plugin
This plugin can be used to add parameters to kernel (boot/dracut)
command line. Currently only grub2 bootloader is used and reboot
is required to apply the tunings. The tuning can be only unloaded
by profile change followed by reboot.

It patches grub.cfg at runtime and installs /etc/grub.d/00_tuned
grub2 template. So it's possible to regenerate grub.cfg by
grub2-mkconfig and the tuning persists.

It also patches /etc/default/grub and adds tuned_params grub2 variable
to GRUB_CMDLINE_LINUX. This is probably the only way how to get
variables into kernel command line in grub.cfg. Nothing else is added to
/etc/default and it's patched if the plugin is used for the first
time. It's re-patched on plugin initialization only if the tuned_params
variable is missing.

On subsequent invocation only the tuned_params grub2 variable and
grub.cfg are changed.

Example of use:

[bootloader]
cmdline=quiet

This adds "quiet" parameter to the kernel boot command line (reboot
is required).

EFI is also supported. By default it autodetects redhat and fedora
directories (in this order). Nothing else is touched. If you have
different EFI system and your grub.cfg location is not auto-detected
or your grub.cfg is located on different place you can specify
the grub.cfg location manually:

[bootloader]
grub2_cfg_file=CUSTOM_PATH/grub.cfg
cmdline=quiet

This has precedence over auto-detection. This is used for runtime
patching. In case it is not set correctly, the grub.cfg patching
will not work, but you can still regenerate the config by hand by
grub2-mkconfig.

Resolves: rhbz#1044111

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2014-09-29 16:33:56 +02:00
Jaroslav Škarvada
56ecbd362e tuned: Improved error messages
Made tuned error messages less verbose, but more descriptive if running without
debug option. Also made class from the tuned.utils.commands helper functions.
Its logging can be enabled / disabled.

Resolves: rhbz#1068699

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2014-09-24 16:15:06 +02:00
Jaroslav Škarvada
94e383a5ed plugin_cpu: added support for intel_pstate
The following intel_pstate parameters are now supported:
  min_perf_pct
  max_perf_pct
  no_turbo

Resolves: rhbz#996722

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2013-11-05 22:55:38 +01:00
Jaroslav Škarvada
adbdb8f4b2 plugin_cpu: consolidated some log messages
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2013-10-23 11:07:22 +02:00
Jaroslav Škarvada
59e259a3ce plugin_cpu: added support for x86_energy_perf_policy
This feature is controlled by the energy_perf_bias cpu plugin
option.

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2013-10-23 10:44:24 +02:00
Jaroslav Škarvada
f070213c64 utils: fixed packaging of pmqos-static
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2013-10-16 14:34:00 +02:00
Jaroslav Škarvada
f535dd52d9 cpu plugin: fixed cpupower workaround
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2013-03-19 16:12:24 +01:00
Jaroslav Škarvada
7088da1202 cpu plugin: fixed crash if cpupower is installed
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2013-03-04 14:32:35 +01:00
Jaroslav Škarvada
03a53346b1 disk plugin: use sysfs fallback if cpupower is missing
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2013-03-01 11:10:16 +01:00
Jaroslav Škarvada
b9459970fb cpu plugin: dropped multicore_powersave as kernel upstream already did
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2013-02-22 17:08:30 +01:00
Jaroslav Škarvada
d5017be612 sysctl plugin: use utils.execute for commands execution
Changed utils.execute to return more useful tuple (retcode, str) instead of str.

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2013-02-19 16:39:31 +01:00
Jan Vcelak
246559a5a5 cpu plugin: latency not supported per cpu, apply only on first device 2013-01-23 16:24:41 +01:00
Jan Vcelak
719c7efe2b cpu plugin: fix dynamic tuning, migrate to new plugin interface 2013-01-22 19:13:28 +01:00
Jan Vcelak
ed7c53533c disk plugin: migrate to new structure 2013-01-11 15:14:54 +01:00
Jan Vcelak
f4cc64a3a9 plugins: tuning units are handled within plugin classes
This change moves a lot of logic into the plugins, namely
the enumeration, seizing, and releasing of the devices.
However it allows the plugins to control the process in
more detail. This will be also utilised when tuning the
devices, which were dynamically added into the system.

WATCH OUT: only cpu plugin has been updated
2013-01-11 15:14:54 +01:00
Jan Vcelak
ff6b179455 cpu plugin: use hardware enumeration 2013-01-11 15:13:56 +01:00
Jaroslav Škarvada
3c7916e4fa plugin_cpu: fixed cpupower exec 2012-10-29 15:52:31 +01:00
Jan Vcelak
24887afbe5 cpu: support governor setting per CPU core, re-enable multicore_powersave option 2012-05-25 14:05:46 +02:00
Jan Vcelak
4e233b8ad1 fix cpu plugin initialization 2012-05-25 13:08:05 +02:00
Jan Vcelak
341e843df1 plugins: remove dynamic_tuning from options, was not conceptual 2012-05-25 11:58:48 +02:00
Jan Vcelak
492c182e7d cpu plugin: fix initialization 2012-05-21 22:57:11 +02:00