]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/suse-2.6.27.39/patches.arch/powerpc-pseries-cmo-unused-page-hinting.patch
Add a patch to fix Intel E100 wake-on-lan problems.
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.arch / powerpc-pseries-cmo-unused-page-hinting.patch
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
5 Patch-mainline: 2.6.31
6 References: bnc#495091
7
8 From: Robert Jennings <rcj@linux.vnet.ibm.com>
9
10 commit 14f966e79445015cd89d0fa0ceb6b33702e951b6 upstream.
11
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.
17
18 This adds the kernel parameter 'cmo_free_hint' to disable this
19 functionality.
20
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>
25
26 ---
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(+)
31
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
36 some critical bits.
37
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
42 + a hypervisor.
43 + Default: yes
44 +
45 code_bytes [IA32/X86_64] How many bytes of object code to print
46 in an oops report.
47 Range: 0 - 8192
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
51 struct page *p);
52 extern int page_is_ram(unsigned long pfn);
53
54 +#ifdef CONFIG_PPC_SMLPAR
55 +void arch_free_page(struct page *page, int order);
56 +#define HAVE_ARCH_FREE_PAGE
57 +#endif
58 +
59 struct vm_area_struct;
60
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;
67 }
68 +
69 +#ifdef CONFIG_PPC_SMLPAR
70 +#define CMO_FREE_HINT_DEFAULT 1
71 +static int cmo_free_hint_flag = CMO_FREE_HINT_DEFAULT;
72 +
73 +static int __init cmo_free_hint(char *str)
74 +{
75 + char *parm;
76 + parm = strstrip(str);
77 +
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;
81 + return 1;
82 + }
83 +
84 + cmo_free_hint_flag = 1;
85 + printk(KERN_INFO "cmo_free_hint: CMO free page hinting is active.\n");
86 +
87 + if (strcasecmp(parm, "yes") == 0 || strcasecmp(parm, "on") == 0)
88 + return 1;
89 +
90 + return 0;
91 +}
92 +
93 +__setup("cmo_free_hint=", cmo_free_hint);
94 +
95 +static void pSeries_set_page_state(struct page *page, int order,
96 + unsigned long state)
97 +{
98 + int i, j;
99 + unsigned long cmo_page_sz, addr;
100 +
101 + cmo_page_sz = cmo_get_page_size();
102 + addr = __pa((unsigned long)page_address(page));
103 +
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);
107 + }
108 +}
109 +
110 +void arch_free_page(struct page *page, int order)
111 +{
112 + if (!cmo_free_hint_flag || !firmware_has_feature(FW_FEATURE_CMO))
113 + return;
114 +
115 + pSeries_set_page_state(page, order, H_PAGE_SET_UNUSED);
116 +}
117 +EXPORT_SYMBOL(arch_free_page);
118 +
119 +#endif