1 From 14f966e79445015cd89d0fa0ceb6b33702e951b6 Mon Sep 17 00:00:00 2001
2 From: Robert Jennings <rcj@linux.vnet.ibm.com>
3 Date: Wed, 15 Apr 2009 05:55:32 +0000
4 Subject: powerpc/pseries: CMO unused page hinting
8 From: Robert Jennings <rcj@linux.vnet.ibm.com>
10 commit 14f966e79445015cd89d0fa0ceb6b33702e951b6 upstream.
12 Adds support for the "unused" page hint which can be used in shared
13 memory partitions to flag pages not in use, which will then be stolen
14 before active pages by the hypervisor when memory needs to be moved to
15 LPARs in need of additional memory. Failure to mark pages as 'unused'
16 makes the LPAR slower to give up unused memory to other partitions.
18 This adds the kernel parameter 'cmo_free_hint' to disable this
21 Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
22 Signed-off-by: Robert Jennings <rcj@linux.vnet.ibm.com>
23 Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
27 Documentation/kernel-parameters.txt | 7 ++++
28 arch/powerpc/include/asm/page.h | 5 +++
29 arch/powerpc/platforms/pseries/lpar.c | 52 ++++++++++++++++++++++++++++++++++
30 3 files changed, 64 insertions(+)
32 --- a/Documentation/kernel-parameters.txt
33 +++ b/Documentation/kernel-parameters.txt
34 @@ -458,6 +458,13 @@ and is between 256 and 4096 characters.
35 Also note the kernel might malfunction if you disable
38 + cmo_free_hint= [PPC] Format: { yes | no }
39 + Specify whether pages are marked as being inactive
40 + when they are freed. This is used in CMO environments
41 + to determine OS memory pressure for page stealing by
45 code_bytes [IA32/X86_64] How many bytes of object code to print
48 --- a/arch/powerpc/include/asm/page.h
49 +++ b/arch/powerpc/include/asm/page.h
50 @@ -215,6 +215,11 @@ extern void copy_user_page(void *to, voi
52 extern int page_is_ram(unsigned long pfn);
54 +#ifdef CONFIG_PPC_SMLPAR
55 +void arch_free_page(struct page *page, int order);
56 +#define HAVE_ARCH_FREE_PAGE
59 struct vm_area_struct;
61 typedef struct page *pgtable_t;
62 --- a/arch/powerpc/platforms/pseries/lpar.c
63 +++ b/arch/powerpc/platforms/pseries/lpar.c
64 @@ -609,3 +609,55 @@ void __init hpte_init_lpar(void)
65 ppc_md.flush_hash_range = pSeries_lpar_flush_hash_range;
66 ppc_md.hpte_clear_all = pSeries_lpar_hptab_clear;
69 +#ifdef CONFIG_PPC_SMLPAR
70 +#define CMO_FREE_HINT_DEFAULT 1
71 +static int cmo_free_hint_flag = CMO_FREE_HINT_DEFAULT;
73 +static int __init cmo_free_hint(char *str)
76 + parm = strstrip(str);
78 + if (strcasecmp(parm, "no") == 0 || strcasecmp(parm, "off") == 0) {
79 + printk(KERN_INFO "cmo_free_hint: CMO free page hinting is not active.\n");
80 + cmo_free_hint_flag = 0;
84 + cmo_free_hint_flag = 1;
85 + printk(KERN_INFO "cmo_free_hint: CMO free page hinting is active.\n");
87 + if (strcasecmp(parm, "yes") == 0 || strcasecmp(parm, "on") == 0)
93 +__setup("cmo_free_hint=", cmo_free_hint);
95 +static void pSeries_set_page_state(struct page *page, int order,
96 + unsigned long state)
99 + unsigned long cmo_page_sz, addr;
101 + cmo_page_sz = cmo_get_page_size();
102 + addr = __pa((unsigned long)page_address(page));
104 + for (i = 0; i < (1 << order); i++, addr += PAGE_SIZE) {
105 + for (j = 0; j < PAGE_SIZE; j += cmo_page_sz)
106 + plpar_hcall_norets(H_PAGE_INIT, state, addr + j, 0);
110 +void arch_free_page(struct page *page, int order)
112 + if (!cmo_free_hint_flag || !firmware_has_feature(FW_FEATURE_CMO))
115 + pSeries_set_page_state(page, order, H_PAGE_SET_UNUSED);
117 +EXPORT_SYMBOL(arch_free_page);