Add an ACPI plugin
Resolves: RHEL-16966 At this point, the plugin supports setting a single sysfs attribute, platform_profile. The 3 basic ACPI platform profiles are low-power, balanced, and performance. These are mapped to the generic powersave, balanced, and *-performance TuneD profiles.
This commit is contained in:
parent
bcfbd5de11
commit
9b72d697df
8 changed files with 123 additions and 0 deletions
|
|
@ -215,3 +215,27 @@ cmdline=isolcpus=2
|
|||
|
||||
====
|
||||
--
|
||||
|
||||
`acpi`::
|
||||
|
||||
Configures the ACPI driver.
|
||||
+
|
||||
The only currently supported option is
|
||||
[option]`platform_profile`, which sets the ACPI
|
||||
platform profile sysfs attribute,
|
||||
a generic power/performance preference API for other drivers.
|
||||
Multiple profiles can be specified, separated by `|`.
|
||||
The first available profile is selected.
|
||||
+
|
||||
--
|
||||
.Selecting a platform profile
|
||||
====
|
||||
----
|
||||
[acpi]
|
||||
platform_profile=low-power|quiet
|
||||
----
|
||||
Using this option, *TuneD* will try to set the platform profile
|
||||
to `low-power`. If that fails (e.g, because the system does not
|
||||
support the profile), it will try to set it to `quiet`.
|
||||
====
|
||||
--
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ energy_perf_bias=performance
|
|||
min_perf_pct=100
|
||||
force_latency=99
|
||||
|
||||
[acpi]
|
||||
platform_profile=performance
|
||||
|
||||
[disk]
|
||||
readahead=>4096
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ governor=conservative|powersave
|
|||
energy_perf_bias=normal
|
||||
energy_performance_preference=balance_performance
|
||||
|
||||
[acpi]
|
||||
platform_profile=balanced
|
||||
|
||||
[audio]
|
||||
timeout=10
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ governor=performance
|
|||
energy_perf_bias=performance
|
||||
min_perf_pct=100
|
||||
|
||||
[acpi]
|
||||
platform_profile=performance
|
||||
|
||||
[sysctl]
|
||||
# If a workload mostly uses anonymous memory and it hits this limit, the entire
|
||||
# working set is buffered for I/O, and any more write buffering would require
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ governor=ondemand|powersave
|
|||
energy_perf_bias=powersave|power
|
||||
energy_performance_preference=power
|
||||
|
||||
[acpi]
|
||||
platform_profile=low-power|quiet
|
||||
|
||||
[eeepc_she]
|
||||
|
||||
[vm]
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ energy_perf_bias=performance
|
|||
min_perf_pct=100
|
||||
energy_performance_preference=performance
|
||||
|
||||
[acpi]
|
||||
platform_profile=performance
|
||||
|
||||
# Marvell ThunderX
|
||||
[vm.thunderx]
|
||||
type=vm
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ SYSTEMD_CPUAFFINITY_VAR = "CPUAffinity"
|
|||
# irqbalance plugin configuration
|
||||
IRQBALANCE_SYSCONFIG_FILE = "/etc/sysconfig/irqbalance"
|
||||
|
||||
# acpi plugin configuration
|
||||
ACPI_DIR = "/sys/firmware/acpi"
|
||||
|
||||
# built-in functions configuration
|
||||
SYSFS_CPUS_PATH = "/sys/devices/system/cpu"
|
||||
|
||||
|
|
|
|||
81
tuned/plugins/plugin_acpi.py
Normal file
81
tuned/plugins/plugin_acpi.py
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
from . import base
|
||||
from .decorators import *
|
||||
import os
|
||||
import errno
|
||||
import tuned.logs
|
||||
from tuned.consts import ACPI_DIR
|
||||
|
||||
log = tuned.logs.get()
|
||||
|
||||
|
||||
class ACPIPlugin(base.Plugin):
|
||||
"""
|
||||
`acpi`::
|
||||
|
||||
Configures the ACPI driver.
|
||||
+
|
||||
The only currently supported option is
|
||||
[option]`platform_profile`, which sets the ACPI
|
||||
platform profile sysfs attribute,
|
||||
a generic power/performance preference API for other drivers.
|
||||
Multiple profiles can be specified, separated by `|`.
|
||||
The first available profile is selected.
|
||||
+
|
||||
--
|
||||
.Selecting a platform profile
|
||||
====
|
||||
----
|
||||
[acpi]
|
||||
platform_profile=balanced|low-power
|
||||
----
|
||||
Using this option, *TuneD* will try to set the platform profile
|
||||
to `balanced`. If that fails, it will try to set it to `low-power`.
|
||||
====
|
||||
--
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ACPIPlugin, self).__init__(*args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def _get_config_options(cls):
|
||||
return {"platform_profile": None}
|
||||
|
||||
def _instance_init(self, instance):
|
||||
instance._has_static_tuning = True
|
||||
instance._has_dynamic_tuning = False
|
||||
|
||||
def _instance_cleanup(self, instance):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def _platform_profile_choices_path(cls):
|
||||
return os.path.join(ACPI_DIR, "platform_profile_choices")
|
||||
|
||||
@classmethod
|
||||
def _platform_profile_path(cls):
|
||||
return os.path.join(ACPI_DIR, "platform_profile")
|
||||
|
||||
@command_set("platform_profile")
|
||||
def _set_platform_profile(self, profiles, sim, remove):
|
||||
if not os.path.isfile(self._platform_profile_path()):
|
||||
log.debug("ACPI platform_profile is not supported on this system")
|
||||
return None
|
||||
profiles = [profile.strip() for profile in profiles.split('|')]
|
||||
avail_profiles = set(self._cmd.read_file(self._platform_profile_choices_path()).split())
|
||||
for profile in profiles:
|
||||
if profile in avail_profiles:
|
||||
if not sim:
|
||||
log.info("Setting platform_profile to '%s'" % profile)
|
||||
self._cmd.write_to_file(self._platform_profile_path(), profile, \
|
||||
no_error=[errno.ENOENT] if remove else False)
|
||||
return profile
|
||||
log.warn("Requested platform_profile '%s' unavailable" % profile)
|
||||
log.error("Failed to set platform_profile. Is the value in the profile correct?")
|
||||
return None
|
||||
|
||||
@command_get("platform_profile")
|
||||
def _get_platform_profile(self, ignore_missing=False):
|
||||
if not os.path.isfile(self._platform_profile_path()):
|
||||
log.debug("ACPI platform_profile is not supported on this system")
|
||||
return None
|
||||
return self._cmd.read_file(self._platform_profile_path()).strip()
|
||||
Loading…
Reference in a new issue