1
0
Fork 0

vm plugin: migrate to new plugin interface

This commit is contained in:
Jan Vcelak 2013-01-28 14:49:14 +01:00
parent f532f3d679
commit b078feecdf

View file

@ -13,38 +13,37 @@ class VMPlugin(base.Plugin):
Plugin for tuning memory management.
"""
@classmethod
def tunable_devices(self):
return ["vm"]
def _post_init(self):
self._dynamic_tuning = False
@classmethod
def _get_default_options(cls):
def _get_config_options(self):
return {
"transparent_hugepages" : None,
}
@classmethod
def _instance_init(self, instance):
instance._has_static_tuning = True
instance._has_dynamic_tuning = False
def _instance_cleanup(self, instance):
pass
def _thp_file(self):
return "/sys/kernel/mm/redhat_transparent_hugepage/enabled"
@command_set("transparent_hugepages")
def _set_transparent_hugepages(self, value):
if value not in ["always", "never"]:
log.warn("Incorrect transparent_hugepages value.")
log.warn("Incorrect 'transparent_hugepages' value.")
return
sys_file = VMPlugin._thp_file()
if not os.path.exists(sys_file):
return
tuned.utils.commands.write_to_file(sys_file, value)
sys_file = self._thp_file()
if os.path.exists(sys_file):
tuned.utils.commands.write_to_file(sys_file, value)
else:
log.warn("Option 'transparent_hugepages' is not supported on current hardware.")
@command_get("transparent_hugepages")
def _get_transparent_hugepages(self):
sys_file = VMPlugin._thp_file()
if not os.path.exists(sys_file):
sys_file = self._thp_file()
if os.path.exists(sys_file):
return tuned.utils.commands.get_active_option(tuned.utils.commands.read_file(sys_file))
else:
return None
return tuned.utils.commands.get_active_option(tuned.utils.commands.read_file(sys_file))