Blame SOURCES/bz2090370-CTDB-move-process-to-root-cgroup-if-rt-enabled.patch

8a0ebf
From 99c4f2af92a10155cf072198c72deffaed3883a5 Mon Sep 17 00:00:00 2001
8a0ebf
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
8a0ebf
Date: Wed, 3 Aug 2022 17:20:31 +0200
8a0ebf
Subject: [PATCH] CTDB: move process to root cgroup if realtime scheduling is
8a0ebf
 enabled
8a0ebf
8a0ebf
---
8a0ebf
 heartbeat/CTDB.in           |  2 ++
8a0ebf
 heartbeat/ocf-shellfuncs.in | 12 ++++++++++++
8a0ebf
 2 files changed, 14 insertions(+)
8a0ebf
8a0ebf
diff --git a/heartbeat/CTDB.in b/heartbeat/CTDB.in
8a0ebf
index d25d026ca..46f56cfac 100755
8a0ebf
--- a/heartbeat/CTDB.in
8a0ebf
+++ b/heartbeat/CTDB.in
8a0ebf
@@ -709,6 +709,8 @@ EOF
8a0ebf
 invoke_ctdbd() {
8a0ebf
 	local vers="$1"
8a0ebf
 
8a0ebf
+	ocf_move_to_root_cgroup_if_rt_enabled
8a0ebf
+
8a0ebf
 	ocf_version_cmp "$vers" "4.9.0"
8a0ebf
 	if [ "$?" -ne "0" ]; then
8a0ebf
 		# With 4.9+, all ctdbd binary parameters are provided as
8a0ebf
diff --git a/heartbeat/ocf-shellfuncs.in b/heartbeat/ocf-shellfuncs.in
8a0ebf
index 6be4e4e30..2c53a967a 100644
8a0ebf
--- a/heartbeat/ocf-shellfuncs.in
8a0ebf
+++ b/heartbeat/ocf-shellfuncs.in
8a0ebf
@@ -672,6 +672,18 @@ EOF
8a0ebf
 	systemctl daemon-reload
8a0ebf
 }
8a0ebf
 
8a0ebf
+# move process to root cgroup if realtime scheduling is enabled
8a0ebf
+ocf_move_to_root_cgroup_if_rt_enabled()
8a0ebf
+{
8a0ebf
+	if [ -e "/sys/fs/cgroup/cpu/cpu.rt_runtime_us" ]; then
8a0ebf
+		echo $$ >> /sys/fs/cgroup/cpu/tasks
8a0ebf
+
8a0ebf
+		if [ "$?" -ne "0" ]; then
8a0ebf
+			ocf_log warn "Unable to move PID $$ to the root cgroup"
8a0ebf
+		fi
8a0ebf
+	fi
8a0ebf
+}
8a0ebf
+
8a0ebf
 # usage: crm_mon_no_validation args...
8a0ebf
 # run crm_mon without any cib schema validation
8a0ebf
 # This is useful when an agent runs in a bundle to avoid potential