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
|
||||
BuildRequires: %{_py}-pyudev
|
||||
Requires: %{_py}-pyudev
|
||||
Requires: %{_py}-linux-procfs, %{_py}-perf
|
||||
Requires: %{_py}-linux-procfs
|
||||
Requires: %{_py}-inotify
|
||||
%if %{without python3}
|
||||
Requires: %{_py}-schedutils
|
||||
|
|
@ -93,9 +93,6 @@ Requires: %{_py}-schedutils
|
|||
# BuildRequires for 'make test'
|
||||
BuildRequires: python3-dbus, python3-gobject-base
|
||||
Requires: python3-dbus, python3-gobject-base
|
||||
%if 0%{?fedora} > 22 || 0%{?rhel} > 7
|
||||
Recommends: dmidecode
|
||||
%endif
|
||||
%else
|
||||
# BuildRequires for 'make test'
|
||||
BuildRequires: dbus-python, pygobject3-base
|
||||
|
|
@ -105,11 +102,15 @@ Requires: virt-what, ethtool, gawk
|
|||
Requires: util-linux, dbus, polkit
|
||||
%if 0%{?fedora} > 22 || 0%{?rhel} > 7
|
||||
Recommends: dmidecode
|
||||
# https://src.fedoraproject.org/rpms/tuned/pull-request/8
|
||||
Recommends: %{_py}-perf
|
||||
# i686 excluded
|
||||
Recommends: kernel-tools
|
||||
Requires: hdparm
|
||||
Requires: kmod
|
||||
Requires: iproute
|
||||
%else
|
||||
Requires: %{_py}-perf
|
||||
%endif
|
||||
# syspurpose
|
||||
%if 0%{?rhel} > 8
|
||||
|
|
|
|||
|
|
@ -77,6 +77,9 @@ ACPI_DIR = "/sys/firmware/acpi"
|
|||
# built-in functions configuration
|
||||
SYSFS_CPUS_PATH = "/sys/devices/system/cpu"
|
||||
|
||||
# present CPUs
|
||||
SYSFS_CPUS_PRESENT_PATH = "%s/present" % SYSFS_CPUS_PATH
|
||||
|
||||
# number of backups
|
||||
LOG_FILE_COUNT = 2
|
||||
LOG_FILE_MAXBYTES = 100*1000
|
||||
|
|
|
|||
|
|
@ -8,7 +8,12 @@ import tuned.logs
|
|||
import re
|
||||
from subprocess import *
|
||||
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 tuned.consts as consts
|
||||
import procfs
|
||||
|
|
@ -449,7 +454,15 @@ class SchedulerPlugin(base.Plugin):
|
|||
self._ps_whitelist = ".*"
|
||||
self._ps_blacklist = ""
|
||||
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(
|
||||
command_name = "scheduler")
|
||||
self._irq_process = True
|
||||
|
|
@ -534,6 +547,8 @@ class SchedulerPlugin(base.Plugin):
|
|||
instance._evlist.mmap(pages = perf_mmap_pages)
|
||||
# no perf
|
||||
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
|
||||
|
||||
def _instance_cleanup(self, instance):
|
||||
|
|
|
|||
Loading…
Reference in a new issue