vserver 1.9.3
[linux-2.6.git] / include / asm-ppc64 / pgalloc.h
1 #ifndef _PPC64_PGALLOC_H
2 #define _PPC64_PGALLOC_H
3
4 #include <linux/mm.h>
5 #include <linux/slab.h>
6 #include <linux/cpumask.h>
7 #include <linux/percpu.h>
8 #include <asm/processor.h>
9 #include <asm/tlb.h>
10 #include <asm/page.h>
11
12 extern kmem_cache_t *zero_cache;
13
14 /*
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version
18  * 2 of the License, or (at your option) any later version.
19  */
20
21 static inline pgd_t *
22 pgd_alloc(struct mm_struct *mm)
23 {
24         return kmem_cache_alloc(zero_cache, GFP_KERNEL);
25 }
26
27 static inline void
28 pgd_free(pgd_t *pgd)
29 {
30         kmem_cache_free(zero_cache, pgd);
31 }
32
33 #define pgd_populate(MM, PGD, PMD)      pgd_set(PGD, PMD)
34
35 static inline pmd_t *
36 pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
37 {
38         return kmem_cache_alloc(zero_cache, GFP_KERNEL|__GFP_REPEAT);
39 }
40
41 static inline void
42 pmd_free(pmd_t *pmd)
43 {
44         kmem_cache_free(zero_cache, pmd);
45 }
46
47 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, pte)
48 #define pmd_populate(mm, pmd, pte_page) \
49         pmd_populate_kernel(mm, pmd, page_address(pte_page))
50
51 static inline pte_t *
52 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
53 {
54         pte_t *pte;
55         pte = kmem_cache_alloc(zero_cache, GFP_KERNEL|__GFP_REPEAT);
56         if (pte) {
57                 struct page *ptepage = virt_to_page(pte);
58                 ptepage->mapping = (void *) mm;
59                 ptepage->index = address & PMD_MASK;
60         }
61         return pte;
62 }
63
64 static inline struct page *
65 pte_alloc_one(struct mm_struct *mm, unsigned long address)
66 {
67         pte_t *pte;
68         pte = kmem_cache_alloc(zero_cache, GFP_KERNEL|__GFP_REPEAT);
69         if (pte) {
70                 struct page *ptepage = virt_to_page(pte);
71                 ptepage->mapping = (void *) mm;
72                 ptepage->index = address & PMD_MASK;
73                 return ptepage;
74         }
75         return NULL;
76 }
77                 
78 static inline void pte_free_kernel(pte_t *pte)
79 {
80         virt_to_page(pte)->mapping = NULL;
81         kmem_cache_free(zero_cache, pte);
82 }
83
84 static inline void pte_free(struct page *ptepage)
85 {
86         ptepage->mapping = NULL;
87         kmem_cache_free(zero_cache, page_address(ptepage));
88 }
89
90 struct pte_freelist_batch
91 {
92         struct rcu_head rcu;
93         unsigned int    index;
94         struct page *   pages[0];
95 };
96
97 #define PTE_FREELIST_SIZE       ((PAGE_SIZE - sizeof(struct pte_freelist_batch)) / \
98                                   sizeof(struct page *))
99
100 extern void pte_free_now(struct page *ptepage);
101 extern void pte_free_submit(struct pte_freelist_batch *batch);
102
103 DECLARE_PER_CPU(struct pte_freelist_batch *, pte_freelist_cur);
104
105 void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage);
106 #define __pmd_free_tlb(tlb, pmd)        __pte_free_tlb(tlb, virt_to_page(pmd))
107
108 #define check_pgt_cache()       do { } while (0)
109
110 #endif /* _PPC64_PGALLOC_H */