6bec19
From 66924b842228e7178301aa399d30459155b35762 Mon Sep 17 00:00:00 2001
6bec19
From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= <olysonek@redhat.com>
6bec19
Date: Tue, 9 Jul 2019 11:31:20 +0200
6bec19
Subject: [PATCH 1/3] plugin_script: Execute all scripts regardless of errors
6bec19
MIME-Version: 1.0
6bec19
Content-Type: text/plain; charset=UTF-8
6bec19
Content-Transfer-Encoding: 8bit
6bec19
6bec19
Due to commit d4038a7e64af3, if a script fails to execute or its exit
6bec19
code is non-zero, no subsequent scripts are executed. This seems
6bec19
logically wrong and it causes problems especially during rollback as some
6bec19
tunings may not be reverted due to this behaviour. Also, it appears it
6bec19
was not the intention of that commit to change this behaviour - the
6bec19
intention rather seems to have been to make _call_scripts return
6bec19
success/error information for use by the verification mechanism.
6bec19
6bec19
So let's aggregate the success/error information instead.
6bec19
6bec19
Related: https://github.com/redhat-performance/tuned/pull/194
6bec19
6bec19
Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
6bec19
---
6bec19
 tuned/plugins/plugin_script.py | 7 ++++---
6bec19
 1 file changed, 4 insertions(+), 3 deletions(-)
6bec19
6bec19
diff --git a/tuned/plugins/plugin_script.py b/tuned/plugins/plugin_script.py
6bec19
index 940c1f9a..19b7fc60 100644
6bec19
--- a/tuned/plugins/plugin_script.py
6bec19
+++ b/tuned/plugins/plugin_script.py
6bec19
@@ -31,6 +31,7 @@ def _instance_cleanup(self, instance):
6bec19
 		pass
6bec19
 
6bec19
 	def _call_scripts(self, scripts, arguments):
6bec19
+		ret = True
6bec19
 		for script in scripts:
6bec19
 			environ = os.environ
6bec19
 			environ.update(self._variables.get_env())
6bec19
@@ -47,11 +48,11 @@ def _call_scripts(self, scripts, arguments):
6bec19
 					log.error("script '%s' error output: '%s'" % (script, err[:-1]))
6bec19
 				if proc.returncode:
6bec19
 					log.error("script '%s' returned error code: %d" % (script, proc.returncode))
6bec19
-					return False
6bec19
+					ret = False
6bec19
 			except (OSError,IOError) as e:
6bec19
 				log.error("script '%s' error: %s" % (script, e))
6bec19
-				return False
6bec19
-		return True
6bec19
+				ret = False
6bec19
+		return ret
6bec19
 
6bec19
 	def _instance_apply_static(self, instance):
6bec19
 		super(ScriptPlugin, self)._instance_apply_static(instance)
6bec19
6bec19
From 4a8e64994eb978ada0c7e23702e96c82352cc222 Mon Sep 17 00:00:00 2001
6bec19
From: Peter Xu <peterx@redhat.com>
6bec19
Date: Thu, 4 Jul 2019 11:16:54 +0800
6bec19
Subject: [PATCH 2/3] cpu-partitioning: Introduce irqbalance helpers and use
6bec19
6bec19
Provide irqbalance_banned_cpus_{setup|clear} for tuning irqbalance.
6bec19
Use them in cpu-partitioning.
6bec19
6bec19
Signed-off-by: Peter Xu <peterx@redhat.com>
6bec19
---
6bec19
 profiles/cpu-partitioning/script.sh |  5 ++---
6bec19
 profiles/functions                  | 11 +++++++++++
6bec19
 2 files changed, 13 insertions(+), 3 deletions(-)
6bec19
6bec19
diff --git a/profiles/cpu-partitioning/script.sh b/profiles/cpu-partitioning/script.sh
6bec19
index efe9bcbb..4d0a08b2 100755
6bec19
--- a/profiles/cpu-partitioning/script.sh
6bec19
+++ b/profiles/cpu-partitioning/script.sh
6bec19
@@ -39,8 +39,7 @@ start() {
6bec19
     mkdir -p "${TUNED_tmpdir}/usr/lib/dracut/hooks/pre-udev"
6bec19
     cp /etc/systemd/system.conf "${TUNED_tmpdir}/etc/systemd/"
6bec19
     cp 00-tuned-pre-udev.sh "${TUNED_tmpdir}/usr/lib/dracut/hooks/pre-udev/"
6bec19
-    sed -i '/^IRQBALANCE_BANNED_CPUS=/d' /etc/sysconfig/irqbalance
6bec19
-    echo "IRQBALANCE_BANNED_CPUS=$TUNED_isolated_cpumask" >>/etc/sysconfig/irqbalance
6bec19
+    irqbalance_banned_cpus_setup "$TUNED_isolated_cpumask"
6bec19
     setup_kvm_mod_low_latency
6bec19
     disable_ksm
6bec19
 
6bec19
@@ -52,7 +51,7 @@ start() {
6bec19
 stop() {
6bec19
     if [ "$1" = "full_rollback" ]
6bec19
     then
6bec19
-        sed -i '/^IRQBALANCE_BANNED_CPUS=/d' /etc/sysconfig/irqbalance
6bec19
+        irqbalance_banned_cpus_clear
6bec19
         teardown_kvm_mod_low_latency
6bec19
         enable_ksm
6bec19
     fi
6bec19
diff --git a/profiles/functions b/profiles/functions
6bec19
index aab608ad..d52b0818 100644
6bec19
--- a/profiles/functions
6bec19
+++ b/profiles/functions
6bec19
@@ -473,6 +473,17 @@ restore_logs_syncing() {
6bec19
 	mv -Z $RSYSLOG_SAVE $RSYSLOG_CFG || mv $RSYSLOG_SAVE $RSYSLOG_CFG
6bec19
 }
6bec19
 
6bec19
+irqbalance_banned_cpus_clear() {
6bec19
+    sed -i '/^IRQBALANCE_BANNED_CPUS=/d' /etc/sysconfig/irqbalance
6bec19
+}
6bec19
+
6bec19
+irqbalance_banned_cpus_setup() {
6bec19
+    irqbalance_banned_cpus_clear
6bec19
+    if [ -n "$1" ]; then
6bec19
+        echo "IRQBALANCE_BANNED_CPUS=$1" >> /etc/sysconfig/irqbalance
6bec19
+    fi
6bec19
+}
6bec19
+
6bec19
 #
6bec19
 # HARDWARE SPECIFIC tuning
6bec19
 #
6bec19
6bec19
From 7e93b6948f0ab2eb10db5abccb71ae1cc489460c Mon Sep 17 00:00:00 2001
6bec19
From: Peter Xu <peterx@redhat.com>
6bec19
Date: Thu, 4 Jul 2019 11:18:11 +0800
6bec19
Subject: [PATCH 3/3] realtime: Apply irqbalance tunes too in realtime profiles
6bec19
6bec19
Realtime profiles require to restrict irqbalance too.  Apply them to
6bec19
the realtime profile so that realtime-virtual-{host|guest} can benefit
6bec19
from that too.
6bec19
6bec19
Signed-off-by: Peter Xu <peterx@redhat.com>
6bec19
---
6bec19
 profiles/realtime/script.sh  | 2 ++
6bec19
 profiles/realtime/tuned.conf | 1 +
6bec19
 2 files changed, 3 insertions(+)
6bec19
6bec19
diff --git a/profiles/realtime/script.sh b/profiles/realtime/script.sh
6bec19
index 41517315..e2a2829c 100755
6bec19
--- a/profiles/realtime/script.sh
6bec19
+++ b/profiles/realtime/script.sh
6bec19
@@ -3,10 +3,12 @@
6bec19
 . /usr/lib/tuned/functions
6bec19
 
6bec19
 start() {
6bec19
+    irqbalance_banned_cpus_setup "$TUNED_isolated_cpumask"
6bec19
     return 0
6bec19
 }
6bec19
 
6bec19
 stop() {
6bec19
+    irqbalance_banned_cpus_clear
6bec19
     return 0
6bec19
 }
6bec19
 
6bec19
diff --git a/profiles/realtime/tuned.conf b/profiles/realtime/tuned.conf
6bec19
index c595e67b..3100941f 100644
6bec19
--- a/profiles/realtime/tuned.conf
6bec19
+++ b/profiles/realtime/tuned.conf
6bec19
@@ -18,6 +18,7 @@ assert1=${f:assertion_non_equal:isolated_cores are set:${isolated_cores}:${isola
6bec19
 # Non-isolated cores cpumask including offline cores
6bec19
 not_isolated_cpumask = ${f:cpulist2hex_invert:${isolated_cores}}
6bec19
 isolated_cores_expanded=${f:cpulist_unpack:${isolated_cores}}
6bec19
+isolated_cpumask=${f:cpulist2hex:${isolated_cores_expanded}}
6bec19
 isolated_cores_online_expanded=${f:cpulist_online:${isolated_cores}}
6bec19
 
6bec19
 # Fail if isolated_cores contains CPUs which are not online