|
|
4fe94b |
From 1d1c3a389c393afa1e88d5629f5dff85824fc92b Mon Sep 17 00:00:00 2001
|
|
|
4fe94b |
From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= <jskarvad@redhat.com>
|
|
|
4fe94b |
Date: Wed, 7 May 2014 17:02:59 +0200
|
|
|
4fe94b |
Subject: tuned: Added support for >, < assignment modifiers in tuned.conf
|
|
|
4fe94b |
MIME-Version: 1.0
|
|
|
4fe94b |
Content-Type: text/plain; charset=UTF-8
|
|
|
4fe94b |
Content-Transfer-Encoding: 8bit
|
|
|
4fe94b |
|
|
|
4fe94b |
These modifiers can specify when to assign new value considering
|
|
|
4fe94b |
the old value.
|
|
|
4fe94b |
|
|
|
4fe94b |
E.g.:
|
|
|
4fe94b |
readahead=>4096
|
|
|
4fe94b |
|
|
|
4fe94b |
means assign readahead 4096 only if the current value of readahaed
|
|
|
4fe94b |
is lower than 4096 (i.e. the readahaed will be at least 4096).
|
|
|
4fe94b |
|
|
|
4fe94b |
Similarly for the < operator, it will assign the value only
|
|
|
4fe94b |
if the current value is higher.
|
|
|
4fe94b |
|
|
|
4fe94b |
The modifiers are part of the value, not part of the equality
|
|
|
4fe94b |
operator, thus the following is correct:
|
|
|
4fe94b |
readahead= >4096
|
|
|
4fe94b |
|
|
|
4fe94b |
But the following isn't correct, but will probably also work
|
|
|
4fe94b |
due to the nature how the value is parsed:
|
|
|
4fe94b |
readahead=> 4096
|
|
|
4fe94b |
|
|
|
4fe94b |
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
|
|
|
4fe94b |
|
|
|
4fe94b |
diff --git a/profiles/throughput-performance/tuned.conf b/profiles/throughput-performance/tuned.conf
|
|
|
4fe94b |
index dae02dc..42473a9 100644
|
|
|
4fe94b |
--- a/profiles/throughput-performance/tuned.conf
|
|
|
4fe94b |
+++ b/profiles/throughput-performance/tuned.conf
|
|
|
4fe94b |
@@ -11,7 +11,7 @@ min_perf_pct=100
|
|
|
4fe94b |
transparent_hugepages=always
|
|
|
4fe94b |
|
|
|
4fe94b |
[disk]
|
|
|
4fe94b |
-readahead=4096
|
|
|
4fe94b |
+readahead=>4096
|
|
|
4fe94b |
|
|
|
4fe94b |
[sysctl]
|
|
|
4fe94b |
# ktune sysctl settings for rhel6 servers, maximizing i/o throughput
|
|
|
4fe94b |
diff --git a/tuned/plugins/base.py b/tuned/plugins/base.py
|
|
|
4fe94b |
index bad487f..f0faf38 100644
|
|
|
4fe94b |
--- a/tuned/plugins/base.py
|
|
|
4fe94b |
+++ b/tuned/plugins/base.py
|
|
|
4fe94b |
@@ -212,7 +212,7 @@ class Plugin(object):
|
|
|
4fe94b |
|
|
|
4fe94b |
def _instance_apply_dynamic(self, instance, device):
|
|
|
4fe94b |
for option in filter(lambda opt: self._storage_get(instance, self._commands[opt], device) is None, self._options_used_by_dynamic):
|
|
|
4fe94b |
- self._save_current_value(instance, self._commands[option], device)
|
|
|
4fe94b |
+ self._check_and_save_value(instance, self._commands[option], device)
|
|
|
4fe94b |
|
|
|
4fe94b |
self._instance_update_dynamic(instance, device)
|
|
|
4fe94b |
|
|
|
4fe94b |
@@ -317,27 +317,50 @@ class Plugin(object):
|
|
|
4fe94b |
for device in devices:
|
|
|
4fe94b |
self._execute_device_command(instance, command, device, new_value)
|
|
|
4fe94b |
|
|
|
4fe94b |
- def _save_current_value(self, instance, command, device = None):
|
|
|
4fe94b |
+ def _check_and_save_value(self, instance, command, device = None, new_value = None):
|
|
|
4fe94b |
if device is not None:
|
|
|
4fe94b |
current_value = command["get"](device)
|
|
|
4fe94b |
else:
|
|
|
4fe94b |
current_value = command["get"]()
|
|
|
4fe94b |
+ if new_value is not None:
|
|
|
4fe94b |
+ nws = str(new_value)
|
|
|
4fe94b |
+ op = nws[:1]
|
|
|
4fe94b |
+ val = nws[1:]
|
|
|
4fe94b |
+ try:
|
|
|
4fe94b |
+ if op == ">":
|
|
|
4fe94b |
+ if int(val) > int(current_value):
|
|
|
4fe94b |
+ new_value = val;
|
|
|
4fe94b |
+ else:
|
|
|
4fe94b |
+ current_value = None
|
|
|
4fe94b |
+ new_value = None
|
|
|
4fe94b |
+ elif op == "<":
|
|
|
4fe94b |
+ if int(val) < int(current_value):
|
|
|
4fe94b |
+ new_value = val;
|
|
|
4fe94b |
+ else:
|
|
|
4fe94b |
+ current_value = None
|
|
|
4fe94b |
+ new_value = None
|
|
|
4fe94b |
+ except ValueError:
|
|
|
4fe94b |
+ log.warn("cannot compare new value '%s' with current value '%s' by operator '%s', using '%s' directly as new value" % (val, current_value, op, new_value))
|
|
|
4fe94b |
+
|
|
|
4fe94b |
if current_value is not None:
|
|
|
4fe94b |
self._storage_set(instance, command, current_value, device)
|
|
|
4fe94b |
+ return new_value
|
|
|
4fe94b |
|
|
|
4fe94b |
def _execute_device_command(self, instance, command, device, new_value):
|
|
|
4fe94b |
if command["custom"] is not None:
|
|
|
4fe94b |
command["custom"](True, new_value, device)
|
|
|
4fe94b |
else:
|
|
|
4fe94b |
- self._save_current_value(instance, command, device)
|
|
|
4fe94b |
- command["set"](new_value, device)
|
|
|
4fe94b |
+ new_value = self._check_and_save_value(instance, command, device, new_value)
|
|
|
4fe94b |
+ if new_value is not None:
|
|
|
4fe94b |
+ command["set"](new_value, device)
|
|
|
4fe94b |
|
|
|
4fe94b |
def _execute_non_device_command(self, instance, command, new_value):
|
|
|
4fe94b |
if command["custom"] is not None:
|
|
|
4fe94b |
command["custom"](True, new_value)
|
|
|
4fe94b |
else:
|
|
|
4fe94b |
- self._save_current_value(instance, command)
|
|
|
4fe94b |
- command["set"](new_value)
|
|
|
4fe94b |
+ new_value = self._check_and_save_value(instance, command, None, new_value)
|
|
|
4fe94b |
+ if new_value is not None:
|
|
|
4fe94b |
+ command["set"](new_value)
|
|
|
4fe94b |
|
|
|
4fe94b |
def _cleanup_all_non_device_commands(self, instance):
|
|
|
4fe94b |
for command in filter(lambda command: not command["per_device"], self._commands.values()):
|
|
|
4fe94b |
--
|
|
|
4fe94b |
cgit v0.10.1
|
|
|
4fe94b |
|