1 #ifndef __ASM_SH_PGALLOC_H
2 #define __ASM_SH_PGALLOC_H
4 #include <linux/quicklist.h>
7 #define QUICK_PGD 0 /* We preserve special mappings over free */
8 #define QUICK_PT 1 /* Other page table pages that are zero on free */
10 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
13 set_pmd(pmd, __pmd((unsigned long)pte));
16 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
19 set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
21 #define pmd_pgtable(pmd) pmd_page(pmd)
23 static inline void pgd_ctor(void *x)
27 memcpy(pgd + USER_PTRS_PER_PGD,
28 swapper_pg_dir + USER_PTRS_PER_PGD,
29 (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
33 * Allocate and free page tables.
35 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
37 return quicklist_alloc(QUICK_PGD, GFP_KERNEL | __GFP_REPEAT, pgd_ctor);
40 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
42 quicklist_free(QUICK_PGD, NULL, pgd);
45 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
46 unsigned long address)
48 return quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL);
51 static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
52 unsigned long address)
57 pg = quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL);
60 page = virt_to_page(pg);
61 pgtable_page_ctor(page);
65 static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
67 quicklist_free(QUICK_PT, NULL, pte);
70 static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
72 pgtable_page_dtor(pte);
73 quicklist_free_page(QUICK_PT, NULL, pte);
76 #define __pte_free_tlb(tlb,pte) \
78 pgtable_page_dtor(pte); \
79 tlb_remove_page((tlb), (pte)); \
83 * allocating and freeing a pmd is trivial: the 1-entry pmd is
84 * inside the pgd, so has no extra memory associated with it.
87 #define pmd_free(mm, x) do { } while (0)
88 #define __pmd_free_tlb(tlb,x) do { } while (0)
90 static inline void check_pgt_cache(void)
92 quicklist_trim(QUICK_PGD, NULL, 25, 16);
93 quicklist_trim(QUICK_PT, NULL, 25, 16);
96 #endif /* __ASM_SH_PGALLOC_H */