Blob Blame History Raw
From 66924b842228e7178301aa399d30459155b35762 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= <olysonek@redhat.com>
Date: Tue, 9 Jul 2019 11:31:20 +0200
Subject: [PATCH 1/3] plugin_script: Execute all scripts regardless of errors
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Due to commit d4038a7e64af3, if a script fails to execute or its exit
code is non-zero, no subsequent scripts are executed. This seems
logically wrong and it causes problems especially during rollback as some
tunings may not be reverted due to this behaviour. Also, it appears it
was not the intention of that commit to change this behaviour - the
intention rather seems to have been to make _call_scripts return
success/error information for use by the verification mechanism.

So let's aggregate the success/error information instead.

Related: https://github.com/redhat-performance/tuned/pull/194

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
---
 tuned/plugins/plugin_script.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tuned/plugins/plugin_script.py b/tuned/plugins/plugin_script.py
index 940c1f9a..19b7fc60 100644
--- a/tuned/plugins/plugin_script.py
+++ b/tuned/plugins/plugin_script.py
@@ -31,6 +31,7 @@ def _instance_cleanup(self, instance):
 		pass
 
 	def _call_scripts(self, scripts, arguments):
+		ret = True
 		for script in scripts:
 			environ = os.environ
 			environ.update(self._variables.get_env())
@@ -47,11 +48,11 @@ def _call_scripts(self, scripts, arguments):
 					log.error("script '%s' error output: '%s'" % (script, err[:-1]))
 				if proc.returncode:
 					log.error("script '%s' returned error code: %d" % (script, proc.returncode))
-					return False
+					ret = False
 			except (OSError,IOError) as e:
 				log.error("script '%s' error: %s" % (script, e))
-				return False
-		return True
+				ret = False
+		return ret
 
 	def _instance_apply_static(self, instance):
 		super(ScriptPlugin, self)._instance_apply_static(instance)

From 4a8e64994eb978ada0c7e23702e96c82352cc222 Mon Sep 17 00:00:00 2001
From: Peter Xu <peterx@redhat.com>
Date: Thu, 4 Jul 2019 11:16:54 +0800
Subject: [PATCH 2/3] cpu-partitioning: Introduce irqbalance helpers and use

Provide irqbalance_banned_cpus_{setup|clear} for tuning irqbalance.
Use them in cpu-partitioning.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 profiles/cpu-partitioning/script.sh |  5 ++---
 profiles/functions                  | 11 +++++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/profiles/cpu-partitioning/script.sh b/profiles/cpu-partitioning/script.sh
index efe9bcbb..4d0a08b2 100755
--- a/profiles/cpu-partitioning/script.sh
+++ b/profiles/cpu-partitioning/script.sh
@@ -39,8 +39,7 @@ start() {
     mkdir -p "${TUNED_tmpdir}/usr/lib/dracut/hooks/pre-udev"
     cp /etc/systemd/system.conf "${TUNED_tmpdir}/etc/systemd/"
     cp 00-tuned-pre-udev.sh "${TUNED_tmpdir}/usr/lib/dracut/hooks/pre-udev/"
-    sed -i '/^IRQBALANCE_BANNED_CPUS=/d' /etc/sysconfig/irqbalance
-    echo "IRQBALANCE_BANNED_CPUS=$TUNED_isolated_cpumask" >>/etc/sysconfig/irqbalance
+    irqbalance_banned_cpus_setup "$TUNED_isolated_cpumask"
     setup_kvm_mod_low_latency
     disable_ksm
 
@@ -52,7 +51,7 @@ start() {
 stop() {
     if [ "$1" = "full_rollback" ]
     then
-        sed -i '/^IRQBALANCE_BANNED_CPUS=/d' /etc/sysconfig/irqbalance
+        irqbalance_banned_cpus_clear
         teardown_kvm_mod_low_latency
         enable_ksm
     fi
diff --git a/profiles/functions b/profiles/functions
index aab608ad..d52b0818 100644
--- a/profiles/functions
+++ b/profiles/functions
@@ -473,6 +473,17 @@ restore_logs_syncing() {
 	mv -Z $RSYSLOG_SAVE $RSYSLOG_CFG || mv $RSYSLOG_SAVE $RSYSLOG_CFG
 }
 
+irqbalance_banned_cpus_clear() {
+    sed -i '/^IRQBALANCE_BANNED_CPUS=/d' /etc/sysconfig/irqbalance
+}
+
+irqbalance_banned_cpus_setup() {
+    irqbalance_banned_cpus_clear
+    if [ -n "$1" ]; then
+        echo "IRQBALANCE_BANNED_CPUS=$1" >> /etc/sysconfig/irqbalance
+    fi
+}
+
 #
 # HARDWARE SPECIFIC tuning
 #

From 7e93b6948f0ab2eb10db5abccb71ae1cc489460c Mon Sep 17 00:00:00 2001
From: Peter Xu <peterx@redhat.com>
Date: Thu, 4 Jul 2019 11:18:11 +0800
Subject: [PATCH 3/3] realtime: Apply irqbalance tunes too in realtime profiles

Realtime profiles require to restrict irqbalance too.  Apply them to
the realtime profile so that realtime-virtual-{host|guest} can benefit
from that too.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 profiles/realtime/script.sh  | 2 ++
 profiles/realtime/tuned.conf | 1 +
 2 files changed, 3 insertions(+)

diff --git a/profiles/realtime/script.sh b/profiles/realtime/script.sh
index 41517315..e2a2829c 100755
--- a/profiles/realtime/script.sh
+++ b/profiles/realtime/script.sh
@@ -3,10 +3,12 @@
 . /usr/lib/tuned/functions
 
 start() {
+    irqbalance_banned_cpus_setup "$TUNED_isolated_cpumask"
     return 0
 }
 
 stop() {
+    irqbalance_banned_cpus_clear
     return 0
 }
 
diff --git a/profiles/realtime/tuned.conf b/profiles/realtime/tuned.conf
index c595e67b..3100941f 100644
--- a/profiles/realtime/tuned.conf
+++ b/profiles/realtime/tuned.conf
@@ -18,6 +18,7 @@ assert1=${f:assertion_non_equal:isolated_cores are set:${isolated_cores}:${isola
 # Non-isolated cores cpumask including offline cores
 not_isolated_cpumask = ${f:cpulist2hex_invert:${isolated_cores}}
 isolated_cores_expanded=${f:cpulist_unpack:${isolated_cores}}
+isolated_cpumask=${f:cpulist2hex:${isolated_cores_expanded}}
 isolated_cores_online_expanded=${f:cpulist_online:${isolated_cores}}
 
 # Fail if isolated_cores contains CPUs which are not online