aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-sh
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2007-05-07 22:55:21 -0400
committerPaul Mundt <lethal@hera.kernel.org>2007-05-08 21:35:00 -0400
commit5f8c9908f200b775a3d6c345bc6f3e928e2426a9 (patch)
tree0e7077bdc8fef01c54845b0ed5f524bb31324350 /include/asm-sh
parent36f021b579d195cdc5fa6f3e2bab198b4bf70643 (diff)
sh: generic quicklist support.
This moves SH over to the generic quicklists. As per x86_64, we have special mappings for the PGDs, so these go on their own list.. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'include/asm-sh')
-rw-r--r--include/asm-sh/pgalloc.h44
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
4static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, 10static 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
22static 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 */
19static inline pgd_t *pgd_alloc(struct mm_struct *mm) 34static 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
33static inline void pgd_free(pgd_t *pgd) 39static 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
38static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 44static 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
44static inline struct page *pte_alloc_one(struct mm_struct *mm, 50static 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
50static inline void pte_free_kernel(pte_t *pte) 57static 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
55static inline void pte_free(struct page *pte) 62static 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
77static 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 */