Blob Blame History Raw
From 5ed61ce394bad089f86a0be4b911cd93eddeb1b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= <jskarvad@redhat.com>
Date: Fri, 20 Mar 2020 18:02:46 +0100
Subject: [PATCH] realtime: added conditional support for managed_irq
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Also added regex_search_ternary built-in function.

It takes arguments in the following form:
  STR1, REGEX, STR2, STR3

If REGEX matches STR1 (re.search is used), STR2 is returned,
if it doesn't match STR3 is returned.

Example:
[variables]
foo=Y
bar=${f:regex_search_ternary:${foo}:\b[y,Y,1,t,T]\b:foo:bar}

It will result in the 'foo' string stored in the '${bar}' variable.

Resolves: rhbz#1797025

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
---
 profiles/realtime/realtime-variables.conf     |  7 +++++++
 profiles/realtime/tuned.conf                  |  5 ++++-
 .../function_regex_search_ternary.py          | 21 +++++++++++++++++++
 3 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 tuned/profiles/functions/function_regex_search_ternary.py

diff --git a/profiles/realtime/realtime-variables.conf b/profiles/realtime/realtime-variables.conf
index b91e5f3..c2da595 100644
--- a/profiles/realtime/realtime-variables.conf
+++ b/profiles/realtime/realtime-variables.conf
@@ -2,3 +2,10 @@
 # isolated_cores=2,4-7
 # isolated_cores=2-23
 #
+#
+# Uncomment the 'isolate_managed_irq=Y' bellow if you want to move kernel
+# managed IRQs out of isolated cores. Note that this requires kernel
+# support. Please only specify this parameter if you are sure that the
+# kernel supports it.
+#
+# isolate_managed_irq=Y
diff --git a/profiles/realtime/tuned.conf b/profiles/realtime/tuned.conf
index 6f5c5b1..a22ffdd 100644
--- a/profiles/realtime/tuned.conf
+++ b/profiles/realtime/tuned.conf
@@ -28,6 +28,9 @@ isolated_cores_online_expanded=${f:cpulist_online:${isolated_cores}}
 # Fail if isolated_cores contains CPUs which are not online
 assert2=${f:assertion:isolated_cores contains online CPU(s):${isolated_cores_expanded}:${isolated_cores_online_expanded}}
 
+# Assembly managed_irq
+managed_irq=${f:regex_search_ternary:${isolate_managed_irq}:\b[y,Y,1,t,T]\b:managed_irq,domain,:}
+
 [sysctl]
 kernel.hung_task_timeout_secs = 600
 kernel.nmi_watchdog = 0
@@ -41,7 +44,7 @@ kernel.timer_migration = 0
 /sys/devices/system/machinecheck/machinecheck*/ignore_ce = 1
 
 [bootloader]
-cmdline_realtime=+isolcpus=${isolated_cores} intel_pstate=disable nosoftlockup tsc=nowatchdog
+cmdline_realtime=+isolcpus=${managed_irq}${isolated_cores} intel_pstate=disable nosoftlockup tsc=nowatchdog
 
 [script]
 script = ${i:PROFILE_DIR}/script.sh
diff --git a/tuned/profiles/functions/function_regex_search_ternary.py b/tuned/profiles/functions/function_regex_search_ternary.py
new file mode 100644
index 0000000..42c4567
--- /dev/null
+++ b/tuned/profiles/functions/function_regex_search_ternary.py
@@ -0,0 +1,21 @@
+import re
+from . import base
+
+class regex_search_ternary(base.Function):
+	"""
+	Ternary regex operator, it takes arguments in the following form
+	STR1, REGEX, STR2, STR3
+	If REGEX matches STR1 (re.search is used), STR2 is returned,
+	otherwise STR3 is returned
+	"""
+	def __init__(self):
+		# 4 arguments
+		super(regex_search_ternary, self).__init__("regex_search_ternary", 4)
+
+	def execute(self, args):
+		if not super(regex_search_ternary, self).execute(args):
+			return None
+		if re.search(args[1], args[0]):
+			return args[2]
+		else:
+			return args[3]
-- 
2.21.1