1
0
Fork 0

tuned: Added support for >, < assignment modifiers in tuned.conf

These modifiers can specify when to assign new value considering
the old value.

E.g.:
readahead=>4096

means assign readahead 4096 only if the current value of readahaed
is lower than 4096 (i.e. the readahaed will be at least 4096).

Similarly for the < operator, it will assign the value only
if the current value is higher.

The modifiers are part of the value, not part of the equality
operator, thus the following is correct:
readahead= >4096

But the following isn't correct, but will probably also work
due to the nature how the value is parsed:
readahead=> 4096

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
This commit is contained in:
Jaroslav Škarvada 2014-05-07 17:02:59 +02:00
parent adffbb0ca1
commit 1d1c3a389c
2 changed files with 30 additions and 7 deletions

View file

@ -11,7 +11,7 @@ min_perf_pct=100
transparent_hugepages=always
[disk]
readahead=4096
readahead=>4096
[sysctl]
# ktune sysctl settings for rhel6 servers, maximizing i/o throughput

View file

@ -212,7 +212,7 @@ class Plugin(object):
def _instance_apply_dynamic(self, instance, device):
for option in filter(lambda opt: self._storage_get(instance, self._commands[opt], device) is None, self._options_used_by_dynamic):
self._save_current_value(instance, self._commands[option], device)
self._check_and_save_value(instance, self._commands[option], device)
self._instance_update_dynamic(instance, device)
@ -317,27 +317,50 @@ class Plugin(object):
for device in devices:
self._execute_device_command(instance, command, device, new_value)
def _save_current_value(self, instance, command, device = None):
def _check_and_save_value(self, instance, command, device = None, new_value = None):
if device is not None:
current_value = command["get"](device)
else:
current_value = command["get"]()
if new_value is not None:
nws = str(new_value)
op = nws[:1]
val = nws[1:]
try:
if op == ">":
if int(val) > int(current_value):
new_value = val;
else:
current_value = None
new_value = None
elif op == "<":
if int(val) < int(current_value):
new_value = val;
else:
current_value = None
new_value = None
except ValueError:
log.warn("cannot compare new value '%s' with current value '%s' by operator '%s', using '%s' directly as new value" % (val, current_value, new_value))
if current_value is not None:
self._storage_set(instance, command, current_value, device)
return new_value
def _execute_device_command(self, instance, command, device, new_value):
if command["custom"] is not None:
command["custom"](True, new_value, device)
else:
self._save_current_value(instance, command, device)
command["set"](new_value, device)
new_value = self._check_and_save_value(instance, command, device, new_value)
if new_value is not None:
command["set"](new_value, device)
def _execute_non_device_command(self, instance, command, new_value):
if command["custom"] is not None:
command["custom"](True, new_value)
else:
self._save_current_value(instance, command)
command["set"](new_value)
new_value = self._check_and_save_value(instance, command, None, new_value)
if new_value is not None:
command["set"](new_value)
def _cleanup_all_non_device_commands(self, instance):
for command in filter(lambda command: not command["per_device"], self._commands.values()):