Blob Blame History Raw
From 26db89de18efad1b453618ea8156422d26e0c85f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= <jskarvad@redhat.com>
Date: Tue, 8 Jan 2019 15:00:33 +0100
Subject: [PATCH] mssql: updated tuning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Added vm plugin option 'transparent_hugepage.defrag'.

Resolves: rhbz#1660178

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
---
 profiles/mssql/tuned.conf  |  9 ++++++++-
 tuned/plugins/plugin_vm.py | 32 +++++++++++++++++++++++++++-----
 2 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/profiles/mssql/tuned.conf b/profiles/mssql/tuned.conf
index 2491717..35e208a 100644
--- a/profiles/mssql/tuned.conf
+++ b/profiles/mssql/tuned.conf
@@ -6,5 +6,12 @@
 summary=Optimize for MS SQL Server
 include=throughput-performance
 
+[vm]
+transparent_hugepage.defrag=always
+
 [sysctl]
-vm.max_map_count=262144
+vm.max_map_count=800000
+kernel.numa_balancing=0
+kernel.sched_latency_ns=60000000
+kernel.sched_min_granularity_ns=15000000
+kernel.sched_wakeup_granularity_ns=2000000
diff --git a/tuned/plugins/plugin_vm.py b/tuned/plugins/plugin_vm.py
index be570e2..9021ac3 100644
--- a/tuned/plugins/plugin_vm.py
+++ b/tuned/plugins/plugin_vm.py
@@ -20,6 +20,7 @@ class VMPlugin(base.Plugin):
 		return {
 			"transparent_hugepages" : None,
 			"transparent_hugepage" : None,
+			"transparent_hugepage.defrag" : None,
 		}
 
 	def _instance_init(self, instance):
@@ -30,10 +31,11 @@ class VMPlugin(base.Plugin):
 		pass
 
 	@classmethod
-	def _thp_file(self):
-		path = "/sys/kernel/mm/transparent_hugepage/enabled"
+	def _thp_path(self):
+		path = "/sys/kernel/mm/transparent_hugepage"
 		if not os.path.exists(path):
-			path =  "/sys/kernel/mm/redhat_transparent_hugepage/enabled"
+			# RHEL-6 support
+			path =  "/sys/kernel/mm/redhat_transparent_hugepage"
 		return path
 
 	@command_set("transparent_hugepages")
@@ -49,7 +51,7 @@ class VMPlugin(base.Plugin):
 				log.info("transparent_hugepage is already set in kernel boot cmdline, ingoring value from profile")
 			return None
 
-		sys_file = self._thp_file()
+		sys_file = os.path.join(self._thp_path(), "enabled")
 		if os.path.exists(sys_file):
 			if not sim:
 				cmd.write_to_file(sys_file, value)
@@ -66,7 +68,7 @@ class VMPlugin(base.Plugin):
 
 	@command_get("transparent_hugepages")
 	def _get_transparent_hugepages(self):
-		sys_file = self._thp_file()
+		sys_file = os.path.join(self._thp_path(), "enabled")
 		if os.path.exists(sys_file):
 			return cmd.get_active_option(cmd.read_file(sys_file))
 		else:
@@ -76,3 +78,23 @@ class VMPlugin(base.Plugin):
 	@command_get("transparent_hugepage")
 	def _get_transparent_hugepage(self):
 		return self._get_transparent_hugepages()
+
+	@command_set("transparent_hugepage.defrag")
+	def _set_transparent_hugepage_defrag(self, value, sim):
+		sys_file = os.path.join(self._thp_path(), "defrag")
+		if os.path.exists(sys_file):
+			if not sim:
+				cmd.write_to_file(sys_file, value)
+			return value
+		else:
+			if not sim:
+				log.warn("Option 'transparent_hugepage.defrag' is not supported on current hardware.")
+			return None
+
+	@command_get("transparent_hugepage.defrag")
+	def _get_transparent_hugepage_defrag(self):
+		sys_file = os.path.join(self._thp_path(), "defrag")
+		if os.path.exists(sys_file):
+			return cmd.get_active_option(cmd.read_file(sys_file))
+		else:
+			return None
-- 
2.20.1