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

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