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