[TCP]: Compute in_sacked properly when we split up a TSO frame.
[linux-2.6] / include / asm-ia64 / pgalloc.h
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
25 DECLARE_PER_CPU(unsigned long *, __pgtable_quicklist);
26 #define pgtable_quicklist __ia64_per_cpu_var(__pgtable_quicklist)
27 DECLARE_PER_CPU(long, __pgtable_quicklist_size);
28 #define pgtable_quicklist_size __ia64_per_cpu_var(__pgtable_quicklist_size)
29
30 static inline long pgtable_quicklist_total_size(void)
31 {
32         long ql_size = 0;
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
41 static inline void *pgtable_quicklist_alloc(void)
42 {
43         unsigned long *ret = NULL;
44
45         preempt_disable();
46
47         ret = pgtable_quicklist;
48         if (likely(ret != NULL)) {
49                 pgtable_quicklist = (unsigned long *)(*ret);
50                 ret[0] = 0;
51                 --pgtable_quicklist_size;
52                 preempt_enable();
53         } else {
54                 preempt_enable();
55                 ret = (unsigned long *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
56         }
57
58         return ret;
59 }
60
61 static inline void pgtable_quicklist_free(void *pgtable_entry)
62 {
63 #ifdef CONFIG_NUMA
64         unsigned long nid = page_to_nid(virt_to_page(pgtable_entry));
65
66         if (unlikely(nid != numa_node_id())) {
67                 free_page((unsigned long)pgtable_entry);
68                 return;
69         }
70 #endif
71
72         preempt_disable();
73         *(unsigned long *)pgtable_entry = (unsigned long)pgtable_quicklist;
74         pgtable_quicklist = (unsigned long *)pgtable_entry;
75         ++pgtable_quicklist_size;
76         preempt_enable();
77 }
78
79 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
80 {
81         return pgtable_quicklist_alloc();
82 }
83
84 static inline void pgd_free(pgd_t * pgd)
85 {
86         pgtable_quicklist_free(pgd);
87 }
88
89 static inline void
90 pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
91 {
92         pud_val(*pud_entry) = __pa(pmd);
93 }
94
95 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
96 {
97         return pgtable_quicklist_alloc();
98 }
99
100 static inline void pmd_free(pmd_t * pmd)
101 {
102         pgtable_quicklist_free(pmd);
103 }
104
105 #define __pmd_free_tlb(tlb, pmd)        pmd_free(pmd)
106
107 static inline void
108 pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, struct page *pte)
109 {
110         pmd_val(*pmd_entry) = page_to_phys(pte);
111 }
112
113 static inline void
114 pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte)
115 {
116         pmd_val(*pmd_entry) = __pa(pte);
117 }
118
119 static inline struct page *pte_alloc_one(struct mm_struct *mm,
120                                          unsigned long addr)
121 {
122         return virt_to_page(pgtable_quicklist_alloc());
123 }
124
125 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
126                                           unsigned long addr)
127 {
128         return pgtable_quicklist_alloc();
129 }
130
131 static inline void pte_free(struct page *pte)
132 {
133         pgtable_quicklist_free(page_address(pte));
134 }
135
136 static inline void pte_free_kernel(pte_t * pte)
137 {
138         pgtable_quicklist_free(pte);
139 }
140
141 #define __pte_free_tlb(tlb, pte)        pte_free(pte)
142
143 extern void check_pgt_cache(void);
144
145 #endif                          /* _ASM_IA64_PGALLOC_H */