1
0
Fork 0
Commit graph

1240 commits

Author SHA1 Message Date
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
4287b61fdb monitors: Fix adding a hotplugged device to a monitor
If a device, namely a disk, is hotplugged after tuned is started, it
won't be present in Monitor._available_devices. Consequently, it won't
get added to the monitor and so dynamic tuning won't work for the
device. Let's fix that by refreshing the list of available devices when
adding a device to a monitor.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-03-06 19:51:10 +01:00
Ondřej Lysoněk
04168eaa57 Remove unused _remove_unused_filters()
_remove_unused_filters() is not used anywhere and the udev's
remove_filter() is broken anyway:
https://github.com/systemd/systemd/issues/11529

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-03-06 19:51:10 +01:00
Ondřej Lysoněk
145b4551b4 Log full stack trace of unhandled exceptions as an error
Hiding the full stack trace in the debug output is not useful - it hides
information that would be useful for us when diagnosing a failure. It's
not always possible (and it's certainly an unnecessary burden for the
users) to later reproduce the issue with debug mode on. As a bonus, the
traceback will now stand out in the log, increasing the likelihood
that it will get noticed and reported.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-03-06 19:51:10 +01:00
Jaroslav Škarvada
c7b92148c2
Merge pull request #164 from olysonek/none_comparison
Fix checking for None values
2019-03-06 16:21:17 +01:00
Ondřej Lysoněk
9e6913231d Fix checking for None values
In python, 'is None' should be used instead of '== None' to check if
something is None.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-03-06 15:46:34 +01:00
Jaroslav Škarvada
e5fbac1863
Merge pull request #163 from olysonek/profile_dir_fixup
Update tuned.conf(5) and powertop2tuned to use ${i:PROFILE_DIR}
2019-03-06 15:14:33 +01:00
Jaroslav Škarvada
30d5fdb78e
Merge pull request #160 from olysonek/sysctl
Apply sysctl settings by writing to /proc/sys directly
2019-03-06 15:13:19 +01:00
Jaroslav Škarvada
aa5bda3ce1
balanced: added explicit priority to CPU plugin instance
Related: #158

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2019-03-06 11:28:56 +01:00
Jaroslav Škarvada
ec4ce18c8f
Merge pull request #158 from watologo1/fix_conservative_module_loading
conservative governor may be compiled as module and needs explicit lo…
2019-03-06 11:25:21 +01:00
Ondřej Lysoněk
054e24d451 powertop2tuned: Use ${i:PROFILE_DIR} in the generated profile
Since commit cd4943bdbf, it is recommended to use ${i:PROFILE_DIR}
in paths to scripts, in order to make the paths absolute. So let's make
the profile generated by powertop2tuned conform to that recommendation.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-03-05 10:20:05 +01:00
Ondřej Lysoněk
a484c644c5 man: Use ${i:PROFILE_DIR} in the example profile
Since commit cd4943bdbf, it is recommended to use ${i:PROFILE_DIR}
in paths to scripts, in order to make the paths absolute. It's not
required (yet) though.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-03-05 10:16:44 +01:00
Jaroslav Škarvada
18118c2814 s2kb: fixed to be compatible with python3
Resolves: rhbz#1684122

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2019-02-28 14:42:00 +01:00
Jaroslav Škarvada
7332a0917f
Merge pull request #153 from nealepetrillo/master
Added profile for HPC compute workloads
2019-02-28 10:00:42 +01:00
Ondřej Lysoněk
9953d35dd6 Use built-in functionality to apply system sysctl
In order to avoid the overhead of executing 'sysctl --system', sysctl
settings from sysctl configuration files are now applied by directly
writing to /proc/sys.

Fixes #146
Resolves: rhbz#1663412

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-02-25 15:48:53 +01:00
Ondřej Lysoněk
4331c39843 sysctl: Don't attempt to set a setting if reading the original fails
Previously it could (theoretically) happen that reading the original
value of a setting fails, but then a new value is successfully written.
This would result in Tuned not being able to restore the original value
of the setting.

Even though I don't know of a situation where this could happen in
practice, the code was logically wrong, so let's fix it.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-02-25 15:44:19 +01:00
Ondřej Lysoněk
f85073c7c5 sysctl: Transform bound methods into functions where possible
By limiting the number of bound methods and using regular functions
instead of methods where possible, we make the code easier to reason
about. For example, now we can be sure that _get_sysctl_path,
_read_sysctl and _write_sysctl won't touch attributes of SysctlPlugin.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-02-25 15:43:08 +01:00
Ondřej Lysoněk
3166940015 sysctl: Set individual parameters by writing to /proc/sys
Set individual sysctl parameters by directly writing to /proc/sys in
order to avoid the overhead of executing the 'sysctl' program for each
setting.

We originally thought about rewriting the functionality using procfs.sysctl
from python-procfs, however I decided to implement it directly, because
it's trivial and because the error handling in procfs.sysctl is not
sufficient for our needs.

The list of deprecated sysctl settings was taken from the sysctl program
from procps-ng.

Fixes #146
Resolves: rhbz#1663412

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-02-25 15:41:33 +01:00
Petrillo, Neale Angelo
8f6433336d Removed superfluous sched_migration_cost_ns declaration
kernel.sched_migration_cost_ns=5000000 was being defined here even though it was defined in the included latency-performance profile. Removed to eliminate redundancy.
2019-02-22 12:52:51 -05:00
Jaroslav Škarvada
95cf27ae35
Merge pull request #159 from olysonek/lint
Makefile: Drop a workaround for a pylint bug and run pylint on tests too
2019-02-19 18:03:29 +01:00
Ondřej Lysoněk
afa6611f39 Makefile: Run pylint on the tests too
The tests are now in a good shape, so we can now run pylint on them
without getting a huge list of errors. In fact, we should lint them
to decrease the likelihood they'll go stale again.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-02-19 16:26:27 +01:00
Ondřej Lysoněk
32666498ba tests: Fix import of Mapping
Since python3.3, Mapping has been moved to collections.abc and starting
with python3.8, it will no longer be available as collections.Mapping.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-02-19 16:26:27 +01:00
Ondřej Lysoněk
a5c39d83f3 Makefile: Drop a workaround for a pylint bug
The bug is no longer reproducible with
python3-pylint-2.1.1-2.fc29.noarch.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-02-19 16:26:27 +01:00
Jaroslav Škarvada
2441fe6384
Merge pull request #156 from TomasKorbar/tuned-gui-2.0
Remove obsolete policy and unnecessary import from tuned gui
2019-02-19 10:27:06 +01:00
Jaroslav Škarvada
b35f4a97cd
Merge pull request #157 from olysonek/master
Increase max log file size in the default config file
2019-02-19 10:25:36 +01:00
Thomas Renninger
af269d11ae conservative governor may be compiled as module and needs explicit loading
Tested on an AMD machine with acpi-cpufreq kernel driver providing
ondemand, conservative,... governors.

Without this line, one gets:
tuned.plugins.plugin_cpu: ignoring governor 'conservative' on cpu 'cpu7', it
is not supported

when switching to balanced profile.
With this line you see:
tuned.plugins.plugin_cpu: setting governor 'ondemand' on cpu 'cpu2'

Be careful: Order matters!
tuned seem to read profile config file line by line or section by section
and directly tries to apply things.

If order of these lines are exchanged:
[modules]
cpufreq_conservative=+r

[cpu]
governor=conservative

you fall back to previous error again. Therefore the newly introduced
[modules] section is not put at the end, but nearly at top.
2019-02-13 15:38:49 +01:00
Ondřej Lysoněk
9574a63e50 Increase max log file size in the default config file
100KB is not a lot, it can fill up quickly.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-02-08 14:34:30 +01:00
Tomas Korbar
0c7ec6e358 Remove unnecessary import from tuned-gui.py
Signed-off-by: Tomas Korbar <tkorbar@redhat.com>
2019-02-04 11:04:52 +01:00
Tomas Korbar
adcb160b97 Remove obsolete polkit policy for tuned-gui
Tuned gui does not need root privileges for it to work now
For more information see #138

Signed-off-by: Tomas Korbar <tkorbar@redhat.com>
2019-02-04 11:04:52 +01:00
Jaroslav Škarvada
506cf930fa
Merge pull request #154 from olysonek/dco
Add contribution guidelines
2019-01-31 18:42:55 +01:00
Jaroslav Škarvada
218c68bebb
Merge pull request #152 from redhatrises/tuned_gui_typo
Fix typo in tuned-gui
2019-01-31 18:39:53 +01:00
Jaroslav Škarvada
2d7b5a1d73
Merge pull request #151 from watologo1/intel_amd_ppc_differing
Differ archs and x86 CPU vendors in plugin_cpu
2019-01-31 18:38:58 +01:00
Jaroslav Škarvada
7a05a07b0c
Merge pull request #147 from mrksu/documentation
Documentation
2019-01-31 18:20:37 +01:00
Jaroslav Škarvada
17c44cca27
Merge pull request #143 from TomasKorbar/rhbz1631744
Reload profile configuration on SIGHUP
2019-01-31 16:43:47 +01:00
Jaroslav Škarvada
778576af60
Merge pull request #155 from redhat-performance/revert-140-rhbz1592743
Revert "Make copy of instance's devices before executing changes to system"
2019-01-31 16:35:29 +01:00
Jaroslav Škarvada
55078cbd0c
Revert "Make copy of instance's devices before executing changes to system" 2019-01-31 16:32:16 +01:00
Jaroslav Škarvada
f79c6292b6
Merge pull request #142 from TomasKorbar/rhbz1613379
Fix unit configuration reading
2019-01-31 16:15:21 +01:00
Jaroslav Škarvada
f5493aea57
Merge pull request #141 from TomasKorbar/rhbz1595156
fix disk plugin/plugout problem
2019-01-31 16:14:06 +01:00
Jaroslav Škarvada
265152ab00
Merge pull request #140 from TomasKorbar/rhbz1592743
Make copy of instance's devices before executing changes to system
2019-01-31 16:11:42 +01:00
Jaroslav Škarvada
8f82779a7f
Merge pull request #138 from TomasKorbar/tuned-gui-2.0
Add support for config options hints and fix running under normal user
2019-01-31 16:08:01 +01:00
Ondřej Lysoněk
86abd82ced Add contribution guidelines
This is an attempt to formalize the process of contributing to Tuned
and formulate what is expected from contributors. From now on, all
contributors are expected to follow the guidelines.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-01-31 11:19:16 +01:00
Neale Petrillo
da6a2925af
Update tuned.conf 2019-01-30 14:41:11 -05:00
Neale Petrillo
6c8c9ce837
Update tuned.conf 2019-01-30 14:30:39 -05:00
Tomas Korbar
941fc6e2ea Fix check in add and remove device methods of Monitor class
Contribution to f563c7d
2019-01-29 12:36:49 +01:00
Tomas Korbar
a2219675f2 fix disk plugin/plugout problem
when udev sends remove event it does not send any device
attributes with it so _device_is_supported check must be omitted

Resolves: rhbz#1595156
2019-01-28 16:05:03 +01:00
Gabe
d24cb4e58c Fix typo in tuned-gui
- Fix typos for tuned daemon not running prompt
2019-01-28 04:36:14 -07:00
Petrillo, Neale Angelo
550a3f1d1e Initial commit of HPC compute profile 2019-01-25 21:13:54 -05: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
2cc3d74798 plugin_disk: Fix checking the 'removable' attribute on python3
The 'removable' attribute is a bytestring, so it will never be equal to
"0" in python3. Check equality with b"0" instead.

The patch was originally written by Tomáš Korbař.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2019-01-24 16:33:02 +01:00
Jaroslav Škarvada
668bf7448d
Minor readme update
Mentioned web page.

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2019-01-19 18:54:27 +01:00