Blame SOURCES/tuned-2.10.0-update-kvm-modprobe-file.patch

1bfeda
From c4a0aef63df41a79e96c1276ac732ecde8d58d86 Mon Sep 17 00:00:00 2001
1bfeda
From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= <jskarvad@redhat.com>
1bfeda
Date: Thu, 22 Nov 2018 17:38:12 +0100
1bfeda
Subject: [PATCH] functions: reworked setup_kvm_mod_low_latency to count with
1bfeda
 kernel changes
1bfeda
MIME-Version: 1.0
1bfeda
Content-Type: text/plain; charset=UTF-8
1bfeda
Content-Transfer-Encoding: 8bit
1bfeda
1bfeda
It updates the KVM modprobe file if its content differs from what's
1bfeda
supported on the current system. It may look a bit over-engineered, but
1bfeda
it's done this way to lower the possibility of race condition.
1bfeda
1bfeda
Resolves: rhbz#1649408
1bfeda
1bfeda
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
1bfeda
---
1bfeda
 profiles/functions | 35 +++++++++++++++++++----------------
1bfeda
 1 file changed, 19 insertions(+), 16 deletions(-)
1bfeda
1bfeda
diff --git a/profiles/functions b/profiles/functions
1bfeda
index 919409c..aab608a 100644
1bfeda
--- a/profiles/functions
1bfeda
+++ b/profiles/functions
1bfeda
@@ -503,26 +503,29 @@ eee_set_normal_fsb() {
1bfeda
 
1bfeda
 kvm_modprobe_file=/etc/modprobe.d/kvm.rt.tuned.conf
1bfeda
 
1bfeda
-setup_kvm_mod_low_latency()
1bfeda
+teardown_kvm_mod_low_latency()
1bfeda
 {
1bfeda
-	if [ -f $kvm_modprobe_file ]; then
1bfeda
-		return
1bfeda
-	fi
1bfeda
-
1bfeda
-	modinfo -p kvm | grep -q kvmclock_periodic_sync
1bfeda
-	if [ "$?" -eq 0 ]; then
1bfeda
-		echo "options kvm kvmclock_periodic_sync=0" > $kvm_modprobe_file
1bfeda
-	fi
1bfeda
-
1bfeda
-	modinfo -p kvm_intel | grep -q ple_gap
1bfeda
-	if [ "$?" -eq 0 ]; then
1bfeda
-		echo "options kvm_intel ple_gap=0" >> $kvm_modprobe_file
1bfeda
-	fi
1bfeda
+	rm -f $kvm_modprobe_file
1bfeda
 }
1bfeda
 
1bfeda
-teardown_kvm_mod_low_latency()
1bfeda
+setup_kvm_mod_low_latency()
1bfeda
 {
1bfeda
-	rm -f $kvm_modprobe_file
1bfeda
+	local HAS_KPS=""
1bfeda
+	local HAS_PLE_GAP=""
1bfeda
+	local WANTS_KPS=""
1bfeda
+	local WANTS_PLE_GAP=""
1bfeda
+
1bfeda
+	modinfo -p kvm | grep -q kvmclock_periodic_sync && HAS_KPS=1
1bfeda
+	modinfo -p kvm_intel | grep -q ple_gap && HAS_PLE_GAP=1
1bfeda
+	grep -qs kvmclock_periodic_sync "$kvm_modprobe_file" && WANTS_KPS=1
1bfeda
+	grep -qs ple_gap "$kvm_modprobe_file" && WANTS_PLE_GAP=1
1bfeda
+
1bfeda
+	if [ "$HAS_KPS" != "$WANTS_KPS" -o "$HAS_PLE_GAP" != "$WANTS_PLE_GAP" ]; then
1bfeda
+		teardown_kvm_mod_low_latency
1bfeda
+		[ "$HAS_KPS" ] && echo "options kvm kvmclock_periodic_sync=0" > $kvm_modprobe_file
1bfeda
+		[ "$HAS_PLE_GAP" ] && echo "options kvm_intel ple_gap=0" >> $kvm_modprobe_file
1bfeda
+	fi
1bfeda
+	return 0
1bfeda
 }
1bfeda
 
1bfeda
 #
1bfeda
-- 
1bfeda
2.14.5
1bfeda