plugin_scheduler: make perf support optional
Requested in: https://src.fedoraproject.org/rpms/tuned/pull-request/8 Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
This commit is contained in:
parent
cc168b9782
commit
9535b07cbe
3 changed files with 25 additions and 6 deletions
|
|
@ -83,7 +83,7 @@ BuildRequires: %{_py}-mock
|
||||||
%endif
|
%endif
|
||||||
BuildRequires: %{_py}-pyudev
|
BuildRequires: %{_py}-pyudev
|
||||||
Requires: %{_py}-pyudev
|
Requires: %{_py}-pyudev
|
||||||
Requires: %{_py}-linux-procfs, %{_py}-perf
|
Requires: %{_py}-linux-procfs
|
||||||
Requires: %{_py}-inotify
|
Requires: %{_py}-inotify
|
||||||
%if %{without python3}
|
%if %{without python3}
|
||||||
Requires: %{_py}-schedutils
|
Requires: %{_py}-schedutils
|
||||||
|
|
@ -93,9 +93,6 @@ Requires: %{_py}-schedutils
|
||||||
# BuildRequires for 'make test'
|
# BuildRequires for 'make test'
|
||||||
BuildRequires: python3-dbus, python3-gobject-base
|
BuildRequires: python3-dbus, python3-gobject-base
|
||||||
Requires: python3-dbus, python3-gobject-base
|
Requires: python3-dbus, python3-gobject-base
|
||||||
%if 0%{?fedora} > 22 || 0%{?rhel} > 7
|
|
||||||
Recommends: dmidecode
|
|
||||||
%endif
|
|
||||||
%else
|
%else
|
||||||
# BuildRequires for 'make test'
|
# BuildRequires for 'make test'
|
||||||
BuildRequires: dbus-python, pygobject3-base
|
BuildRequires: dbus-python, pygobject3-base
|
||||||
|
|
@ -105,11 +102,15 @@ Requires: virt-what, ethtool, gawk
|
||||||
Requires: util-linux, dbus, polkit
|
Requires: util-linux, dbus, polkit
|
||||||
%if 0%{?fedora} > 22 || 0%{?rhel} > 7
|
%if 0%{?fedora} > 22 || 0%{?rhel} > 7
|
||||||
Recommends: dmidecode
|
Recommends: dmidecode
|
||||||
|
# https://src.fedoraproject.org/rpms/tuned/pull-request/8
|
||||||
|
Recommends: %{_py}-perf
|
||||||
# i686 excluded
|
# i686 excluded
|
||||||
Recommends: kernel-tools
|
Recommends: kernel-tools
|
||||||
Requires: hdparm
|
Requires: hdparm
|
||||||
Requires: kmod
|
Requires: kmod
|
||||||
Requires: iproute
|
Requires: iproute
|
||||||
|
%else
|
||||||
|
Requires: %{_py}-perf
|
||||||
%endif
|
%endif
|
||||||
# syspurpose
|
# syspurpose
|
||||||
%if 0%{?rhel} > 8
|
%if 0%{?rhel} > 8
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,9 @@ ACPI_DIR = "/sys/firmware/acpi"
|
||||||
# built-in functions configuration
|
# built-in functions configuration
|
||||||
SYSFS_CPUS_PATH = "/sys/devices/system/cpu"
|
SYSFS_CPUS_PATH = "/sys/devices/system/cpu"
|
||||||
|
|
||||||
|
# present CPUs
|
||||||
|
SYSFS_CPUS_PRESENT_PATH = "%s/present" % SYSFS_CPUS_PATH
|
||||||
|
|
||||||
# number of backups
|
# number of backups
|
||||||
LOG_FILE_COUNT = 2
|
LOG_FILE_COUNT = 2
|
||||||
LOG_FILE_MAXBYTES = 100*1000
|
LOG_FILE_MAXBYTES = 100*1000
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,12 @@ import tuned.logs
|
||||||
import re
|
import re
|
||||||
from subprocess import *
|
from subprocess import *
|
||||||
import threading
|
import threading
|
||||||
import perf
|
# perf is optional
|
||||||
|
try:
|
||||||
|
import perf
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
# if perf is unavailable, it will be disabled later
|
||||||
|
pass
|
||||||
import select
|
import select
|
||||||
import tuned.consts as consts
|
import tuned.consts as consts
|
||||||
import procfs
|
import procfs
|
||||||
|
|
@ -449,7 +454,15 @@ class SchedulerPlugin(base.Plugin):
|
||||||
self._ps_whitelist = ".*"
|
self._ps_whitelist = ".*"
|
||||||
self._ps_blacklist = ""
|
self._ps_blacklist = ""
|
||||||
self._cgroup_ps_blacklist_re = ""
|
self._cgroup_ps_blacklist_re = ""
|
||||||
self._cpus = perf.cpu_map()
|
# perf is optional, if unavailable, it will be disabled later
|
||||||
|
try:
|
||||||
|
self._cpus = perf.cpu_map()
|
||||||
|
except (NameError, AttributeError):
|
||||||
|
cpus = self._cmd.read_file(consts.SYSFS_CPUS_PRESENT_PATH)
|
||||||
|
# it's different type than perf.cpu_map(), but without perf we use it as iterable
|
||||||
|
# which should be compatible, fallback to single core CPU if sysfs is unavailable
|
||||||
|
self._cpus = self._cmd.cpulist_unpack(cpus) if cpus else [ 0 ]
|
||||||
|
|
||||||
self._scheduler_storage_key = self._storage_key(
|
self._scheduler_storage_key = self._storage_key(
|
||||||
command_name = "scheduler")
|
command_name = "scheduler")
|
||||||
self._irq_process = True
|
self._irq_process = True
|
||||||
|
|
@ -534,6 +547,8 @@ class SchedulerPlugin(base.Plugin):
|
||||||
instance._evlist.mmap(pages = perf_mmap_pages)
|
instance._evlist.mmap(pages = perf_mmap_pages)
|
||||||
# no perf
|
# no perf
|
||||||
except:
|
except:
|
||||||
|
log.warning("python-perf unavailable, disabling perf support and " \
|
||||||
|
"runtime tuning, you can try to (re)install python(3)-perf package")
|
||||||
instance._runtime_tuning = False
|
instance._runtime_tuning = False
|
||||||
|
|
||||||
def _instance_cleanup(self, instance):
|
def _instance_cleanup(self, instance):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue