diff options
Diffstat (limited to 'include/asm-sh/pgalloc.h')
-rw-r--r-- | include/asm-sh/pgalloc.h | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/include/asm-sh/pgalloc.h b/include/asm-sh/pgalloc.h index 888e4529e6fe..26e493f39dbb 100644 --- a/include/asm-sh/pgalloc.h +++ b/include/asm-sh/pgalloc.h | |||
@@ -1,6 +1,12 @@ | |||
1 | #ifndef __ASM_SH_PGALLOC_H | 1 | #ifndef __ASM_SH_PGALLOC_H |
2 | #define __ASM_SH_PGALLOC_H | 2 | #define __ASM_SH_PGALLOC_H |
3 | 3 | ||
4 | #include <linux/quicklist.h> | ||
5 | #include <asm/page.h> | ||
6 | |||
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 */ | ||
9 | |||
4 | static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, | 10 | static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, |
5 | pte_t *pte) | 11 | pte_t *pte) |
6 | { | 12 | { |
@@ -13,48 +19,49 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, | |||
13 | set_pmd(pmd, __pmd((unsigned long)page_address(pte))); | 19 | set_pmd(pmd, __pmd((unsigned long)page_address(pte))); |
14 | } | 20 | } |
15 | 21 | ||
22 | static inline void pgd_ctor(void *x) | ||
23 | { | ||
24 | pgd_t *pgd = x; | ||
25 | |||
26 | memcpy(pgd + USER_PTRS_PER_PGD, | ||
27 | swapper_pg_dir + USER_PTRS_PER_PGD, | ||
28 | (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t)); | ||
29 | } | ||
30 | |||
16 | /* | 31 | /* |
17 | * Allocate and free page tables. | 32 | * Allocate and free page tables. |
18 | */ | 33 | */ |
19 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) | 34 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) |
20 | { | 35 | { |
21 | pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT); | 36 | return quicklist_alloc(QUICK_PGD, GFP_KERNEL | __GFP_REPEAT, pgd_ctor); |
22 | |||
23 | if (pgd) { | ||
24 | memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t)); | ||
25 | memcpy(pgd + USER_PTRS_PER_PGD, | ||
26 | swapper_pg_dir + USER_PTRS_PER_PGD, | ||
27 | (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t)); | ||
28 | } | ||
29 | |||
30 | return pgd; | ||
31 | } | 37 | } |
32 | 38 | ||
33 | static inline void pgd_free(pgd_t *pgd) | 39 | static inline void pgd_free(pgd_t *pgd) |
34 | { | 40 | { |
35 | free_page((unsigned long)pgd); | 41 | quicklist_free(QUICK_PGD, NULL, pgd); |
36 | } | 42 | } |
37 | 43 | ||
38 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, | 44 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, |
39 | unsigned long address) | 45 | unsigned long address) |
40 | { | 46 | { |
41 | return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO); | 47 | return quicklist_alloc(QUICK_PT, GFP_KERNEL, NULL); |
42 | } | 48 | } |
43 | 49 | ||
44 | static inline struct page *pte_alloc_one(struct mm_struct *mm, | 50 | static inline struct page *pte_alloc_one(struct mm_struct *mm, |
45 | unsigned long address) | 51 | unsigned long address) |
46 | { | 52 | { |
47 | return alloc_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO); | 53 | void *pg = quicklist_alloc(QUICK_PT, GFP_KERNEL, NULL); |
54 | return pg ? virt_to_page(pg) : NULL; | ||
48 | } | 55 | } |
49 | 56 | ||
50 | static inline void pte_free_kernel(pte_t *pte) | 57 | static inline void pte_free_kernel(pte_t *pte) |
51 | { | 58 | { |
52 | free_page((unsigned long)pte); | 59 | quicklist_free(QUICK_PT, NULL, pte); |
53 | } | 60 | } |
54 | 61 | ||
55 | static inline void pte_free(struct page *pte) | 62 | static inline void pte_free(struct page *pte) |
56 | { | 63 | { |
57 | __free_page(pte); | 64 | quicklist_free_page(QUICK_PT, NULL, pte); |
58 | } | 65 | } |
59 | 66 | ||
60 | #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte)) | 67 | #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte)) |
@@ -66,6 +73,11 @@ static inline void pte_free(struct page *pte) | |||
66 | 73 | ||
67 | #define pmd_free(x) do { } while (0) | 74 | #define pmd_free(x) do { } while (0) |
68 | #define __pmd_free_tlb(tlb,x) do { } while (0) | 75 | #define __pmd_free_tlb(tlb,x) do { } while (0) |
69 | #define check_pgt_cache() do { } while (0) | 76 | |
77 | static inline void check_pgt_cache(void) | ||
78 | { | ||
79 | quicklist_trim(QUICK_PGD, NULL, 25, 16); | ||
80 | quicklist_trim(QUICK_PT, NULL, 25, 16); | ||
81 | } | ||
70 | 82 | ||
71 | #endif /* __ASM_SH_PGALLOC_H */ | 83 | #endif /* __ASM_SH_PGALLOC_H */ |