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>
20 #include <linux/config.h>
22 #include <linux/compiler.h>
24 #include <linux/page-flags.h>
25 #include <linux/threads.h>
27 #include <asm/mmu_context.h>
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)
34 static inline long pgtable_quicklist_total_size(void)
39 for_each_online_cpu(cpuid) {
40 ql_size += per_cpu(__pgtable_quicklist_size, cpuid);
45 static inline void *pgtable_quicklist_alloc(void)
47 unsigned long *ret = NULL;
51 ret = pgtable_quicklist;
52 if (likely(ret != NULL)) {
53 pgtable_quicklist = (unsigned long *)(*ret);
55 --pgtable_quicklist_size;
59 ret = (unsigned long *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
65 static inline void pgtable_quicklist_free(void *pgtable_entry)
68 unsigned long nid = page_to_nid(virt_to_page(pgtable_entry));
70 if (unlikely(nid != numa_node_id())) {
71 free_page((unsigned long)pgtable_entry);
77 *(unsigned long *)pgtable_entry = (unsigned long)pgtable_quicklist;
78 pgtable_quicklist = (unsigned long *)pgtable_entry;
79 ++pgtable_quicklist_size;
83 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
85 return pgtable_quicklist_alloc();
88 static inline void pgd_free(pgd_t * pgd)
90 pgtable_quicklist_free(pgd);
93 #ifdef CONFIG_PGTABLE_4
95 pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
97 pgd_val(*pgd_entry) = __pa(pud);
100 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
102 return pgtable_quicklist_alloc();
105 static inline void pud_free(pud_t * pud)
107 pgtable_quicklist_free(pud);
109 #define __pud_free_tlb(tlb, pud) pud_free(pud)
110 #endif /* CONFIG_PGTABLE_4 */
113 pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
115 pud_val(*pud_entry) = __pa(pmd);
118 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
120 return pgtable_quicklist_alloc();
123 static inline void pmd_free(pmd_t * pmd)
125 pgtable_quicklist_free(pmd);
128 #define __pmd_free_tlb(tlb, pmd) pmd_free(pmd)
131 pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, struct page *pte)
133 pmd_val(*pmd_entry) = page_to_phys(pte);
137 pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte)
139 pmd_val(*pmd_entry) = __pa(pte);
142 static inline struct page *pte_alloc_one(struct mm_struct *mm,
145 return virt_to_page(pgtable_quicklist_alloc());
148 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
151 return pgtable_quicklist_alloc();
154 static inline void pte_free(struct page *pte)
156 pgtable_quicklist_free(page_address(pte));
159 static inline void pte_free_kernel(pte_t * pte)
161 pgtable_quicklist_free(pte);
164 #define __pte_free_tlb(tlb, pte) pte_free(pte)
166 extern void check_pgt_cache(void);
168 #endif /* _ASM_IA64_PGALLOC_H */