2 * Copyright IBM Corp. 2008
4 * Guest page hinting for unused pages.
6 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
9 #include <linux/kernel.h>
10 #include <linux/errno.h>
11 #include <linux/types.h>
13 #include <linux/gfp.h>
14 #include <linux/init.h>
16 #define ESSA_SET_STABLE 1
17 #define ESSA_SET_UNUSED 2
19 static int cmma_flag
= 1;
21 static int __init
cmma(char *str
)
26 if (strcmp(parm
, "yes") == 0 || strcmp(parm
, "on") == 0) {
31 if (strcmp(parm
, "no") == 0 || strcmp(parm
, "off") == 0)
35 __setup("cmma=", cmma
);
37 void __init
cmma_init(void)
39 register unsigned long tmp
asm("0") = 0;
40 register int rc
asm("1") = -EOPNOTSUPP
;
45 " .insn rrf,0xb9ab0000,%1,%1,0,0\n"
49 : "+&d" (rc
), "+&d" (tmp
));
54 static inline void set_page_unstable(struct page
*page
, int order
)
58 for (i
= 0; i
< (1 << order
); i
++)
59 asm volatile(".insn rrf,0xb9ab0000,%0,%1,%2,0"
61 : "a" (page_to_phys(page
+ i
)),
62 "i" (ESSA_SET_UNUSED
));
65 void arch_free_page(struct page
*page
, int order
)
69 set_page_unstable(page
, order
);
72 static inline void set_page_stable(struct page
*page
, int order
)
76 for (i
= 0; i
< (1 << order
); i
++)
77 asm volatile(".insn rrf,0xb9ab0000,%0,%1,%2,0"
79 : "a" (page_to_phys(page
+ i
)),
80 "i" (ESSA_SET_STABLE
));
83 void arch_alloc_page(struct page
*page
, int order
)
87 set_page_stable(page
, order
);
90 void arch_set_page_states(int make_stable
)
92 unsigned long flags
, order
, t
;
100 drain_local_pages(NULL
);
101 for_each_populated_zone(zone
) {
102 spin_lock_irqsave(&zone
->lock
, flags
);
103 for_each_migratetype_order(order
, t
) {
104 list_for_each(l
, &zone
->free_area
[order
].free_list
[t
]) {
105 page
= list_entry(l
, struct page
, lru
);
107 set_page_stable(page
, order
);
109 set_page_unstable(page
, order
);
112 spin_unlock_irqrestore(&zone
->lock
, flags
);