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

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