Subject: [PATCH] [BZ 117045] cpuplugd: update default sysconfig file
From: Gerald Schaefer <gerald.schaefer@de.ibm.com>

Description:  cpuplugd: update default sysconfig file
Symptom:      CPUs may be set online and offline too frequently or not often
              enough.
Problem:      Depending on the workload, the default rules in the sysconfig
              file may lead to adverse behaviour.
Solution:     Replace the default sysconfig file with the new upstream version.
Reproduction: -
Upstream-ID:  -
Problem-ID:   117045

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
---
 cpuplugd/cpuplugd.conf.example |  166 +++++++++++++++++++++++++++++++++++++++++
 cpuplugd/man/cpuplugd.conf.5   |   37 ---------
 2 files changed, 168 insertions(+), 35 deletions(-)

--- /dev/null
+++ b/cpuplugd/cpuplugd.conf.example
@@ -0,0 +1,166 @@
+#
+# Exemplary configuration file for the Linux on System z CPU and memory hotplug
+# daemon
+#
+# The file is evaluated by cpuplugd at startup when called with -c.
+# It does not contain shell environment variables.
+
+## Type:	integer
+## Default:	1
+#
+# The minimum number of CPUs must be > 0.
+#
+CPU_MIN="1"
+
+## Type:	integer
+## Default:	0
+#
+# The maximum number of CPUs to be enabled. If 0 is specified here,
+# the maximum number of CPUs equals the number of CPUs detected.
+#
+CPU_MAX="0"
+
+## Type:	integer
+## Default:	5
+#
+# The update interval described how often the current system state
+# is checked against the configured set of hotplug and hotunplug rules.
+# The update interval is defined in seconds.
+#
+UPDATE="1"
+
+## Type:	integer
+## Default:	0
+#
+# The minimum size of the static page pool (in 4K pages)
+#
+CMM_MIN="0"
+
+## Type:	integer
+## Default:	131072
+#
+# The maximum size of the static page pool (in 4K pages)
+#
+# Recommended setting is system size minus 256 MB
+CMM_MAX="131072"	# 512 MB
+
+#
+# Variables
+#
+# User-defined variables are case-sensitive and must not match a pre-defined
+# variable or keyword. In the configuration file, definitions
+# for user-defined variables must precede their use in expressions.
+# Variable names consist of alphanumeric characters (a-z,A-Z,0-9) and
+# the "_" character. The maximum name length for a variable is 128 characters,
+# and the maximum total size for user-defined variables (names + values) is 4096
+# characters.
+#
+pgscan_d="vmstat.pgscan_direct_dma[0] + vmstat.pgscan_direct_normal[0] + vmstat.pgscan_direct_movable[0]"
+pgscan_d1="vmstat.pgscan_direct_dma[1] + vmstat.pgscan_direct_normal[1] + vmstat.pgscan_direct_movable[1]"
+# page scan rate in pages / timer tick
+pgscanrate="(pgscan_d - pgscan_d1) / (cpustat.total_ticks[0] - cpustat.total_ticks[1])"
+# cache usage in kilobytes
+avail_cache="meminfo.Cached - meminfo.Shmem"
+
+user_0="(cpustat.user[0] - cpustat.user[1])"
+nice_0="(cpustat.nice[0] - cpustat.nice[1])"
+system_0="(cpustat.system[0] - cpustat.system[1])"
+user_2="(cpustat.user[2] - cpustat.user[3])"
+nice_2="(cpustat.nice[2] - cpustat.nice[3])"
+system_2="(cpustat.system[2] - cpustat.system[3])"
+CP_Active0="(user_0 + nice_0 + system_0) / (cpustat.total_ticks[0] - cpustat.total_ticks[1])"
+CP_Active2="(user_2 + nice_2 + system_2) / (cpustat.total_ticks[2] - cpustat.total_ticks[3])"
+
+CP_ActiveAVG="(CP_Active0+CP_Active2) / 2"
+idle_0="(cpustat.idle[0] - cpustat.idle[1])"
+iowait_0="(cpustat.iowait[0] - cpustat.iowait[1])"
+idle_2="(cpustat.idle[2] - cpustat.idle[3])"
+iowait_2="(cpustat.iowait[2] - cpustat.iowait[3])"
+CP_idle0="(idle_0 + iowait_0) / (cpustat.total_ticks[0] - cpustat.total_ticks[1])"
+CP_idle2="(idle_2 + iowait_2) / (cpustat.total_ticks[2] - cpustat.total_ticks[3])"
+CP_idleAVG="(CP_idle0 + CP_idle2) / 2"
+
+## Type:	string
+## Default:	"(meminfo.MemFree + cache) / 40"
+#
+# The amount of pages the static page pool
+# is increased if a memunplug rule is matched.
+#
+# cmm_inc: 10% of free memory, in 4K pages
+CMM_INC="meminfo.MemFree / 40"
+
+## Type:	string
+## Default:	"meminfo.MemTotal / 40"
+#
+# The amount of pages the static page pool
+# is decreased if a memplug rule is matched.
+#
+# cmm_dec: 10% of total memory, in 4K pages
+CMM_DEC="meminfo.MemTotal / 40"
+
+#
+# Ruledefinitions
+#
+# Four kinds of rules are distinguished
+#   (1) hotplug rules, used to enable CPUs
+#   (2) hotunplug rules, to disable CPUs
+#   (3) memplug rules, used to increase memory (decrease cmm balloon)
+#   (4) memunplug rules, used to decrease memory (increase cmm balloon)
+#
+# Within the hotplug/hotunplug rule definitions the following variables
+# can be used:
+#   - loadavg:		the current loadaverage
+#   - onumcpus:		the current number of CPUs which are online
+#   - runnable_proc:	the current amount of runnable processes
+#   - user:		the current user percentage
+#   - nice:		the current nice percentage
+#   - system:		the current system percentage
+#   - idle:		the current idle percentage
+#   - iowait:		the current iowait percentage
+#   - irq:		the current irq percentage
+#   - softirq:		the current softirq percentage
+#   - steal:		the current steal percentage
+#   - guest:		the current guest percentage
+#   - guest_nice:	the current guest_nice percentage
+#   - cpustat.<name>:	data from /proc/stat and /proc/loadavg
+#   - time:		floating point timestamp in "seconds.microseconds"
+#			since the Unix Epoch (1970-01-01 00:00:00 +0000 (UTC))
+#
+## Type:	string
+## Default:	"(loadavg > onumcpus + 0.75) & (idle < 10.0)"
+#
+HOTPLUG="((1 - CP_ActiveAVG) * onumcpus) < 0.08"
+
+## Type:	string
+## Default:	"(loadavg < onumcpus - 0.25) | (idle > 50)"
+#
+HOTUNPLUG="(CP_idleAVG * onumcpus) > 1.15"
+
+#
+# Memplug and memunplug can contain the following keywords:
+#   - apcr:		the amount of page cache operations,
+#			i.e. pgpin + pgpout from /proc/vmstat
+#			(in 512 byte blocks / second)
+#   - freemem:		the amount of free memory (in megabytes)
+#   - swaprate:		the number of swap operations, i.e. pswpin + pswpout
+#			from /proc/vmstat (in pages / second)
+#   - meminfo.<name>:	any value from /proc/meminfo
+#   - vmstat.<name>:	any value from /proc/vmstat
+#   - time:		floating point timestamp in "seconds.microseconds"
+#			since the Unix Epoch (1970-01-01 00:00:00 +0000 (UTC))
+#
+# This function is disabled by default, because this rule has to be
+# adjusted for each production system, depending on the environment.
+#
+## Type:	string
+## Default:	"0"
+#
+#MEMPLUG="pgscanrate > 20"
+MEMPLUG="0"
+
+## Type:	string
+## Default:	"0"
+#
+#MEMUNPLUG="(meminfo.MemFree + avail_cache) > (meminfo.MemTotal / 10)"
+MEMUNPLUG="0"
+
--- a/cpuplugd/man/cpuplugd.conf.5
+++ b/cpuplugd/man/cpuplugd.conf.5
@@ -234,41 +234,8 @@ dependent on time intervals, see section
 (pgscanrate).
 .
 .SH EXAMPLES
-A complete configuration file could look like this:
-
-.nf
------------------------------- config file start ------------------------------
-UPDATE="5"
-CPU_MIN="2"
-CPU_MAX="5"
-CMM_MIN="0"
-CMM_MAX="131072"	# 512 MB
-
-pgscan_k="vmstat.pgscan_kswapd_dma + vmstat.pgscan_kswapd_normal + vmstat.pgscan_kswapd_movable"
-pgscan_d="vmstat.pgscan_direct_dma + vmstat.pgscan_direct_normal + vmstat.pgscan_direct_movable"
-pgscan_k1="vmstat.pgscan_kswapd_dma[1] + vmstat.pgscan_kswapd_normal[1] + vmstat.pgscan_kswapd_movable[1]"
-pgscan_d1="vmstat.pgscan_direct_dma[1] + vmstat.pgscan_direct_normal[1] + vmstat.pgscan_direct_movable[1]"
-pgscanrate="(pgscan_k + pgscan_d - pgscan_k1 - pgscan_d1) / (time - time[1])"
-cache="meminfo.Cached + meminfo.Buffers"
-
-# CMM_INC: 10% of free memory + cache, in 4K pages
-CMM_INC="(meminfo.MemFree + cache) / 40"
-# CMM_DEC: 10% of total memory in 4K pages
-CMM_DEC="meminfo.MemTotal / 40"
-
-HOTPLUG = "(loadavg > onumcpus + 0.75) & (idle < 10.0)"
-HOTUNPLUG = "(loadavg < onumcpus - 0.25) | (idle > 50)"
-
-# Plug memory if page scan rate is above 20 pages / sec
-MEMPLUG = "pgscanrate > 20"
-# Unplug memory while free memory is above 10% of total memory, or cache uses
-# more than 50% of total memory
-MEMUNPLUG = "(meminfo.MemFree > meminfo.MemTotal / 10) | (cache > meminfo.MemTotal / 2)"
------------------------------- config file end ------------------------------
-.fi
-
-The example includes multiple user-defined variables to calculate the page scan
-rate with values from /proc/vmstat, as well as the cache size.
+See /usr/share/doc/packages/s390-tools/cpuplugd.conf.example for an example
+configuration file.
 
 \fBAttention:\fP Do not use these example rules on production systems. The
 rules have been designed to illustrate the configuration file syntax and are
