plugins: added plugin vm to tune virtual memory management
Currently only transparent hugepages settings is supported.
This commit is contained in:
parent
bc5538c16c
commit
3d57c489cc
1 changed files with 50 additions and 0 deletions
50
tuned/plugins/plugin_vm.py
Normal file
50
tuned/plugins/plugin_vm.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import base
|
||||
from decorators import *
|
||||
import tuned.logs
|
||||
|
||||
import os
|
||||
import struct
|
||||
import glob
|
||||
|
||||
log = tuned.logs.get()
|
||||
|
||||
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):
|
||||
return {
|
||||
"transparent_hugepages" : None,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
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.")
|
||||
return
|
||||
|
||||
sys_file = VMPlugin._thp_file()
|
||||
if not os.path.exists(sys_file):
|
||||
return
|
||||
|
||||
tuned.utils.commands.write_to_file(sys_file, value)
|
||||
|
||||
@command_get("transparent_hugepages")
|
||||
def _get_transparent_hugepages(self):
|
||||
sys_file = VMPlugin._thp_file()
|
||||
if not os.path.exists(sys_file):
|
||||
return None
|
||||
return tuned.utils.commands.get_active_option(tuned.utils.commands.read_file(sys_file))
|
||||
Loading…
Reference in a new issue