1 #ifndef _ASM_IA64_PGALLOC_H
2 #define _ASM_IA64_PGALLOC_H
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)
9 * This file contains the functions and defines necessary to allocate
12 * This hopefully works with any (fixed) ia-64 page-size, as defined
13 * in <asm/page.h> (currently 8192).
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>
21 #include <linux/compiler.h>
23 #include <linux/page-flags.h>
24 #include <linux/threads.h>
26 #include <asm/mmu_context.h>
28 DECLARE_PER_CPU(unsigned long *, __pgtable_quicklist);
29 #define pgtable_quicklist __ia64_per_cpu_var(__pgtable_quicklist)
30 DECLARE_PER_CPU(long, __pgtable_quicklist_size);
31 #define pgtable_quicklist_size __ia64_per_cpu_var(__pgtable_quicklist_size)
33 static inline long pgtable_quicklist_total_size(void)
38 for_each_online_cpu(cpuid) {
39 ql_size += per_cpu(__pgtable_quicklist_size, cpuid);
44 static inline void *pgtable_quicklist_alloc(void)
46 unsigned long *ret = NULL;
50 ret = pgtable_quicklist;
51 if (likely(ret != NULL)) {
52 pgtable_quicklist = (unsigned long *)(*ret);
54 --pgtable_quicklist_size;
58 ret = (unsigned long *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
64 static inline void pgtable_quicklist_free(void *pgtable_entry)
67 unsigned long nid = page_to_nid(virt_to_page(pgtable_entry));
69 if (unlikely(nid != numa_node_id())) {
70 free_page((unsigned long)pgtable_entry);
76 *(unsigned long *)pgtable_entry = (unsigned long)pgtable_quicklist;
77 pgtable_quicklist = (unsigned long *)pgtable_entry;
78 ++pgtable_quicklist_size;
82 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
84 return pgtable_quicklist_alloc();
87 static inline void pgd_free(pgd_t * pgd)
89 pgtable_quicklist_free(pgd);
92 #ifdef CONFIG_PGTABLE_4
94 pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
96 pgd_val(*pgd_entry) = __pa(pud);
99 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
101 return pgtable_quicklist_alloc();
104 static inline void pud_free(pud_t * pud)
106 pgtable_quicklist_free(pud);
108 #define __pud_free_tlb(tlb, pud) pud_free(pud)
109 #endif /* CONFIG_PGTABLE_4 */
112 pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
114 pud_val(*pud_entry) = __pa(pmd);
117 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
119 return pgtable_quicklist_alloc();
122 static inline void pmd_free(pmd_t * pmd)
124 pgtable_quicklist_free(pmd);
127 #define __pmd_free_tlb(tlb, pmd) pmd_free(pmd)
130 pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, struct page *pte)
133 pmd_val(*pmd_entry) = page_to_phys(pte);
135 pmd_val(*pmd_entry) = page_to_pseudophys(pte);
140 pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte)
142 pmd_val(*pmd_entry) = __pa(pte);
145 static inline struct page *pte_alloc_one(struct mm_struct *mm,
148 return virt_to_page(pgtable_quicklist_alloc());
151 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
154 return pgtable_quicklist_alloc();
157 static inline void pte_free(struct page *pte)
159 pgtable_quicklist_free(page_address(pte));
162 static inline void pte_free_kernel(pte_t * pte)
164 pgtable_quicklist_free(pte);
167 #define __pte_free_tlb(tlb, pte) pte_free(pte)
169 extern void check_pgt_cache(void);
171 #endif /* _ASM_IA64_PGALLOC_H */