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