From: Suresh Jayaraman <sjayaraman@suse.de>
Subject: [PATCH] mm: Make default VM dirty ratio configurable to suit different workloads
References: bnc#552883
Patch-mainline: Never

Based on the observation that higher VM dirty ratio improves performance of
most server workloads that dirties a lot of memory (e.g. simple databases not
using direct IO, workloads doing heavy writes) and the latency-sensitive
workloads like desktop and typical workstations perform better with a
decreased VM dirty ratio, make default VM dirty ratio configurable. This also
ensures that we have the similar dirty pages writeback limit in SLES11 SP1 as
compared to SLES11 GM.

The default VM dirty ratio is 20 for kernel-desktop flavor and 40 for all the
other flavors.

Also introduce a new CONFIG_KERNEL_DESKTOP option which might allow to tune
the kernel to suit desktop workloads.

Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Acked-by: Jeff Mahoney <jeffm@suse.com>
---
 init/Kconfig        |   24 ++++++++++++++++++++++++
 mm/page-writeback.c |    2 +-
 2 files changed, 25 insertions(+), 1 deletion(-)

--- a/init/Kconfig
+++ b/init/Kconfig
@@ -32,6 +32,13 @@ config SPLIT_PACKAGE
 	  If you aren't packaging a kernel for distribution, it's safe to
 	  say n.
 
+config KERNEL_DESKTOP
+	bool "Kernel to suit desktop workloads"
+	default n
+	help
+	  This is an option used to tune kernel parameters to better suit
+	  desktop workloads.
+
 config ARCH
 	string
 	option env="ARCH"
@@ -1131,6 +1138,23 @@ config MMAP_ALLOW_UNINITIALIZED
 
 	  See Documentation/nommu-mmap.txt for more information.
 
+config DEFAULT_VM_DIRTY_RATIO
+	int "Default VM dirty ratio (in %)"
+	default 20 if KERNEL_DESKTOP
+	default 40
+	help
+	  Allows to tune VM dirty ratio to suit different workloads. Increased
+	  VM dirty ratio improves performance of most server workloads that
+	  dirties a lot of memory (e.g. simple databases not using direct IO,
+	  workloads doing heavy writes). The latency-sensitive workloads like
+	  desktop and typical workstations perform better with a decreased
+	  VM dirty ratio.
+
+	  Recommended value for desktop workload is 20.
+	  Recommended value for server workload is 40.
+
+	  Only use this if you really know what you are doing.
+
 config PROFILING
 	bool "Profiling support"
 	help
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -77,7 +77,7 @@ int vm_highmem_is_dirtyable;
 /*
  * The generator of dirty data starts writeback at this percentage
  */
-int vm_dirty_ratio = 20;
+int vm_dirty_ratio = CONFIG_DEFAULT_VM_DIRTY_RATIO;
 
 /*
  * vm_dirty_bytes starts at 0 (disabled) so that it is a function of
