upgrade to fedora-2.6.12-1.1398.FC4 + vserver 2.0.rc7
[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 static inline void
94 pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
95 {
96         pud_val(*pud_entry) = __pa(pmd);
97 }
98
99 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
100 {
101         return pgtable_quicklist_alloc();
102 }
103
104 static inline void pmd_free(pmd_t * pmd)
105 {
106         pgtable_quicklist_free(pmd);
107 }
108
109 #define __pmd_free_tlb(tlb, pmd)        pmd_free(pmd)
110
111 static inline void
112 pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, struct page *pte)
113 {
114         pmd_val(*pmd_entry) = page_to_phys(pte);
115 }
116
117 static inline void
118 pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte)
119 {
120         pmd_val(*pmd_entry) = __pa(pte);
121 }
122
123 static inline struct page *pte_alloc_one(struct mm_struct *mm,
124                                          unsigned long addr)
125 {
126         return virt_to_page(pgtable_quicklist_alloc());
127 }
128
129 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
130                                           unsigned long addr)
131 {
132         return pgtable_quicklist_alloc();
133 }
134
135 static inline void pte_free(struct page *pte)
136 {
137         pgtable_quicklist_free(page_address(pte));
138 }
139
140 static inline void pte_free_kernel(pte_t * pte)
141 {
142         pgtable_quicklist_free(pte);
143 }
144
145 #define __pte_free_tlb(tlb, pte)        pte_free(pte)
146
147 extern void check_pgt_cache(void);
148
149 #endif                          /* _ASM_IA64_PGALLOC_H */