Blame SOURCES/tuned-2.10.0-disable-ksm-once.patch

b6c6d0
diff --git a/profiles/cpu-partitioning/script.sh b/profiles/cpu-partitioning/script.sh
b6c6d0
index 0e94d3a..efe9bcb 100755
b6c6d0
--- a/profiles/cpu-partitioning/script.sh
b6c6d0
+++ b/profiles/cpu-partitioning/script.sh
b6c6d0
@@ -54,8 +54,8 @@ stop() {
b6c6d0
     then
b6c6d0
         sed -i '/^IRQBALANCE_BANNED_CPUS=/d' /etc/sysconfig/irqbalance
b6c6d0
         teardown_kvm_mod_low_latency
b6c6d0
+        enable_ksm
b6c6d0
     fi
b6c6d0
-    enable_ksm
b6c6d0
     enable_balance_domains
b6c6d0
     return "$?"
b6c6d0
 }
b6c6d0
diff --git a/profiles/functions b/profiles/functions
b6c6d0
index 2df8168..919409c 100644
b6c6d0
--- a/profiles/functions
b6c6d0
+++ b/profiles/functions
b6c6d0
@@ -531,35 +531,30 @@ teardown_kvm_mod_low_latency()
b6c6d0
 
b6c6d0
 KSM_SERVICES="ksm ksmtuned"
b6c6d0
 KSM_RUN_PATH=/sys/kernel/mm/ksm/run
b6c6d0
+KSM_MASK_FILE="${STORAGE_PERSISTENT}/ksm-masked"
b6c6d0
 
b6c6d0
 disable_ksm()
b6c6d0
 {
b6c6d0
-	for s in $KSM_SERVICES; do
b6c6d0
-		if systemctl is-enabled -q $s; then
b6c6d0
-			systemctl -q disable $s
b6c6d0
+	if [ ! -f $KSM_MASK_FILE ]; then
b6c6d0
+		# Always create $KSM_MASK_FILE, since we don't want to
b6c6d0
+		# run any systemctl commands during boot
b6c6d0
+		if ! touch $KSM_MASK_FILE; then
b6c6d0
+			die "failed to create $KSM_MASK_FILE"
b6c6d0
 		fi
b6c6d0
-
b6c6d0
-		if systemctl is-active -q $s; then
b6c6d0
-			systemctl -q stop $s
b6c6d0
-		fi
b6c6d0
-	done
b6c6d0
-
b6c6d0
-	if [ -f $KSM_RUN_PATH ]; then
b6c6d0
+		systemctl --now --quiet mask $KSM_SERVICES
b6c6d0
 		# Unmerge all shared pages
b6c6d0
-		echo 2 > $KSM_RUN_PATH
b6c6d0
+		test -f $KSM_RUN_PATH && echo 2 > $KSM_RUN_PATH
b6c6d0
 	fi
b6c6d0
 }
b6c6d0
 
b6c6d0
+# Should only be called when full_rollback == true
b6c6d0
 enable_ksm()
b6c6d0
 {
b6c6d0
-	for s in $KSM_SERVICES; do
b6c6d0
-		systemctl -q preset $s
b6c6d0
-
b6c6d0
-		# Only start the service if it's enabled by defaut
b6c6d0
-		if systemctl is-enabled -q $s; then
b6c6d0
-			systemctl start $s
b6c6d0
+	if [ -f $KSM_MASK_FILE ]; then
b6c6d0
+		if systemctl --quiet unmask $KSM_SERVICES; then
b6c6d0
+			rm -f $KSM_MASK_FILE
b6c6d0
 		fi
b6c6d0
-	done
b6c6d0
+	fi
b6c6d0
 }
b6c6d0
 
b6c6d0
 die() {
b6c6d0
diff --git a/profiles/realtime-virtual-host/script.sh b/profiles/realtime-virtual-host/script.sh
b6c6d0
index a9366cb..33a7996 100755
b6c6d0
--- a/profiles/realtime-virtual-host/script.sh
b6c6d0
+++ b/profiles/realtime-virtual-host/script.sh
b6c6d0
@@ -93,8 +93,10 @@ start() {
b6c6d0
 }
b6c6d0
 
b6c6d0
 stop() {
b6c6d0
-    [ "$1" = "full_rollback" ] && teardown_kvm_mod_low_latency
b6c6d0
-    enable_ksm
b6c6d0
+    if [ "$1" = "full_rollback" ]; then
b6c6d0
+        teardown_kvm_mod_low_latency
b6c6d0
+        enable_ksm
b6c6d0
+    fi
b6c6d0
     systemctl stop rt-entsk
b6c6d0
     return "$?"
b6c6d0
 }