Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / include / asm-ia64 / pgalloc.h
1 #ifndef _ASM_IA64_PGALLOC_H
2 #define _ASM_IA64_PGALLOC_H
3
4 #define arch_add_exec_range(mm, limit)          do { ; } while (0)
5 #define arch_flush_exec_range(mm)               do { ; } while (0)
6 #define arch_remove_exec_range(mm, limit)       do { ; } while (0)
7
8 /*
9  * This file contains the functions and defines necessary to allocate
10  * page tables.
11  *
12  * This hopefully works with any (fixed) ia-64 page-size, as defined
13  * in <asm/page.h> (currently 8192).
14  *
15  * Copyright (C) 1998-2001 Hewlett-Packard Co
16  *      David Mosberger-Tang <davidm@hpl.hp.com>
17  * Copyright (C) 2000, Goutham Rao <goutham.rao@intel.com>
18  */
19
20 #include <linux/config.h>
21
22 #include <linux/compiler.h>
23 #include <linux/mm.h>
24 #include <linux/page-flags.h>
25 #include <linux/threads.h>
26
27 #include <asm/mmu_context.h>
28
29 DECLARE_PER_CPU(unsigned long *, __pgtable_quicklist);
30 #define pgtable_quicklist __ia64_per_cpu_var(__pgtable_quicklist)
31 DECLARE_PER_CPU(long, __pgtable_quicklist_size);
32 #define pgtable_quicklist_size __ia64_per_cpu_var(__pgtable_quicklist_size)
33
34 static inline long pgtable_quicklist_total_size(void)
35 {
36         long ql_size = 0;
37         int cpuid;
38
39         for_each_online_cpu(cpuid) {
40                 ql_size += per_cpu(__pgtable_quicklist_size, cpuid);
41         }
42         return ql_size;
43 }
44
45 static inline void *pgtable_quicklist_alloc(void)
46 {
47         unsigned long *ret = NULL;
48
49         preempt_disable();
50
51         ret = pgtable_quicklist;
52         if (likely(ret != NULL)) {
53                 pgtable_quicklist = (unsigned long *)(*ret);
54                 ret[0] = 0;
55                 --pgtable_quicklist_size;
56                 preempt_enable();
57         } else {
58                 preempt_enable();
59                 ret = (unsigned long *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
60         }
61
62         return ret;
63 }
64
65 static inline void pgtable_quicklist_free(void *pgtable_entry)
66 {
67 #ifdef CONFIG_NUMA
68         unsigned long nid = page_to_nid(virt_to_page(pgtable_entry));
69
70         if (unlikely(nid != numa_node_id())) {
71                 free_page((unsigned long)pgtable_entry);
72                 return;
73         }
74 #endif
75
76         preempt_disable();
77         *(unsigned long *)pgtable_entry = (unsigned long)pgtable_quicklist;
78         pgtable_quicklist = (unsigned long *)pgtable_entry;
79         ++pgtable_quicklist_size;
80         preempt_enable();
81 }
82
83 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
84 {
85         return pgtable_quicklist_alloc();
86 }
87
88 static inline void pgd_free(pgd_t * pgd)
89 {
90         pgtable_quicklist_free(pgd);
91 }
92
93 #ifdef CONFIG_PGTABLE_4
94 static inline void
95 pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
96 {
97         pgd_val(*pgd_entry) = __pa(pud);
98 }
99
100 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
101 {
102         return pgtable_quicklist_alloc();
103 }
104
105 static inline void pud_free(pud_t * pud)
106 {
107         pgtable_quicklist_free(pud);
108 }
109 #define __pud_free_tlb(tlb, pud)        pud_free(pud)
110 #endif /* CONFIG_PGTABLE_4 */
111
112 static inline void
113 pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
114 {
115         pud_val(*pud_entry) = __pa(pmd);
116 }
117
118 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
119 {
120         return pgtable_quicklist_alloc();
121 }
122
123 static inline void pmd_free(pmd_t * pmd)
124 {
125         pgtable_quicklist_free(pmd);
126 }
127
128 #define __pmd_free_tlb(tlb, pmd)        pmd_free(pmd)
129
130 static inline void
131 pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, struct page *pte)
132 {
133         pmd_val(*pmd_entry) = page_to_phys(pte);
134 }
135
136 static inline void
137 pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte)
138 {
139         pmd_val(*pmd_entry) = __pa(pte);
140 }
141
142 static inline struct page *pte_alloc_one(struct mm_struct *mm,
143                                          unsigned long addr)
144 {
145         return virt_to_page(pgtable_quicklist_alloc());
146 }
147
148 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
149                                           unsigned long addr)
150 {
151         return pgtable_quicklist_alloc();
152 }
153
154 static inline void pte_free(struct page *pte)
155 {
156         pgtable_quicklist_free(page_address(pte));
157 }
158
159 static inline void pte_free_kernel(pte_t * pte)
160 {
161         pgtable_quicklist_free(pte);
162 }
163
164 #define __pte_free_tlb(tlb, pte)        pte_free(pte)
165
166 extern void check_pgt_cache(void);
167
168 #endif                          /* _ASM_IA64_PGALLOC_H */