From: Brian King [EMAIL PROTECTED]
Adds a collaborative memory manager, which acts as a simple balloon driver
for System p machines that support cooperative memory overcommitment
(CMO).
Signed-off-by: Brian King [EMAIL PROTECTED]
Signed-off-by: Robert Jennings [EMAIL PROTECTED]
---
arch/powerpc/platforms/pseries/Kconfig | 11 +
arch/powerpc/platforms/pseries/Makefile |1 +
arch/powerpc/platforms/pseries/cmm.c| 468
3 files changed, 480 insertions(+)
Index: b/arch/powerpc/platforms/pseries/Kconfig
===
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -39,3 +39,14 @@ config PPC_PSERIES_DEBUG
depends on PPC_PSERIES PPC_EARLY_DEBUG
bool Enable extra debug logging in platforms/pseries
default y
+
+config CMM
+ tristate Collaborative memory management
+ depends on PPC_PSERIES
+ help
+ Select this option, if you want to enable the kernel interface
+ to reduce the memory size of the system. This is accomplished
+ by allocating pages of memory and put them on hold. This only
+ makes sense for a system running in an LPAR where the unused pages
+ will be reused for other LPARs. The interface allows firmware to
+ balance memory across many LPARs.
Index: b/arch/powerpc/platforms/pseries/Makefile
===
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -24,3 +24,4 @@ obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o
obj-$(CONFIG_HVCS) += hvcserver.o
obj-$(CONFIG_HCALL_STATS) += hvCall_inst.o
obj-$(CONFIG_PHYP_DUMP)+= phyp_dump.o
+obj-$(CONFIG_CMM) += cmm.o
Index: b/arch/powerpc/platforms/pseries/cmm.c
===
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/cmm.c
@@ -0,0 +1,468 @@
+/*
+ * Collaborative memory management interface.
+ *
+ * Copyright (C) 2008 IBM Corporation
+ * Author(s): Brian King ([EMAIL PROTECTED]),
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include linux/ctype.h
+#include linux/delay.h
+#include linux/errno.h
+#include linux/fs.h
+#include linux/init.h
+#include linux/kthread.h
+#include linux/module.h
+#include linux/oom.h
+#include linux/sched.h
+#include linux/stringify.h
+#include linux/swap.h
+#include linux/sysdev.h
+#include asm/firmware.h
+#include asm/hvcall.h
+#include asm/mmu.h
+#include asm/pgalloc.h
+#include asm/uaccess.h
+
+#include plpar_wrappers.h
+
+#define CMM_DRIVER_VERSION 1.0.0
+#define CMM_DEFAULT_DELAY 1
+#define CMM_DEBUG 0
+#define CMM_DISABLE0
+#define CMM_OOM_KB 1024
+#define CMM_MIN_MEM_MB 256
+#define KB2PAGES(_p) ((_p)(PAGE_SHIFT-10))
+#define PAGES2KB(_p) ((_p)(PAGE_SHIFT-10))
+
+static unsigned int delay = CMM_DEFAULT_DELAY;
+static unsigned int oom_kb = CMM_OOM_KB;
+static unsigned int cmm_debug = CMM_DEBUG;
+static unsigned int cmm_disabled = CMM_DISABLE;
+static unsigned long min_mem_mb = CMM_MIN_MEM_MB;
+static struct sys_device cmm_sysdev;
+
+MODULE_AUTHOR(Brian King [EMAIL PROTECTED]);
+MODULE_DESCRIPTION(IBM System p Collaborative Memory Manager);
+MODULE_LICENSE(GPL);
+MODULE_VERSION(CMM_DRIVER_VERSION);
+
+module_param_named(delay, delay, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(delay, Delay (in seconds) between polls to query hypervisor
paging requests.
+[Default= __stringify(CMM_DEFAULT_DELAY) ]);
+module_param_named(oom_kb, oom_kb, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(oom_kb, Amount of memory in kb to free on OOM.
+[Default= __stringify(CMM_OOM_KB) ]);
+module_param_named(min_mem_mb, min_mem_mb, ulong, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(min_mem_mb, Minimum amount of memory (in MB) to not balloon.
+[Default= __stringify(CMM_MIN_MEM_MB) ]);
+module_param_named(debug, cmm_debug, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(debug, Enable module debugging logging. Set to 1 to enable.
+[Default= __stringify(CMM_DEBUG) ]);
+
+#define CMM_NR_PAGES ((PAGE_SIZE -