diff --git a/tuned-main.conf b/tuned-main.conf index 40c4be2..aeb9e4e 100644 --- a/tuned-main.conf +++ b/tuned-main.conf @@ -39,3 +39,13 @@ log_file_count = 2 # Log file max size log_file_max_size = 1MB + +# Preset system uname string for architecture specific tuning. +# It can be used to force tuning for specific architecture. +# If commented, "uname" will be called to fill its content. +# uname_string = x86_64 + +# Preset system cpuinfo string for architecture specific tuning. +# It can be used to force tuning for specific architecture. +# If commented, "/proc/cpuinfo" will be read to fill its content. +# cpuinfo_string = Intel diff --git a/tuned/consts.py b/tuned/consts.py index 40928ec..e68205b 100644 --- a/tuned/consts.py +++ b/tuned/consts.py @@ -71,6 +71,8 @@ CFG_RECOMMEND_COMMAND = "recommend_command" CFG_REAPPLY_SYSCTL = "reapply_sysctl" CFG_DEFAULT_INSTANCE_PRIORITY = "default_instance_priority" CFG_UDEV_BUFFER_SIZE = "udev_buffer_size" +CFG_UNAME_STRING = "uname_string" +CFG_CPUINFO_STRING = "cpuinfo_string" # no_daemon mode CFG_DEF_DAEMON = True diff --git a/tuned/daemon/application.py b/tuned/daemon/application.py index 396106b..18d54ce 100644 --- a/tuned/daemon/application.py +++ b/tuned/daemon/application.py @@ -41,7 +41,7 @@ class Application(object): def_instance_priority = int(self.config.get(consts.CFG_DEFAULT_INSTANCE_PRIORITY, consts.CFG_DEF_DEFAULT_INSTANCE_PRIORITY)) unit_manager = units.Manager( plugins_repository, monitors_repository, - def_instance_priority, hardware_inventory) + def_instance_priority, hardware_inventory, self.config) profile_factory = profiles.Factory() profile_merger = profiles.Merger() diff --git a/tuned/units/manager.py b/tuned/units/manager.py index 2fee283..56d255e 100644 --- a/tuned/units/manager.py +++ b/tuned/units/manager.py @@ -6,6 +6,7 @@ import tuned.exceptions import tuned.logs import tuned.plugins.exceptions import tuned.consts as consts +from tuned.utils.global_config import GlobalConfig from tuned.utils.commands import commands log = tuned.logs.get() @@ -18,7 +19,7 @@ class Manager(object): """ def __init__(self, plugins_repository, monitors_repository, - def_instance_priority, hardware_inventory): + def_instance_priority, hardware_inventory, config = None): super(Manager, self).__init__() self._plugins_repository = plugins_repository self._monitors_repository = monitors_repository @@ -26,6 +27,7 @@ class Manager(object): self._hardware_inventory = hardware_inventory self._instances = [] self._plugins = [] + self._config = config or GlobalConfig() self._cmd = commands() @property @@ -43,15 +45,19 @@ class Manager(object): def _unit_matches_cpuinfo(self, unit): if unit.cpuinfo_regex is None: return True - return re.search(unit.cpuinfo_regex, - self._cmd.read_file("/proc/cpuinfo"), + cpuinfo_string = self._config.get(consts.CFG_CPUINFO_STRING) + if cpuinfo_string is None: + cpuinfo_string = self._cmd.read_file("/proc/cpuinfo") + return re.search(unit.cpuinfo_regex, cpuinfo_string, re.MULTILINE) is not None def _unit_matches_uname(self, unit): if unit.uname_regex is None: return True - return re.search(unit.uname_regex, - " ".join(os.uname()), + uname_string = self._config.get(consts.CFG_UNAME_STRING) + if uname_string is None: + uname_string = " ".join(os.uname()) + return re.search(unit.uname_regex, uname_string, re.MULTILINE) is not None def create(self, instances_config):